Last active
December 17, 2015 23:49
-
-
Save ariutta/5692127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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