A mini introduction to Biopax Explorer¶
In [1]:
###################################################
from biopax_explorer.pattern.pattern import PatternExecutor, Pattern
from biopax_explorer.query import EntityNode
from biopax_explorer.biopax import *
import json
##################################################
In [2]:
p=Pattern()
prot = EntityNode("PR", Protein())
prot.whereAttribute("name", "glucokinase","CONTAINS")
entityReference=EntityNode("EN", EntityReference())
prot.connectedWith(entityReference, "entityReference")
p.define(prot,entityReference)
pe=PatternExecutor()
pe.datasetFile("data/input/export_all_g6p.xml")
result = pe.fetchEntities(p)
print("#automatic result mapping")
for entity_row in result[:1]:#only first result row
for entity in entity_row:
if isinstance(entity,Protein):
print("first match of ",entity.meta_label," : ",entity.get_displayName(),",",entity.get_name())
print( entity.to_json() )
#automatic result mapping first match of PR : ADPGK , ADP-dependent glucokinase { "uri": "http://www.reactome.org/biopax/56/71387#Protein186", "dataSource": { "__uri__": "http://www.reactome.org/biopax/56/71387#Provenance1", "comment": null, "xref": null, "displayName": null, "name": null, "standardName": null }, "evidence": null, "xref": { "__class__": "Xref", "uri": "http://www.reactome.org/biopax/56/71387#UnificationXref_reactome_R-HSA-5696062" }, "availability": null, "comment": "http://www.reactome.org/biopax/56/71387#Protein186http://www.reactome.org/biopax/56/71387#Complex122@Layout@http://www.reactome.org/biopax/56/71387#Pathway6@20@1399", "displayName": "ADPGK", "name": "ADP-dependent glucokinase", "standardName": null, "cellularLocation": { "__class__": "CellularLocationVocabulary", "uri": "http://localhost:3030/g6p/CellularLocationVocabulary_b761180db8a874567188c589b45cab17" }, "feature": { "__class__": "EntityFeature", "uri": "http://www.reactome.org/biopax/56/71387#FragmentFeature174" }, "memberPhysicalEntity": null, "notFeature": null, "entityReference": { "__class__": "EntityReference", "uri": "http://identifiers.org/uniprot/Q9BRR6" }, "__class__": "Protein" }
In [3]:
querylist=PatternExecutor().queries(p)
print("#sparql code generation")
for q in querylist:
print("#---generated sparql query---\n\n")
print(q)
#sparql code generation #---generated sparql query--- prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix bi: <http://www.biopax.org/release/biopax-level3.owl#> select ?s2 ?o2 ?entityReferencen0EN ?s2__rdft ?o2__rdft where { ?s2 ?entityReferencen0EN ?o2 . ?s2 rdf:type ?s2__rdft . ?o2 rdf:type ?o2__rdft . { ?o2 a bi:EntityReference } UNION { ?o2 a bi:RnaReference } UNION { ?o2 a bi:RnaRegionReference } UNION { ?o2 a bi:DnaReference } UNION { ?o2 a bi:ProteinReference } UNION { ?o2 a bi:SmallMoleculeReference } UNION { ?o2 a bi:DnaRegionReference } . { ?s2 bi:name ?name }. { ?s2 a bi:Protein } FILTER ( ?entityReferencen0EN = bi:entityReference ) . FILTER ( CONTAINS(?name,'glucokinase') ) . }
In [ ]: