[Biopython] Translation of partial codons

Peter Cock p.j.a.cock at googlemail.com
Thu Mar 21 17:19:45 UTC 2013


On Thu, Mar 21, 2013 at 5:10 PM, Iddo Friedberg <idoerg at gmail.com> wrote:
> Suggstions so far:
> 1. Raise an exception. This may cause  code running on existing data to
> change behavior. I.e. it ran before well on bad length sequences, but as of
> the new code installtion, things will break.

Yes, but in most cases this will be a good thing. The minority of people
knowingly dealing with partial sequences can make this explicit by first
ensuring their sequence is a multiple of three in length (by padding or
cropping as most appropriate to their use case).

> 2. Add a default length_check=True to the translate method. Again, this may
> cause exiting code to behave differently wiht the same data once user
> upgrades. Unless the user explicitly changes the call to
> myseq.translate(length_check=False)

A sensible approach to making likely errors explicit, with an easy work-around
for the old implicit truncation. The downside is yet another argument to the
translate functions/methods, which are already pretty complicated. I prefer (1).

> 3. My suggestion: use length_check=False as default. Code behaves the same
> as before, so no data-induced breakages. If the user wants to check length,
> the explicitly pass a True value. So we give the option of checking length,
> and retaining code-behavior legacy.
>
> length_check, being an argument, does not need to be passed explicitly.

I don't like this, even though it is backwards compatible for the corner
case. I think the old behaviour is a bug.

Regards,

Peter



More information about the Biopython mailing list