bpy21. Using elink EUtil in Biopython

We can use Bio.Entrez.elink to find related IDs from one database to another, or from same database. Thus elink requires we give name of database from where the IDs are located. We also need name of database where the new IDs are located. Finally we have to provide a string, or a list of strings, for the IDs.

In the example, the database from is ‘protein’. We have three IDs of tyrosine kinases from human, cow and mouse.

elink returns the IDs in the ‘gene’ database for these proteins.


# bpy21.py
from __future__ import print_function
from Bio import Entrez

Entrez.email = "[email protected]"
IDs = ['15718680','157427902','119703751']
handle = Entrez.elink(dbfrom = 'protein', db='gene', id = IDs)
values = Entrez.read(handle)
link_IDs = []
for value in values:
for linkset in value['LinkSetDb']:
for link in linkset['Link']:
ID = link['Id']
print('Link:', ID)
link_IDs.append(ID)
print("link_ids=n",link_IDs)

#Link: 3702
#Link: 522311
#Link: 16428
#link_ids=
# ['3702', '522311', '16428']

Leave a Reply

Your email address will not be published. Required fields are marked *