Created
January 7, 2022 05:28
-
-
Save lucidrains/ebd2700c21160a9e75c3a412b20139ae to your computer and use it in GitHub Desktop.
uniprot mapping for python3
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
import urllib | |
import urllib.parse | |
from urllib.request import urlopen | |
def uniprot_mapping(fromtype, totype, identifier): | |
base = 'http://www.uniprot.org' | |
tool = 'mapping' | |
params = { | |
'from': fromtype, | |
'to': totype, | |
'format': 'tab', | |
'query': identifier, | |
} | |
data = urllib.parse.urlencode(params) | |
response = urlopen(f'{base}/{tool}?{data}') | |
return response.read() | |
print(uniprot_mapping('EMBL_ID', 'ID', 'X02469')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment