[BioPython] problem accessing ncbi through GenBank.NCBIDictionary

Miguel Ortiz-Lombardía ibdeno at gmail.com
Tue Sep 4 14:55:27 UTC 2007


Eventually, I managed to download all of them (21 only...) But thank you
very much for the tip, I will incorporate that error check/try to the
script!

Cheers,


Miguel

2007/9/4, Peter <biopython at maubp.freeserve.co.uk>:
>
> Miguel Ortiz-Lombardía wrote:
> > Hello everyone.
> >
> > I'm trying to retrieve from NCBI a series of GeneBank records from a
> list
> > read from a file.
>
> How many GenBenk identifiers are we talking about? Just trying to get an
> idea of the scale of the problem.  It certainly sounds like either
> network failures or timeouts.  Have you try something like this?
>
> from Bio import GenBank
> from urllib2 import HTTPError
> ncbi_dict = GenBank.NCBIDictionary("protein", "genbank")
> ids = ['14598510', '16904191']
> output = open('saved.gb','w')
> for gbid in ids:
>      print "Fetching %s" % gbid
>      try :
>          gb_record = ncbi_dict[gbid]
>      except HTTPError, e :
>          #Check error code?
>          print str(e)
>          print "Re-trying %s" % gbid
>          gb_record = ncbi_dict[gbid]
>      output.write(gb_record)
> output.close()
> print "Done"
>
> Peter
>
>


-- 
correo-e: ibdeno at gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Je suis de la mauvaise herbe,
Braves gens, braves gens,
Je pousse en liberté
Dans les jardins mal fréquentés!

Georges Brassens




More information about the Biopython mailing list