I am using MEGA11 MEGA11: Molecular Evolutionary Genetics Analysis Version 11 , Mol. Biol. Evol. 38(7):3022–3027 to align protein coding sequences that I downloaded from KEGG database. I am doing MUSCLE alignment and I choose the "align codons" option. The problem that occurs has to do with the error "stop codons are found in the translated sequences" that pops as an warning during the process. When I check the sequences I cannot find any stop codons except the one at the end, as expect. I don't know how to interpret the message. Does anyone has any idea what is going wrong? Thank you in advance!

  • $\begingroup$ I think this is caused by the final stop codon. Have you tried removing the stop codon at the end? $\endgroup$
    – Niklas
    Commented Dec 6, 2023 at 21:36
  • 1
    $\begingroup$ genome.jp/kegg/pathway.html there is genes genome.jp/kegg/genes.html $\endgroup$
    – pippo1980
    Commented Dec 7, 2023 at 20:42
  • $\begingroup$ Thanks @pippo1980 I did notice this. Wasn't sure how the database could be cleanly interrogated easily however. $\endgroup$
    – M__
    Commented Dec 7, 2023 at 21:13
  • $\begingroup$ What is the format of your input file? Can you show us an example? $\endgroup$
    – terdon
    Commented Dec 8, 2023 at 11:19

1 Answer 1


The solution is very simply, MegaX will not allow any stop codons within the "translated" sequence. The reason is simple

  • MEGAX's function is phylogenetic models with nucleotide or protein data
  • All phylogenetic protein calculations require a 20x20 matrix of amino acid frequencies, e.g. BLOSUM, Dayhoff, mtREV24 etc ... No matrix has ever calculated stop codon frequency (well NCBI have and sort of obviously always '1' or transformed '1' [the definition of a gene is it has one stop codeon])

Thus MEGAX will not permit a single stop codon, even the terminal codon of the gene, because it can't calculate phylogenetic information from them (doesn't fit the model). Thus the "getter" to pick up bugs occurs right at that beginning.

Two solutions:

  1. Don't translate the nucleotide sequence on import - just stick with nucleotides (there are no codon models in MEGAX).
  2. Remove the terminal 3 resides
     perl -p -i -e 's/(^[AGCT-NRY]{3}.*)[AGCT-NRY]{3}$/$1/g' alignment.fa

Note the above code is not tested and intended only for fasta sequence or MEGA input format - don't use it on Clustal or Phylip it will be disastrous, i.e. interleaved format. IN ADDITION make sure there are no carriage returns within the contiguous sequence (again the result is disastrous). Finally, note I forget the {3} stuff (its ages since I wrote perl) and should include all the degenerate nucleotide code beyond NRY, e.g. MB etc ...

Really trimming the 3' last 3 nucleotides is a good use of Biopython - no risk of errors regardless of alignment. Trimal can probably do it BTW or seqkit.

I'm still interested in how you interrogated KEGG gene DB BTW

  • $\begingroup$ If you just want to remove the last three character from every line (but why are we assuming single-line sequences here, and shouldn't we skip the fast headers?), you can use perl -i -pe 's/...$/' file. Your command will remove the last three from every line, irrespective of whether they're actually the last three of the gene. $\endgroup$
    – terdon
    Commented Dec 8, 2023 at 11:09
  • $\begingroup$ If this is fasta then the header > or # would also have 3 characters removed. Using ^[AGCT-NRY]{3} ensures only the sequence is altered. However, many formats of MEGA and fasta using a flxed column width of say 80 characters per line. Personally, I'd use BioPython within their sequence object - which is brilliant. $\endgroup$
    – M__
    Commented Dec 8, 2023 at 11:15
  • 1
    $\begingroup$ I think that is it is possible to just leave it like the way it is and just choose the "ignore" option that pops. When I do that the programm goes on, however I don't know if there are any consequences for my alignment. By the way thank you everyone for your answers! I do not think that it is a big deal however I wasn't sure what caused the warning so I wanted your opinion about it. Thanks again! $\endgroup$
    – George X.
    Commented Dec 11, 2023 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.