We can use Bio.Entrez.esearch to find IDs from a database. Besides the database, we have to give the search term. We may, additionally, give the maximum number of IDs to return, as a keyword argument.
20 IDs are returned since that is the default value for the maximum number of IDs returned, that is, RetMax is equal to 20. We can also see the total number of matches.
We may search any of the fields, however here we search in [All Fields].
# bpy16.py
from __future__ import print_function, division
from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
handle = Entrez.esearch("omim","cancer")
record = Entrez.read(handle)
handle.close()
print("There are a total of %s results." % record['Count'])
r = record['IdList']
NumIds = len(r)
print("%d Ids were returned. They are:" % NumIds)
for i in range(0,NumIds,4):
r_fmt = i+1,r[i],i+2,r[i+1],i+3,r[i+2],i+4,r[i+3]
print("%d: %s\t%d: %s\t%d: %s\t%d: %s" % r_fmt)
#There are a total of 2802 results.
#20 Ids were returned. They are:
#1: 616093 2: 616092 3: 616073 4: 616043
#5: 616041 6: 616016 7: 616015 8: 616000
#9: 615993 10: 615977 11: 615943 12: 615930
#13: 615920 14: 615909 15: 615908 16: 615874
#17: 615869 18: 615854 19: 615845 20: 615825
No comments:
Post a Comment