Skip to content

Instantly share code, notes, and snippets.

@lucidrains
Created January 7, 2022 05:28
Show Gist options
  • Save lucidrains/ebd2700c21160a9e75c3a412b20139ae to your computer and use it in GitHub Desktop.
Save lucidrains/ebd2700c21160a9e75c3a412b20139ae to your computer and use it in GitHub Desktop.
uniprot mapping for python3
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