Skip to content

Instantly share code, notes, and snippets.

@ariutta
Last active December 17, 2015 23:49
Show Gist options
  • Save ariutta/5692127 to your computer and use it in GitHub Desktop.
Save ariutta/5692127 to your computer and use it in GitHub Desktop.
from lxml import etree
import StringIO
tree = etree.parse("http://www.wikipathways.org/wpi/webservice/webservice.php/getPathway?pwId=WP1266")
apiResponse = tree.xpath('/ns1:getPathwayResponse/ns1:pathway/ns2:gpml', namespaces={'ns1': 'http://www.wso2.org/php/xsd','ns2': 'http://www.wikipathways.org/webservice'})
pathwayXml = StringIO.StringIO(apiResponse[0].text)
pathwayTree = etree.parse(pathwayXml)
species = pathwayTree.xpath('/foo:Pathway/@Organism', namespaces={'foo': 'http://genmapp.org/GPML/2008a'})
ids = pathwayTree.xpath('/foo:Pathway/foo:DataNode[@Type="Protein" or @Type="GeneProduct"]/foo:Xref/@ID[normalize-space() and not(ancestor::a | ancestor::script | ancestor::style)]', namespaces={'foo': 'http://genmapp.org/GPML/2008a'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment