PAX2Graphml Properties management example

  • display all node and edge properties with types,
  • create a property
  • modify the type of properties
  • manipulate properties values as list
  • list all unique values of a property
In [1]:
#
import os,sys
import numpy as np
import graph_tool.all as gt
import pax2graphml  as p2g



rootPath="/home/user/example/"
resultPath=rootPath+"result/"
graphmlfile=resultPath+"G6P_neig_1.graphml"
g=p2g.graph_explore.load_graphml(graphmlfile, directed=True)
print("#initial alias property")
print(p2g.properties.describe_properties(g,"alias"))

p2g.properties.string_to_list_property(g,"alias")
 
aliasList=p2g.properties.node_property_values(g,"alias")

print("#updated alias property")
print(p2g.properties.describe_properties(g,"alias"))
print("#all properties (node+edge)")
print(p2g.properties.describe_properties(g))

print("#all node property alias values:\n%s\n" %(aliasList))

spaimList=p2g.properties.edge_property_values(g,"spaim")
print("#all edge property spaim values:\n%s\n" %(spaimList))

#print(p2g.graph_explore.describe_graph(g))
#initial alias property
node, alias, string 

#updated alias property
node, alias, python::object 

#all properties (node+edge)
node, _graphml_vertex_id, string 
node, biopaxType, string 
node, chebi, string 
node, color, string 
node, evidence, string 
node, generic, string 
node, hgnc, string 
node, input, int64_t 
node, name, string 
node, organism, string 
node, provider, string 
node, shape, string 
node, spaimCase, string 
node, uniprot, string 
node, uri, string 
node, alias, python::object 
edge, _graphml_edge_id, string 
edge, interaction, string 
edge, spaim, string 

