You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
graphMLlink is used in graphics community a lot. Here is a simple conversion code that can be used in odML. This would be helpful for importing odML to graph databases natively. Here is an example conversion that can be used as a basic starting point.
""" odml2graphml Basic odML to graphML converter (c) 2017 German Neuroinformatics Node (G-Node)"""importxml.etree.ElementTreeasETfrompygraphmlimportGraphfrompygraphmlimportGraphMLParserimportuuid# Filesbase_name='rg_dummy'odml_fname=base_name+'.odml'graphml_fname=base_name+'.graphml'# Read odmltree=ET.parse(odml_fname)
root=tree.getroot()
odml_graph=Graph()
child_id=0is_terminal_node_prev=Falseprev_uuid_value=0prev_node=0is_odml_rel_node=0prev_tag= 'odMLforelemintree.iter(): # iter over elementsis_terminal_node=elem.getchildren() == []
is_odml_tag=elem.tagin ['section', 'odML', 'property']
if(is_odml_tag):
uuid_value=str(uuid.uuid4()) # generate UUID for an elementnode=odml_graph.add_node(uuid_value)
node["odml_entity"] =elem.tagnode["uuid"] =uuid_valuechild_id=1is_odml_rel_node=0if(elem.tag=="odML"):
odml_node=nodeelse:
node[elem.tag] =elem.textnode["labels"] =":reach2Grasp"is_terminal_node_prev=is_terminal_nodeif(is_odml_rel_node<1andchild_id>0andis_odml_tag==Trueandprev_tagin ['section', 'property']):
edge=odml_graph.add_edge(prev_node, node, directed=True)
edge=odml_graph.add_edge(odml_node, node, directed=True)
edge['relation'] ='child'if(elem.tagin ['section', 'odML']):
is_odml_rel_node=1prev_node=nodeprev_uuid_value=uuid_valueprev_tag=elem.tagparser=GraphMLParser()
parser.write(odml_graph, graphml_fname)
The text was updated successfully, but these errors were encountered:
graphML
link is used in graphics community a lot. Here is a simple conversion code that can be used in odML. This would be helpful for importing odML to graph databases natively. Here is an example conversion that can be used as a basic starting point.The text was updated successfully, but these errors were encountered: