[Biopython-dev] Bio.GenBank (was: Bio.File)

Peter Cock p.j.a.cock at googlemail.com
Mon Sep 12 09:29:19 EDT 2011


On Mon, Sep 12, 2011 at 1:49 PM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>
>>>> from Bio import GenBank
>>>> parser = GenBank.RecordParser()
>>>> handle = StringIO("no record here")
>>>> parser.parse(handle)
>>>> # no error raised
>
> This I think is not OK. GenBank.RecordParser().parse expects one
> record; it should raise an Exception if it does not one. Likewise, the
> parser does not raise an Exception if there are multiple records in
> the handle.
>
> and for Bio.GenBank.Iterator:
>
>>>> from Bio.GenBank import Iterator
>>>> from Bio.GenBank import RecordParser
>>>> from StringIO import StringIO
>>>> handle = StringIO("no record here")
>>>> parser = RecordParser()
>>>> records = Iterator(handle, parser)
>>>> for record in records: print record.locus
> ...
>>>>
>
> which is the same behavior as for Bio.SeqIO.parse, which I think is OK.

OK, yes - I see what you mean now.

> Assuming that the RecordParser and the Iterator are the only
> two classes that are intended for the end-user, it's probably
> better to add a Bio.GenBank.read and a Bio.GenBank.parse
> function to be consistent with the other Biopython modules.

Good plan - and then we can discourage direct use of the
rest of Bio.GenBank (i.e. RecordParser, Iterator etc).

How's this?
https://github.com/biopython/biopython/commit/ff72037efbae2da6eb6db550aa6d02b883ec1345

> Sorry for the confusion!
>

No problem.

Peter


More information about the Biopython-dev mailing list