[BioPython] Translation method for Seq object
Peter
biopython at maubp.freeserve.co.uk
Sun Oct 19 14:15:59 EDT 2008
On Sun, Oct 19, 2008 at 4:52 PM, Martin MOKREJŠ
<mmokrejs at ribosome.natur.cuni.cz> wrote:
> Hi,
> I have been away for 2 weeks but although late,
Untill we release a new biopython, its not too late to change the Seq
object's new methods.
> let me oppose that string.translate() is of use.
> Here is my current code:
> ...
Your code seems to be doing two things with the python string
translate() method:
(1) Using the deletechars argument (with an empty mapping) to look for
unexpected letters. It took me a while to work out what your code was
doing - personally I would have used a python set for this, rather
than the string translate method. Note also unicode strings don't
support the deletechars argument, and that python 3.0 removes the
deletechars argument from the string style objects.
(2) Using the translate mapping to switch "U" and "u" into "T" and "t"
to back transcribe RNA into DNA. For this, Biopython already has a
Bio.Seq.back_transcribe function (which does work on strings), and in
CVS the Seq object gets a back_transcribe method too. These do both
use the string translate method internally.
Neither of these operations convice me that the Seq object should
support the python string translate method.
Note that if you still need to use the python string translate method,
it is accessable by first turning the Seq object into a string (e.g.
str(my_seq).translate(mapping, delete_chars)), or as Michiel suggested
earlier, you could use the string module translate function on the Seq
object.
Also note that (as in your example using the string translate to do
back transcription) the translate method by its nature makes it
impossible to know if the original Seq object alphabet still applies
to the result.
Peter
More information about the BioPython
mailing list