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

Peter biopython at maubp.freeserve.co.uk
Mon Aug 27 18:48:55 UTC 2007


Michiel De Hoon wrote:
> Peter wrote:
>> However, if SeqRecord acted more like a Seq (and therefore more like a 
>> string) then you could do this which does avoid the lambda:
>>
>> seguid_dict = SeqIO.to_dict(SeqIO.parse(open("ls_orchid.gbk"), \
>>                              "genbank"), seguid)
>>
>> Or, we could enhance your the CheckSum functions to cope with a 
>> SeqRecord, a Seq or a string - right now they cope with a Seq or a string.
>>
> Nice example.
> 
> The SeqRecord class is one of those classes in Biopython for which I never
> understood why they exist. A SeqRecord is nothing more than a Seq with some
> attributes attached. If we add those attributes to the Seq class directly,
> then we can get rid of the SeqRecord class. Then, functions such as those in
> CheckSum only need to cope with strings.
> 
> --Micheil.

I think having SeqRecord subclass Seq is nicer than simply adding 
annotation to the Seq class. Seq objects would (still) just have a 
sequence and alphabet, the SeqRecord becomes a rich/annotated Seq object.

I think this would be close to BioPerl's Seq and RichSeq objects.

I have filed an enhancement on Bugzilla to hold any suggested patches 
etc (I hope to upload something later tonight):

Bug 2351 - Make SeqRecord subclass Seq subclass string?
http://bugzilla.open-bio.org/show_bug.cgi?id=2351

Peter




More information about the Biopython mailing list