diff --git a/ippisite/ippidb/ws.py b/ippisite/ippidb/ws.py index 2cf9ecb8284f04e24e01958cde21fafc54f3dcf9..422a5219ab38cde7844249ba0962e58ca891e3f2 100644 --- a/ippisite/ippidb/ws.py +++ b/ippisite/ippidb/ws.py @@ -1,4 +1,6 @@ from bioservices.eutils import EUtils +from bioservices.uniprot import UniProt +from xml.etree.ElementTree import register_namespace import requests def get_pubmed_info(pmid): @@ -32,3 +34,12 @@ def get_epo_info(patent_number): 'journal_name': None, 'biblio_year': biblio_year, 'authors_list': authors} + +def get_uniprot_info(uniprot_id): + uniprot_client = Uniprot() + resp = uniprot_client.retrieve(uniprot_id) + recommended_name = res.root.findall('{http://uniprot.org/uniprot}entry/{http://uniprot.org/uniprot}protein/{http://uniprot.org/uniprot}recommendedName/{http://uniprot.org/uniprot}fullName')[0].text + organism = res.root.findall('{http://uniprot.org/uniprot}entry/{http://uniprot.org/uniprot}organism/{http://uniprot.org/uniprot}dbReference[@type="NCBI Taxonomy"]/@id') + return {'recommended_name': recommended_name, + 'organism': organism + }