[Biopython] Issue in retrieving Pubmed Ids
Lenna Peterson
arklenna at gmail.com
Fri Aug 9 19:42:13 UTC 2013
If your file has blank lines as shown, then the second iteration is calling
`data = Entrez.esearch(db="pubmed",term = "\n")`
When reading files I often have a check like this:
line = line.strip()
if not line:
continue
Hope that helps.
Cheers,
Lenna
On Fri, Aug 9, 2013 at 3:12 PM, sai nitin <sainitin7 at gmail.com> wrote:
> Hi all,
>
> I have set of genes ( ASCL1, AEBP1, MLF1) i want to search PUBMED for
> literature in glioma. Means i want to get Pubmed Ids for these genes in
> glioma. To achieve this i tried biopython script as follows. First i stored
> this terms in file as follows
>
> ASCL1 and glioma
>
> AEBP1 and glioma
>
> .....
>
> infile = "file.txt"
>
> for line in infile.readlines():
>
> single_id = line
>
> #Retreiving information
>
> data = Entrez.esearch(db="pubmed",term = single_id)
>
> res=Entrez.read(data)
>
> PMID = res["IdList"]
>
> print "%s" %(PMID)
>
> out_put.write("%s\n" %(PMID))
>
> out_put.close()
>
> It reads only first line ASCL1 and glioma ... and gives result as follows
>
> ['22859994', '18796682', '18636433', '17146289', '17124508', '16103883',
> '11433425']
>
> Traceback (most recent call last):
>
> File "PUBMED.py", line 13, in <module>
>
> res=Entrez.read(data)
>
> File "/Library/Python/2.7/site-packages/Bio/Entrez/__init__.py", line
> 367, in read
>
> record = handler.read(handle)
>
> File "/Library/Python/2.7/site-packages/Bio/Entrez/Parser.py", line 184,
> in read
>
> self.parser.ParseFile(handle)
>
> File "/Library/Python/2.7/site-packages/Bio/Entrez/Parser.py", line 322,
> in endElementHandler
>
> raise RuntimeError(value)
>
> RuntimeError: Empty term and query_key - nothing todo
>
>
> It looks like it does not read second line..in file.txt..Can any body tell
> how to solve this issue..
>
>
> Thanks,
>
> --
>
> Sainitin D
> _______________________________________________
> Biopython mailing list - Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>
More information about the Biopython
mailing list