JAL-1636 translate stop codon as '*', mouseover * as STOP
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 7 Sep 2015 14:34:58 +0000 (15:34 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 7 Sep 2015 14:34:58 +0000 (15:34 +0100)
src/jalview/analysis/AlignmentUtils.java
src/jalview/analysis/Dna.java
src/jalview/appletgui/SeqPanel.java
src/jalview/gui/SeqPanel.java
src/jalview/schemes/ResidueProperties.java
test/jalview/analysis/AlignmentUtilsTests.java
test/jalview/analysis/DnaTest.java

index f9d4c08..1e259c2 100644 (file)
@@ -461,10 +461,10 @@ public class AlignmentUtils
       final String translated = ResidueProperties.codonTranslate(
               codon);
       /*
-       * ? allow X in protein to match untranslatable in dna ?
+       * allow * in protein to match untranslatable in dna
        */
       final char aaRes = aaSeqChars[aaResidue];
-      if ((translated == null || "STOP".equals(translated)) && aaRes == 'X')
+      if ((translated == null || "STOP".equals(translated)) && aaRes == '*')
       {
         continue;
       }
index 1d5f996..5696838 100644 (file)
  */
 package jalview.analysis;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
 import jalview.api.AlignViewportI;
 import jalview.datamodel.AlignedCodon;
 import jalview.datamodel.AlignedCodonFrame;
@@ -47,9 +41,15 @@ import jalview.util.DBRefUtils;
 import jalview.util.MapList;
 import jalview.util.ShiftList;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
 public class Dna
 {
-  private static final String STOP_X = "X";
+  private static final String STOP_ASTERIX = "*";
 
   private static final Comparator<AlignedCodon> comparator = new CodonComparator();
 
@@ -544,7 +544,7 @@ public class Dna
           }
           if (aa.equals("STOP"))
           {
-            aa = STOP_X;
+            aa = STOP_ASTERIX;
           }
           resSize++;
         }
index 10db71a..4dd131a 100644 (file)
@@ -432,8 +432,9 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     }
     else
     {
-      residue = "X".equalsIgnoreCase(displayChar) ? "X"
-              : ResidueProperties.aa2Triplet.get(displayChar);
+      residue = "X".equalsIgnoreCase(displayChar) ? "X" : ("*"
+              .equals(displayChar) ? "STOP" : ResidueProperties.aa2Triplet
+              .get(displayChar));
       if (residue != null)
       {
         text.append(" Residue: ").append(residue);
index 44b537b..01653b6 100644 (file)
@@ -856,8 +856,9 @@ public class SeqPanel extends JPanel implements MouseListener,
     }
     else
     {
-      residue = "X".equalsIgnoreCase(displayChar) ? "X"
-              : ResidueProperties.aa2Triplet.get(displayChar);
+      residue = "X".equalsIgnoreCase(displayChar) ? "X" : ("*"
+              .equals(displayChar) ? "STOP" : ResidueProperties.aa2Triplet
+              .get(displayChar));
       if (residue != null)
       {
         text.append(" Residue: ").append(residue);
index 209fe12..ce83875 100755 (executable)
@@ -1509,7 +1509,7 @@ public class ResidueProperties
       return _codonTranslate(lccodon);
     }
     String cdn = codonHash2.get(lccodon.toUpperCase());
-    if (cdn != null && cdn.equals("*"))
+    if ("*".equals(cdn))
     {
       return "STOP";
     }
index 6fef829..9c8e28c 100644 (file)
@@ -579,27 +579,38 @@ public class AlignmentUtilsTests
   {
     assertTrue(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(), 0,
             "FPKG".toCharArray()));
-    // with start codon
+    // with start codon (not in protein)
     assertTrue(AlignmentUtils.translatesAs("atgtttcccaaaggg".toCharArray(),
             3, "FPKG".toCharArray()));
-    // with stop codon1
+    // with stop codon1 (not in protein)
     assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
             0, "FPKG".toCharArray()));
-    // with stop codon2
+    // with stop codon1 (in protein as *)
+    assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
+            0, "FPKG*".toCharArray()));
+    // with stop codon2 (not in protein)
     assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtag".toCharArray(),
             0, "FPKG".toCharArray()));
-    // with stop codon3
+    // with stop codon3 (not in protein)
     assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtga".toCharArray(),
             0, "FPKG".toCharArray()));
     // with start and stop codon1
     assertTrue(AlignmentUtils.translatesAs(
-            "atgtttcccaaaggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+            "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+    // with start and stop codon1 (in protein as *)
+    assertTrue(AlignmentUtils.translatesAs(
+            "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG*".toCharArray()));
     // with start and stop codon2
     assertTrue(AlignmentUtils.translatesAs(
-            "atgtttcccaaaggtag".toCharArray(), 3, "FPKG".toCharArray()));
+            "atgtttcccaaagggtag".toCharArray(), 3, "FPKG".toCharArray()));
     // with start and stop codon3
     assertTrue(AlignmentUtils.translatesAs(
-            "atgtttcccaaaggtga".toCharArray(), 3, "FPKG".toCharArray()));
+            "atgtttcccaaagggtga".toCharArray(), 3, "FPKG".toCharArray()));
+
+    // with embedded stop codon
+    assertTrue(AlignmentUtils.translatesAs(
+            "atgtttTAGcccaaaTAAgggtga".toCharArray(), 3,
+            "F*PK*G".toCharArray()));
 
     // wrong protein
     assertFalse(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(),
index 55908dd..765ec2b 100644 (file)
@@ -148,7 +148,7 @@ public class DnaTest
   }
 
   /**
-   * Test simple translation to Amino Acids (with STOP codons translated to X).
+   * Test simple translation to Amino Acids (with STOP codons translated to *).
    * 
    * @throws IOException
    */
@@ -164,7 +164,7 @@ public class DnaTest
     AlignmentI translated = dna.translateCdna();
     String aa = translated.getSequenceAt(0).getSequenceAsString();
     assertEquals(
-            "AAAACCDDEEFFGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVWYYXXX",
+            "AAAACCDDEEFFGGGGHHIIIKKLLLLLLMNNPPPPQQRRRRRRSSSSSSTTTTVVVVWYY***",
             aa);
   }