This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Making All Protein Sequence Lengths Same

Is there any code in perl / python to make all protein sequences of same length, otherwise my phylogenetic tool MEGA is not working on them ?

perl bioperl biopython python

Have you aligned your sequences? You need to in order to do phylogeny and almost any aligner will pad out sequences to make them the same length.

I would guess that they should be globally-aligned and therefore of the same length. Check your alignment?

David W, I've heard that there are programs that construct alignment and phylogeny in the same time. But I think they are not implemented in MEGA

It happened to me several times to have alignments with sequences of different lengths. These can arise in several situations when you do more sophisticated things, e.g. manual edits, combining several alignments into one using some sequence alignment editors etc. The fact that most of the programs and programming libraries complain about unequal sequence lengths, instead of correcting that automatically, is for me one of the biggest annoyances in bioinformatics.

I liked the way Jan described "manual editing" as one of the more sophisticated things you can do;-)

1 answer

If you don't mind using interactive programs instead of Python/Perl, you can try with Jalview (cross-platform) or BioEdit (Windows)

Jalview: Menu edit-> Pad Gaps

BioEdit: Menu Alignment -> Flush the alignment

But of course, as others suggested in the comments, ensure first you have your sequences aligned, and different lengths arose for different reasons.

Log in to answer this question.