[BioPython] Translation method for Seq object

Peter biopython at maubp.freeserve.co.uk
Sun Oct 19 18:52:06 UTC 2008


On Sun, Oct 19, 2008 at 7:28 PM, Martin MOKREJŠ
<mmokrejs at ribosome.natur.cuni.cz> wrote:
> Peter,
>  you are right in your points. I think the translate() trick
> had some speed advantages over other approaches to
> zap unwanted characters ...

I haven't profiled this - you may be right.  On the other hand, using
the translate method in this way doesn't make the purpose of the code
obvious.

>- I don't remember but if it is gonna break in future
> python releases I will have to rewrite this anyway.

Certainly the deletechars argument seems to be gone in Python 3.0, but
you may not need to worry about that for a while.

> I just wanted to say I really do use the string translate
> function and that it has use in bioinformatics as well. ;-)

Using the string translate for (back)transcription is an obvious
example, but this is a special case that is already handled within
Biopython.

Does anyone have a non-transcription sequence example where the
mapping part of the translate method is actually used?

Using the string translate method just to remove characters is an
interesting one.  How common is this in typical python code?  I've
always used the string replace method (but usually I only want to
remove one character).  Maybe we should have a remove characters
method for the Seq object?  Here at least dealing with the alphabet is
fairly simple.  On another thread I'd suggested a "remove gaps" method
as a special case of this.

> Still, I think the name clash is asking for disaster, but
> overloading is a feature of python so it might be expected.
> Do whatever you want. ;)
> Cheers,
> M.

I'm still a tiny bit uneasy about the name clash myself... anyone else
what to join in the debate?

Peter




More information about the Biopython mailing list