Answers.Body: <p>The solution is very simply, MegaX will not allow any stop codons within the &quot;translated&quot; sequence. The reason is simple</p>
  <ul>
  <li>MEGAX's function is phylogenetic models with nucleotide or protein data</li>
  <li>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])</li>
  </ul>
  <p>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 &quot;getter&quot; to pick up bugs occurs right at that beginning.</p>
  <p>Two solutions:</p>
  <ol>
  <li>Don't translate the nucleotide sequence on import - just stick with nucleotides (there are no codon models in MEGAX).</li>
  <li>Remove the terminal 3 resides</li>
  </ol>
  <pre><code>     perl -p -i -e 's/(^[AGCT-NRY]{3}.*)[AGCT-NRY]{3}$/$1/g' alignment.fa
  </code></pre>
  <p>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 <code>{3}</code> stuff (its ages since I wrote perl) and should include all the degenerate nucleotide code beyond NRY, e.g. MB etc ...</p>
  <p>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.</p>
  <hr />
  <p>I'm still interested in how you interrogated KEGG gene DB BTW</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-08T11:09:51.367Z
Answers.Text: 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.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-08T11:15:17.507Z
Answers.Text: 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.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-11T21:51:12.480Z
Answers.Text: 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!
Answers.UserDisplayName: George X.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-07T20:18:16.740Z
Answers.LastActivityDate: 2023-12-08T03:47:59.143Z
Answers.LastEditDate: 2023-12-08T03:47:59.143Z
Answers.UserDisplayName: M__
Body: <p>I am using MEGA11 <a href="https://www.megasoftware.net/home" rel="nofollow noreferrer">MEGA11: Molecular Evolutionary Genetics Analysis Version 11</a>    ,   <a href="https://www.megasoftware.net/pdfs/TamuraStecherKumar21.pdf" rel="nofollow noreferrer">Mol. Biol. Evol. 38(7):3022–3027 </a>  to align protein coding sequences that I downloaded from KEGG database. I am doing MUSCLE alignment and I choose the &quot;align codons&quot; option. The problem that occurs has to do with the error &quot;stop codons are found in the translated sequences&quot; 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!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-06T21:36:03.807Z
Comments.Text: I think this is caused by the final stop codon. Have you tried removing the stop codon at the end?
Comments.UserDisplayName: Niklas
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-07T20:42:07.003Z
Comments.Text: https://www.genome.jp/kegg/pathway.html   there is genes https://www.genome.jp/kegg/genes.html
Comments.UserDisplayName: pippo1980
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-07T21:13:32.153Z
Comments.Text: Thanks @pippo1980 I did notice this. Wasn't sure how the database could be cleanly interrogated easily however.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-08T11:19:17.630Z
Comments.Text: What is the format of your input file? Can you show us an example?
Comments.UserDisplayName: terdon
Tags: <errors><kegg><codon><megax>
Title: MEGA11 gives the error "stop codons are found in the translated sequences", even though there are not!
ThreadText: # MEGA11 gives the error "stop codons are found in the translated sequences", even though there are not!
  
  (Asked by: username_0 on 2023-12-05)
  
  I am using MEGA11 [MEGA11: Molecular Evolutionary Genetics Analysis Version 11](https://www.megasoftware.net/home) , [Mol. Biol. Evol. 38(7):3022–3027](https://www.megasoftware.net/pdfs/TamuraStecherKumar21.pdf)  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!
  
  **Tags:** errors, kegg, codon, megax
  
  > **Comments:**
  > **username_1**: I think this is caused by the final stop codon. Have you tried removing the stop codon at the end?  
  > **username_2**: https://www.genome.jp/kegg/pathway.html   there is genes https://www.genome.jp/kegg/genes.html  
  > **username_3**: Thanks @username_2 I did notice this. Wasn't sure how the database could be cleanly interrogated easily however.  
  > **username_4**: What is the format of your input file? Can you show us an example?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2023-12-07. Score: 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
  
  > **Comments:**
  > **username_4**: 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.  
  > **username_3**: 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.  
  > **username_0**: 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!  
  
  ---
  
  