take the average of the three consecutive codon sites when translating annotation...
authorjprocter <Jim Procter>
Wed, 24 Jun 2009 08:22:47 +0000 (08:22 +0000)
committerjprocter <Jim Procter>
Wed, 24 Jun 2009 08:22:47 +0000 (08:22 +0000)
src/jalview/analysis/Dna.java

index ce13665..5ff6751 100644 (file)
@@ -364,14 +364,44 @@ public class Dna
   {\r
     // Have a look at all the codon positions for annotation and put the first\r
     // one found into the translated annotation pos.\r
+    int contrib=0;\r
+    Annotation annot = null;\r
     for (int p = 0; p < 3; p++)\r
     {\r
       if (annotations[is[p]] != null)\r
       {\r
-        return new Annotation(annotations[is[p]]);\r
+        if (annot==null) {\r
+          annot = new Annotation(annotations[is[p]]);\r
+          contrib = 1;\r
+        } else {\r
+          // merge with last\r
+          Annotation cpy = new Annotation(annotations[is[p]]);\r
+          if (annot.colour==null)\r
+          {\r
+            annot.colour = cpy.colour;\r
+          }\r
+          if (annot.description==null || annot.description.length()==0)\r
+          {\r
+            annot.description = cpy.description;\r
+          }\r
+          if (annot.displayCharacter==null)\r
+          {\r
+            annot.displayCharacter = cpy.displayCharacter;\r
+          }\r
+          if (annot.secondaryStructure==0)\r
+          {\r
+            annot.secondaryStructure = cpy.secondaryStructure;\r
+          }\r
+          annot.value+=cpy.value;\r
+          contrib++;\r
+        }\r
       }\r
     }\r
-    return null;\r
+    if (contrib>1)\r
+    {\r
+      annot.value/=(float)contrib;\r
+    }\r
+    return annot;\r
   }\r
 \r
   /**\r