[Biopython-dev] [Bug 1689] Seq is broken in CVS
Michiel Jan Laurens de Hoon
mdehoon at ims.u-tokyo.ac.jp
Thu Aug 26 09:15:06 EDT 2004
bugzilla-daemon at portal.open-bio.org wrote:
> http://bugzilla.open-bio.org/show_bug.cgi?id=1689
> in Seq.complement() and Seq.reverse_complement() replaced seq.alphabet by
> self.alphabet.
Oops. That was a typo. Thanks for catching that.
> Added a method __maketrans in Seq
>
> Added support for lower case DNA in Seq.complement() and
> Seq.reverse_complement. Same thing in MutableSeq.complement()
Looks good to me. I'll add that to CVS. Thanks.
>> I wonder if returning a Seq from a complement is a good idea as well
>> if your original sequence is a DNA(going 5'->3') the complement will not be a
>> DNA (it goes 3'->5').
The complement and reverse_complement were added to Seq.py because previously
several implementations of similar functions existed in different parts of
Biopython. The function forward_complement in Bio.GFF.easy takes a Seq object
and returns a Seq object. The function complement in Bio.SeqUtils takes a string
and returns a string. I have a slight preference for returning a Seq object for
consistency with MutableSeq, and also because a user might expect to receive an
object of the same type. Anybody else have an opinion on this?
>>> from Bio.Seq import *
>>> from Bio.GFF.easy import *
>>> s = Seq('ATCGCT')
>>> forward_complement(s)
Seq('TAGCGA', Alphabet())
>>>
>>> from Bio.SeqUtils import complement
>>> s = 'ATCGCT'
>>> complement(s)
'TAGCGA'
>>>
Thanks, Fred.
--Michiel.
--
Michiel de Hoon, Assistant Professor
University of Tokyo, Institute of Medical Science
Human Genome Center
4-6-1 Shirokane-dai, Minato-ku
Tokyo 108-8639
Japan
http://bonsai.ims.u-tokyo.ac.jp/~mdehoon
More information about the Biopython-dev
mailing list