#all node property alias values:
['', 'Phosphate', 'Phosphoglucomutase-2', 'D-Glucose 1-phosphate <=> alpha-D-Glucose 6-phosphate', 'ADP', 'alpha-D-glucose', 'alpha-D-Glucose 6-phosphate + H2O => alpha-D-Glucose + Orthophosphate (G6PC - liver)', 'Pi', 'D-Glucono-1,5-lactone 6-phosphate', 'G6PC2 hydrolyzes glucose 6-phosphate to form glucose and orthophosphate (islet)', 'Glucose phosphomutase', 'PGYM b dimer:AMP', 'alpha-D-Glucose 6-phosphate <=> D-Glucose 1-phosphate', 'H2O', 'PGM1:Mg2+, PGM2:Mg2+', 'D-Fructose 6-phosphoric acid', 'Magnesium', 'D-Fructose 6-phosphate', "Adenosine 5'-triphosphate", 'AMP', 'alpha-D-glucose 6-phosphate + NADP+ => D-glucono-1,5-lactone 6-phosphate + NADPH + H+', 'glucose 6-phosphate isomerase dimer', 'HK1,2,3,GCK phosphorylate Glc to form G6P', 'TPNH', 'polyGlc-GYG1:GYS1-b tetramer', 'oligoGlc-GYG1:GYS1-b tetramer', 'alpha-D-Glucose 1-phosphate', 'GCK, HK1, HK2, HK3', 'PGM1:Mg++', 'Myophosphorylase', 'phosphorylated glycogen synthase 1', 'UDPglucose', "Adenosine 5'-diphosphate", 'phosphate(3-)', 'NADP+', 'alpha-D-glucose 6-phosphate <=> D-fructose 6-phosphate', 'magnesium(2+)', 'D-glucopyranose 1-phosphate', 'NADP(+)', 'glucokinase and hexokinases', 'NADP', 'poly((1,4)-alpha-glucosyl)GYG1', 'Nicotinamide adenine dinucleotide phosphate', 'ATP', 'TPN', '8 UDP-glucose + ((1,4)-alpha-D-glucosyl)4 glycogenin => 8 UDP + ((1,4)-alpha-D-glucosyl)8 glycogenin (GYS1-b)', 'oligo((1,4)-alpha-glucosyl) GYG1', 'PGM1, PGM2', 'phosphoglucomutase 1', 'alpha-D-Glucose 6-phosphate + H2O => alpha-D-Glucose + Orthophosphate (G6PC2 - islet)', 'Orthophosphate', 'H+', 'PXLP-PYGM', 'Mg2+', '6-O-phosphono-D-glucono-1,5-lactone', 'G6P', 'ADPGK:Mg2+', 'Glc', 'NADPH', 'phosphoglucomutases 1, 2', 'PGM2:Mg2+', 'D-Glucose 1-phosphate', 'adenylic acid', 'UDP', 'alpha-D-glucose 6-phosphate', 'oligoGlc-GYG1:phospho-GYS1 tetramer', 'G1P', 'Triphosphopyridine nucleotide', 'beta-Nicotinamide adenine dinucleotide phosphate', 'phospho-GYS1', 'Fru(6)P', 'UDP-D-glucose', 'ADPGK:Mg2+ phosphorylates Glc to G6P', 'alpha-D-Glucose + ATP => alpha-D-glucose 6-phosphate + ADP', 'PGM2', 'Phosphoglucomutase', 'D-Glucose alpha-1-phosphate', "uridine 5'-diphosphate", 'keto-D-fructose 6-phosphate', '6-Phospho-D-glucono-1,5-lactone', 'D-fructose 6-phosphate <=> alpha-D-Glucose 6-phosphate', 'PYGM', 'UDP-glucose', 'Cori ester', 'oligo((1,4)-alpha-glucosyl) glycogenin-1', 'Neuberg ester', 'p-S-GYS1', 'glycogen phosphorylase, muscle form', 'oligo((1,4)-alpha-glucosyl) GN-1', 'PGM1:Mg2+,PGM2:Mg2+ isomerise G6P to G1P', "adenosine 5'-monophosphate", 'poly((1,4)-alpha-glucosyl) glycogenin-1', 'UDP-Glc', 'G6PC hydrolyzes glucose 6-phosphate to form glucose and orthophosphate (liver)', 'proton', 'Mg++', 'water', 'Phosphorylated GYS1 catalyzes the polyglucosylation of oligoGlc-GYG1', 'polyGlc-GYG1:phospho-GYS1 tetramer', 'PGM1', 'Glucose 6-phosphate is isomerized to form fructose-6-phosphate', 'hydron']

#all edge property spaim values:
['p', 'a', 's']

In [2]:
 

    
gg = gt.Graph() 
gg.vp.score=gg.new_vertex_property("string")
gg.ep.weight=gg.new_edge_property("string")

v0=gg.add_vertex() 
v1=gg.add_vertex() 
 
e1=gg.add_edge(v0,v1) 
 
gg.vp["score"][v0]="1"
gg.vp["score"][v1]="2"
 
gg.ep["weight"][e1]="10"
print(p2g.properties.describe_properties(gg,"score"))

p2g.properties.change_property_type(gg,"score", "int", "node") 
#p2g.properties.change_property_type(gg,"score", "double", "node") 
#p2g.properties.change_property_type(gg,"score", "bool", "node") 
#p2g.properties.change_property_type(gg,"weight", "string", "edge") 
p2g.properties.change_property_type(gg,"weight", "float", "edge") 

print(p2g.properties.describe_properties(gg,"score"))

print(p2g.graph_explore.describe_graph(gg))
node, score, string 

node, score, int32_t 

  vertex 0 (score=1,)
      0 out_edge:(0, 1) (weight=10.0,)


  vertex 1 (score=2,)
     1 in_edge:(0, 1) (weight=10.0,)



  vertex 0 (score=1,)
      0 out_edge:(0, 1) (weight=10.0,)


  vertex 1 (score=2,)
     1 in_edge:(0, 1) (weight=10.0,)



In [ ]:
 
In [ ]: