[Biopython] processing XML files in Biopython

Peter Cock p.j.a.cock at googlemail.com
Mon Jun 6 15:16:23 UTC 2011


On Mon, Jun 6, 2011 at 4:10 PM, Sheila the angel <from.d.putto at gmail.com> wrote:
> @David- Yes it works but few small question
> 1. how to extract the information not sored in directly in record[0].keys()
> for an example
> record[0]['GBSeq_feature-table']
> gives output which seems parsed in XML. From this how can I extract the
> 'GBQualifier_name' ?
>
> 2. just out of curiosity  'why we use record[0] to extract information e.g.
> record[0]['GBSeq_definition']  '

This is because the parser gave you a list, and we want the first element
(element zero), which was a dictionary, and we picked the key GBSeq_definition
This is what I meant by the Bio.Entrez parser turns the XML into Python
objects (lists and dicts containing strings/numbers). The structure comes
from the XML itself.

As I said, if you know beforehand exactly which XML element you want,
one of the Python standard libraries might be more direct.

Peter




More information about the Biopython mailing list