fixed jalview 2.3 bug where gapped aligned codons were always translated as inserted...
[jalview.git] / src / jalview / analysis / Dna.java
index 836c39e..48d03b3 100644 (file)
@@ -116,6 +116,7 @@ public class Dna {
                 newSeq[sq].insertCharAt(aspos, gapCharacter);\r
               }\r
               System.arraycopy(codons, aspos, codons, aspos+1, aslen-aspos);\r
+              codons[aspos]=null; // clear so new codon position can be marked.\r
               findpos=false;\r
               break;\r
             case +1:\r
@@ -197,28 +198,36 @@ public class Dna {
         if (annotations[i].autoCalculated) {\r
           continue;\r
         }\r
-\r
-        aSize = aslen; // aa alignment width.\r
-        jalview.datamodel.Annotation[] anots =\r
-          new jalview.datamodel.Annotation[aSize];\r
         \r
-        for (a = 0; a < aSize; a++)\r
+        aSize = aslen; // aa alignment width.\r
+        jalview.datamodel.Annotation[] anots = \r
+          (annotations[i].annotations==null) \r
+          ? null :\r
+            new jalview.datamodel.Annotation[aSize];\r
+        if (anots!=null)\r
         {\r
-          // process through codon map.\r
-          if (codons[a]!=null && codons[a][0]==(codons[a][2]-2))\r
+          for (a = 0; a < aSize; a++)\r
           {\r
-            pos = codons[a][0];\r
-            if (annotations[i].annotations[pos] == null\r
-                || annotations[i].annotations[pos] == null)\r
-              continue;\r
+            // process through codon map.\r
+            if (codons[a]!=null && codons[a][0]==(codons[a][2]-2))\r
+            {\r
+              pos = codons[a][0];\r
+              if (annotations[i].annotations[pos] == null\r
+                      || annotations[i].annotations[pos] == null)\r
+                continue;\r
             \r
-            anots[a] = new Annotation(annotations[i].annotations[pos]);\r
+              anots[a] = new Annotation(annotations[i].annotations[pos]);\r
+            }\r
           }\r
         }\r
 \r
         jalview.datamodel.AlignmentAnnotation aa\r
         = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,\r
             annotations[i].description, anots);\r
+        if (annotations[i].hasScore)\r
+        {\r
+          aa.setScore(annotations[i].getScore());\r
+        }\r
         al.addAnnotation(aa);\r
       }\r
     }\r