JAL-2897 more informative description on synonymous variants
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 5 Feb 2018 09:32:12 +0000 (09:32 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 5 Feb 2018 10:20:39 +0000 (10:20 +0000)
src/jalview/analysis/AlignmentUtils.java
test/jalview/analysis/AlignmentUtilsTests.java

index aa1a98b..5e11446 100644 (file)
@@ -2430,11 +2430,14 @@ public class AlignmentUtils
         {
           for (String base : alleles.split(","))
           {
-            if (!base1.equals(base))
+            if (!base1.equalsIgnoreCase(base))
             {
-              String codon = base + base2 + base3;
+              String codon = base.toUpperCase() + base2.toLowerCase()
+                      + base3.toLowerCase();
+              String canonical = base1.toUpperCase() + base2.toLowerCase()
+                      + base3.toLowerCase();
               if (addPeptideVariant(peptide, peptidePos, residue, var,
-                      codon))
+                      codon, canonical))
               {
                 count++;
               }
@@ -2456,11 +2459,14 @@ public class AlignmentUtils
         {
           for (String base : alleles.split(","))
           {
-            if (!base2.equals(base))
+            if (!base2.equalsIgnoreCase(base))
             {
-              String codon = base1 + base + base3;
+              String codon = base1.toLowerCase() + base.toUpperCase()
+                      + base3.toLowerCase();
+              String canonical = base1.toLowerCase() + base2.toUpperCase()
+                      + base3.toLowerCase();
               if (addPeptideVariant(peptide, peptidePos, residue, var,
-                      codon))
+                      codon, canonical))
               {
                 count++;
               }
@@ -2482,11 +2488,14 @@ public class AlignmentUtils
         {
           for (String base : alleles.split(","))
           {
-            if (!base3.equals(base))
+            if (!base3.equalsIgnoreCase(base))
             {
-              String codon = base1 + base2 + base;
+              String codon = base1.toLowerCase() + base2.toLowerCase()
+                      + base.toUpperCase();
+              String canonical = base1.toLowerCase() + base2.toLowerCase()
+                      + base3.toUpperCase();
               if (addPeptideVariant(peptide, peptidePos, residue, var,
-                      codon))
+                      codon, canonical))
               {
                 count++;
               }
@@ -2509,10 +2518,13 @@ public class AlignmentUtils
    * @param residue
    * @param var
    * @param codon
+   *          the variant codon e.g. aCg
+   * @param canonical
+   *          the 'normal' codon e.g. aTg
    * @return true if a feature was added, else false
    */
   static boolean addPeptideVariant(SequenceI peptide, int peptidePos,
-          String residue, DnaVariant var, String codon)
+          String residue, DnaVariant var, String codon, String canonical)
   {
     /*
      * get peptide translation of codon e.g. GAT -> D
@@ -2527,7 +2539,7 @@ public class AlignmentUtils
     {
       return false;
     }
-    String desc = codon;
+    String desc = canonical + "/" + codon;
     String featureType = "";
     if (trans.equals(residue))
     {
index 2b45eee..0559e6b 100644 (file)
@@ -2193,13 +2193,13 @@ public class AlignmentUtilsTests
     assertEquals(1, sf.getBegin());
     assertEquals(1, sf.getEnd());
     assertEquals("stop_gained", sf.getType());
-    assertEquals("TAA", sf.getDescription());
+    assertEquals("Aaa/Taa", sf.getDescription());
     assertEquals("var3", sf.getValue("ID"));
     assertEquals("Bad", sf.getValue("clinical_significance"));
     assertEquals("ID=var3;clinical_significance=Bad", sf.getAttributes());
     assertEquals(1, sf.links.size());
     assertEquals(
-            "TAA var3|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var3",
+            "Aaa/Taa var3|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var3",
             sf.links.get(0));
     assertEquals(dbSnp, sf.getFeatureGroup());
 
@@ -2208,13 +2208,13 @@ public class AlignmentUtilsTests
     assertEquals(1, sf.getBegin());
     assertEquals(1, sf.getEnd());
     assertEquals("synonymous_variant", sf.getType());
-    assertEquals("AAG", sf.getDescription());
+    assertEquals("aaA/aaG", sf.getDescription());
     assertEquals("var4", sf.getValue("ID"));
     assertEquals("None", sf.getValue("clinical_significance"));
     assertEquals("ID=var4;clinical_significance=None", sf.getAttributes());
     assertEquals(1, sf.links.size());
     assertEquals(
-            "AAG var4|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var4",
+            "aaA/aaG var4|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var4",
             sf.links.get(0));
     assertEquals(cosmic, sf.getFeatureGroup());
 
@@ -2238,13 +2238,13 @@ public class AlignmentUtilsTests
     assertEquals(2, sf.getBegin());
     assertEquals(2, sf.getEnd());
     assertEquals("synonymous_variant", sf.getType());
-    assertEquals("TTC", sf.getDescription());
+    assertEquals("ttT/ttC", sf.getDescription());
     assertEquals("var6", sf.getValue("ID"));
     assertNull(sf.getValue("clinical_significance"));
     assertEquals("ID=var6", sf.getAttributes());
     assertEquals(1, sf.links.size());
     assertEquals(
-            "TTC var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
+            "ttT/ttC var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
             sf.links.get(0));
     assertEquals(dbSnp, sf.getFeatureGroup());