I have a list of around 200 plastid genomes which I want to download from genbank using biopython, and then put into one .gb file.
Here is the code I am using to do this:
out_handle = open(filename, "w")
for i in range(len(genbankIDs)):
net_handle = Entrez.efetch(
db="nucleotide", id=genbankIDs[i], rettype="gbwithparts", retmode="text"
)
out_handle.write(net_handle.read())
out_handle.close()
net_handle.close()
print("Saved")
where genbankIDs
is the list of accession numbers of the sequences I want to download from genbank.
However, this only works for the first 20 accessions. I get this error message:
Traceback (most recent call last):
File "fetchFromGenbank.py", line 25, in <module>
db="nucleotide", id=genbankIDs[i], rettype="gbwithparts", retmode="text"
File "/opt/anaconda2/lib/python2.7/site-packages/Bio/Entrez/__init__.py", line 195, in efetch
return _open(cgi, variables, post=post)
File "/opt/anaconda2/lib/python2.7/site-packages/Bio/Entrez/__init__.py", line 564, in _open
and exception.status // 100 == 4:
AttributeError: 'HTTPError' object has no attribute 'status'
How can I solve this? Is it an instance of NCBI timing out, or a problem based on me using python 2.7 and not a more recent version?
Wilber0x : Biostars built-in SPAM protection (we need to have this in place sorry) does not allow HTTP links in title (I think it was interpreting HTTPerror in your post title as a link). I have edited that out so hopefully you post will not be automatically flagged/deleted as SPAM now. I also reinstated your account so you should be able to respond.
Thank you for your help