[BioPython] Making the Seq object act more like a string

Sebastian Bassi sbassi at gmail.com
Wed Aug 22 11:41:53 EDT 2007


On 8/22/07, Peter <biopython at maubp.freeserve.co.uk> wrote:
> A couple of times (on bugs or the developers mailing list), Michiel de
> Hoon has previously suggested we could make the Seq class (Bio.Seq.Seq)
> a subclass of python string. I agree with him - the Seq object should
> act more like a string.

I agree. Seq acting more like a str would also lower the entry level
to use biopython for non OOP seasoned programmers.

> As a simple example, although there are functions in Biopython to
...

Here is another example (from
http://www.biopython.org/wiki/SeqIO#Using_the_SEGUID_checksum):

Current situation:

from Bio import SeqIO
from Bio.SeqUtils.CheckSum import seguid
seguid_dict = SeqIO.to_dict(SeqIO.parse(open("ls_orchid.gbk"), "genbank"),
                            lambda rec : seguid(rec.seq))
record = seguid_dict["MN/s0q9zDoCVEEc+k/IFwCNF2pY"]
print record.id
print record.description

If seq were more like a string:

...
seguid_dict = SeqIO.to_dict(SeqIO.parse(open("ls_orchid.gbk"), "genbank"),
                            seguid(rec.seq))
....

This way you avoid using a lambda.


-- 
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318


More information about the BioPython mailing list