[Biopython] Iterate Entrez.esearch in Biopython

Jarrod Scott jjscott at uwalumni.com
Tue Dec 8 03:04:15 UTC 2015


Greetings all.

I have 1) a list of species and 2) a list of genes. I am trying to
use Entrez.esearch within Biopython to get a list of accession numbers from
NCBI for each gene from each species. I wrote a small code that can do it
for one gene and one species but have been unsuccessful at creating a code
to iterate through the lists. Here is an example of the code that works.
This returns '11' hits which matches a simple GenBank search. Any help on
how to iterate through two list would be most appreciated.

Jarrod

import sys
import time
from Bio import Entrez
Entrez.email = "jjscott at uwalumni.com"
gene = 'tufA'
species = 'Codium decorticatum'
terms = "{0}[orgn] AND {1}[Gene]".format(species, gene)
handle = Entrez.esearch(db = "nucleotide", term = terms)
record = Entrez.read(handle)
record["Count"]
record["IdList"]



Example files:

Species:

E. coli
H. Sapien
M. tardes

Genes:
yyy
zzz
aaa


biopython-1.66 <http://biopython.org/DIST/biopython-1.66.tar.gz>
Python 2.7.9 :: Anaconda 2.2.0 (x86_64)
OS X Yosemite 10.10.2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20151207/00313484/attachment.html>


More information about the Biopython mailing list