python - Entrez and SeqIO "no records found in handle" -


my code looks this:

import re bio import seqio bio import entrez  entrez.email = "...@..." # e-mail address  handle1 = entrez.efetch(db="pubmed", id=pmid_list_2010, rettype="gb", retmode="text") data1 = handle1.read() handle1.close() handle2 = entrez.efetch(db="pubmed", id=pmid_list_2011, rettype="gb", retmode="text") data2 = handle2.read() handle2.close() handle3 = entrez.efetch(db="pubmed", id=pmid_list_2012, rettype="gb", retmode="text") data3 = handle3.read() handle3.close() handle4 = entrez.efetch(db="pubmed", id=pmid_list_2013, rettype="gb", retmode="text") data4 = handle4.read() handle4.close() handle5 = entrez.efetch(db="pubmed", id=pmid_list_2014, rettype="gb", retmode="text") data5 = handle5.read() handle5.close() handle6 = entrez.efetch(db="pubmed", id=pmid_list_2015, rettype="gb", retmode="text") data6 = handle6.read() handle6.close()  out_handle = open("test2.gb", "w") out_handle.write(data1) out_handle.write(data2) out_handle.write(data3) out_handle.write(data4) out_handle.write(data5) out_handle.write(data6) out_handle.close()  in_handle = open("test2.gb", "r") record = seqio.read(in_handle,"genbank") in_handle.close() 

the second last line giving me error:

valueerror: no records found in handle 

my file looks fine - it's not empty or anything. there plenty of records and, far can tell, it's in correct format. doing wrong?

i have noticed works other databases - "nuceleotide" example. issue pubmed? require different format? thanks.

you trying parse wrong format. when query "pubmed" database, receive rettypes medline, uilist or abstract. yet ask genbank rettype, makes no sense in context.

instead use medline parser:

from bio import medline  h1 = entrez.efetch(db="pubmed",                    id=["26837606"],                    rettype="medline",                    retmode="text")  record in medline.parse(h1):     print(record["ti"]) 

outputs

exploiting crispr/cas9 system targeted genome mutagenesis in petunia. 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -