[BioPython] problem accessing ncbi through GenBank.NCBIDictionary

Miguel Ortiz-Lombardía ibdeno at gmail.com
Sun Sep 2 15:52:57 UTC 2007


Hello everyone.

I'm trying to retrieve from NCBI a series of GeneBank records from a list
read from a file.
This is the code:

8<-------------------------------------------------------------------------------------------

ncbi_dict = GenBank.NCBIDictionary("protein", "genbank")

output = open(args[0]+'.gb','w')

for gbid in ids:
    gb_record = ncbi_dict[gbid]
    output.write(gb_record)

output.close()

------------------------------------------------------------------------------------------->8

The problem is that at some point the job stops with an error such as:

Traceback (most recent call last):
  File "/Users/mol/bin/getfromGB.py", line 61, in ?
    main()
  File "/Users/mol/bin/getfromGB.py", line 54, in main
    gb_record = ncbi_dict[gbid]
  File "/sw/lib/python2.4/site-packages/Bio/GenBank/__init__.py", line 1264,
in __getitem__
    handle = self.db[id]
  File "/sw/lib/python2.4/site-packages/Bio/config/DBRegistry.py", line 89,
in __getitem__
    return self._get(key)
  File "/sw/lib/python2.4/site-packages/Bio/config/_support.py", line 107,
in __call__
    return self.fn(*args, **keywds)
  File "/sw/lib/python2.4/site-packages/Bio/config/DBRegistry.py", line 370,
in _get
    handle = eutils_client.efetch(retmode = "text", rettype =
  File "/sw/lib/python2.4/site-packages/Bio/EUtils/DBIdsClient.py", line
150, in efetch
    complexity = complexity)
  File "/sw/lib/python2.4/site-packages/Bio/EUtils/ThinClient.py", line 987,
in efetch_using_dbids
    query = {"id": id_string,
  File "/sw/lib/python2.4/site-packages/Bio/EUtils/ThinClient.py", line 644,
in _get
    return self.opener.open(url)
  File "/sw/lib/python2.4/urllib2.py", line 364, in open
    response = meth(req, response)
  File "/sw/lib/python2.4/urllib2.py", line 471, in http_response
    response = self.parent.error(
  File "/sw/lib/python2.4/urllib2.py", line 402, in error
    return self._call_chain(*args)
  File "/sw/lib/python2.4/urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "/sw/lib/python2.4/urllib2.py", line 480, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 503: Service Temporarily Unavailable

Sometimes is a 502 Error... Because I can access those entries from my
browser without problem, I'm guessing that there may be a timeout problem
here.

I would appreciate your help!

Cheers,

Miguel
-- 
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