JAL-2214 JAL-1841 compute canonical, canonicalAndWobble visually distinguish dominant...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 21 Sep 2016 15:43:32 +0000 (16:43 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 21 Sep 2016 15:43:32 +0000 (16:43 +0100)
src/jalview/analysis/StructureFrequency.java

index 29bdb7a..ad3f8d9 100644 (file)
@@ -112,7 +112,7 @@ public class StructureFrequency
 
     for (int i = start; i < end; i++) // foreach column
     {
-      int canonicalOrWobblePairCount = 0;
+      int canonicalOrWobblePairCount = 0, canonical = 0;
       int otherPairCount = 0;
       int nongap = 0;
       maxResidue = "-";
@@ -176,14 +176,14 @@ public class StructureFrequency
             }
             if (Rna.isCanonicalOrWobblePair(c, cEnd))
             {
-              values['(']++;
-              maxResidue = "(";
               canonicalOrWobblePairCount++;
+              if (Rna.isCanonicalPair(c, cEnd))
+              {
+                canonical++;
+              }
             }
             else
             {
-              values['[']++;
-              maxResidue = "[";
               otherPairCount++;
             }
             pairs[c][cEnd]++;
@@ -200,7 +200,9 @@ public class StructureFrequency
 
         residueHash.put(PAIRPROFILE, pairs);
       }
-
+      values['('] = canonicalOrWobblePairCount;
+      values['['] = canonical;
+      values['{'] = otherPairCount;
       /*
        * the count is the number of valid pairs (as a percentage, determines
        * the relative size of the profile logo)
@@ -208,13 +210,20 @@ public class StructureFrequency
       int count = canonicalOrWobblePairCount;
 
       /*
-       * currently displaying as '(' if most pairs are valid, or as
-       * '[' if there are more invalid than valid pairs 
+       * display '(' if most pairs are canonical, or as
+       * '[' if there are more wobble pairs. 
        */
-      if (!maxResidue.equals("-"))
+      if (canonicalOrWobblePairCount > 0 || otherPairCount > 0)
       {
-        maxResidue = canonicalOrWobblePairCount >= otherPairCount ? "("
+        if (canonicalOrWobblePairCount >= otherPairCount)
+        {
+          maxResidue = (canonicalOrWobblePairCount - canonical) < canonical ? "("
                 : "[";
+        }
+        else
+        {
+          maxResidue = "{";
+        }
       }
       residueHash.put(MAXCOUNT, new Integer(count));
       residueHash.put(MAXRESIDUE, maxResidue);
@@ -233,9 +242,12 @@ public class StructureFrequency
       {
         values[')'] = values['('];
         values[']'] = values['['];
+        values['}'] = values['{'];
         values['('] = 0;
         values['['] = 0;
-        maxResidue = maxResidue.equals("(") ? ")" : "]";
+        values['{'] = 0;
+        maxResidue = maxResidue.equals("(") ? ")"
+                : maxResidue.equals("[") ? "]" : "}";
 
         residueHash = new Hashtable();
         if (profile)