[Biopython-dev] Entrez ELink history - XML/DTD or Biopython bug?
Peter
biopython at maubp.freeserve.co.uk
Fri Sep 18 07:09:24 EDT 2009
Hi Michiel (et al),
I've been trying to get an example working using the Entrez history
for ELink. Strangely here the URL doesn't use history=y but instead
cmd=neighbor_history (while the default is cmd=neighbor).
However, this appears to show a bug in the Bio.Entrez parser. Consider:
from Bio import Entrez
pmid = "14630660"
print Entrez.elink(dbfrom="pubmed", db="pmc", LinkName="pubmed_pmc_refs",
from_uid=pmid, cmd="neighbor_history").read()
This gives:
<?xml version="1.0"?>
<!DOCTYPE eLinkResult PUBLIC "-//NLM//DTD eLinkResult, 11 May 2002//EN"
"http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eLink_020511.dtd">
<eLinkResult>
<LinkSet>
<DbFrom>pubmed</DbFrom>
<IdList>
<Id>14630660</Id>
</IdList>
<LinkSetDbHistory>
<DbTo>pmc</DbTo>
<LinkName>pubmed_pmc_refs</LinkName>
<QueryKey>1</QueryKey>
</LinkSetDbHistory>
<WebEnv>NCID_1_2657216_130.14.18.53_9001_1253271778</WebEnv>
</LinkSet>
</eLinkResult>
The XML looks reasonable by eye - although quite different from
the non-history version.
Now if instead of printing that, I try and parse it:
>>> data = Entrez.read(Entrez.elink(dbfrom="pubmed", db="pmc",
LinkName="pubmed_pmc_refs", from_uid=pmid, cmd="neighbor_history"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Bio/Entrez/__init__.py",
line 259, in read
record = handler.run(handle)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Bio/Entrez/Parser.py",
line 90, in run
self.parser.ParseFile(handle)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Bio/Entrez/Parser.py",
line 210, in endElement
current[name] = value
TypeError: 'str' object does not support item assignment
I can file a Biopython bug if you like, but my initial guess is
the problem lies in the XML itself versus the eLink_020511.dtd
file, which does not mention the LinkSetDbHistory element at
all. Do you agree that this looks like an NCBI problem?
Thanks,
Peter
More information about the Biopython-dev
mailing list