[Biopython] Blank Returns from Entrez.efetch()

Brad Chapman chapmanb at 50mail.com
Sun Jan 10 13:01:32 UTC 2010


Brett;

Brett: 
> > But when I change that to proteins and my IDs, I get an empty handle
> > as a result:
> > 
> > >>> handle = Entrez.efetch(db="protein", id="Q81T62.1", rettype="gb")

Michiel:
> Have you looked at the EUtils examples on the NCBI website? It shows
> one example for efetch from the protein database.

According to the efetch help here:

http://eutils.ncbi.nlm.nih.gov/corehtml/query/static/efetchseq_help.html

the id parameter should work okay with an accession.version. So
your example should work but something is wrong with how NCBI
handles this particular record. Other accession.version identifiers 
do work, and so does the accession alone:

>>> handle = Entrez.efetch(db="protein", id="Q81T62", rettype="gb")

The safest way to do this is to use GenBank identifiers (GIDs) as
the id attribute. This requires one extra step to search for the
record and get the ID:

>>> handle = Entrez.esearch(db="protein", retmax=1, term="Q81T62.1")
>>> rec = Entrez.read(handle)
>>> rec
{u'Count': '1',
 u'IdList': ['46395771'],
 u'QueryTranslation': 'Q81T62.1',
 u'RetMax': '1',
 u'RetStart': '0',
 u'TranslationSet': []}
>>> handle = Entrez.efetch(db="protein", id=rec[0]['IdList'][0], rettype="gb")
>>> handle.readline()
'LOCUS       Q81T62                   429 aa linear   BCT 15-DEC-2009\n'

Brad



More information about the Biopython mailing list