[Biopython] SeqRecord substring should return SeqRecord or character?

Peter Cock p.j.a.cock at googlemail.com
Wed Jul 11 15:21:00 UTC 2012


On Wed, Jul 11, 2012 at 4:02 PM, Nick Loman <n.j.loman at bham.ac.uk> wrote:
> Hi there
>
> I wanted to add the last character of a SeqRecord s1 to another
> SeqRecord s2. However s1[-1] + s2 fails because s1[-1] returns a
> string rather than a SeqRecord just containing a single base and
> associated annotations. I have to do s1[-1:] to get a sliced
> SeqRecord.

You should be able to do SeqRecord+string, and string+SeqRecord,
both of which are specifically tested in the docstring. Have you got
any more details? e.g. Version? Mini-example?

> Is this behaviour intentional? I kind of assumed I would always get a
> SeqRecord from any given slice, and it's seems weird to get just a
> string back instead, although no doubt there's a good reason for this.

For a single base/residue, the whole SeqRecord overhead does
seem unnecessary. As to why you get a single letter string, not
a single letter Seq, IIRC it was mimicking the Seq object.

Peter



More information about the Biopython mailing list