[Biopython-dev] Re; Rethinking Seq objects

Michiel De Hoon mdehoon at c2b2.columbia.edu
Fri Jun 17 15:42:22 EDT 2005


Dear biopythoneers,

A couple of weeks ago there was a discussion on the Biopython mailing lists
about the Seq and MutableSeq classes in Bio.Seq. Whereas opinions were
divided on most of my proposals (which I therefore did not implement), most
people agreed that there was a need for a more user-friendly way to
transcribe and translate sequences.

So I added a transcribe, back_transcribe, and translate function to Bio.Seq.
I wrote these as functions rather than a method so that it can take both Seq
objects and Python string objects as input. These functions work
approximately the same as the corresponding methods in Bio.Transcribe and
Bio.Translate.

The example in the Biopython tutorial would look like this:

Using strings:

>>> my_seq = 'GCCATTGTAATGGGCCGCTGAAAGGGTGCCCGA'
>>> transcribe(my_seq)
'GCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGA'
>>> back_transcribe(_)
'GCCATTGTAATGGGCCGCTGAAAGGGTGCCCGA'
>>> translate(my_seq)
'AIVMGR*KGAR'
>>> translate(my_seq,table="Vertebrate Mitochondrial")
'AIVMGRWKGAR'
>>> translate(my_seq,table=1)
'AIVMGR*KGAR'
>>> translate(my_seq,table=2)
'AIVMGRWKGAR'

Using Seq objects:

>>> from Bio.Alphabet import IUPAC
>>> my_alpha = IUPAC.unambiguous_dna
>>> from Bio.Seq import *
>>> my_seq = Seq('GCCATTGTAATGGGCCGCTGAAAGGGTGCCCGA', IUPAC.unambiguous_dna)
>>> transcribe(my_seq)
Seq('GCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGA', IUPACUnambiguousRNA())
>>> back_transcribe(_)
Seq('GCCATTGTAATGGGCCGCTGAAAGGGTGCCCGA', IUPACUnambiguousDNA())
>>> translate(my_seq)
Seq('AIVMGR*KGAR', HasStopCodon(IUPACProtein(), '*'))
>>> translate(my_seq,table="Vertebrate Mitochondrial")
Seq('AIVMGRWKGAR', HasStopCodon(IUPACProtein(), '*'))
>>> translate(my_seq,table=1)
Seq('AIVMGR*KGAR', HasStopCodon(IUPACProtein(), '*'))
>>> translate(my_seq,table=2)
Seq('AIVMGRWKGAR', HasStopCodon(IUPACProtein(), '*'))
>>>

The original methods in Bio.Transcribe and Bio.Translate of course still work
(for Seq objects).


Thanks, everybody, for contributing to this discussion. I hope these
functions will prove to be useful.

--Michiel.


Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032




More information about the Biopython-dev mailing list