(JAL-1071) hacked the square matrix that stores the interacting pairs to allow 36...
[jalview.git] / src / jalview / analysis / StructureFrequency.java
index c15dba4..5f85916 100644 (file)
@@ -122,6 +122,9 @@ public class StructureFrequency
       }
       else
       {
+        bpEnd = findPair(rna, i);
+        if (bpEnd>-1)
+        {
         for (j = 0; j < jSize; j++) // foreach row
         {
           if (sequences[j] == null)
@@ -130,11 +133,8 @@ public class StructureFrequency
                     .println("WARNING: Consensus skipping null sequence - possible race condition.");
             continue;
           }
-          seq = sequences[j].getSequence();
-
-          if (seq.length > i)
+          c = sequences[j].getCharAt(i);
           {
-            c = seq[i];
 
             // standard representation for gaps in sequence and structure
             if (c == '.' || c == ' ')
@@ -147,8 +147,7 @@ public class StructureFrequency
               values['-']++;
               continue;
             }
-            bpEnd = findPair(rna, i);
-            cEnd = seq[bpEnd];
+            cEnd = sequences[j].getCharAt(bpEnd);
             if (checkBpType(c, cEnd))
             {
               values['(']++; // H means it's a helix (structured)
@@ -158,6 +157,7 @@ public class StructureFrequency
             maxResidue = "(";
           }
         }
+        }
         // nonGap++;
       }
       // UPDATE this for new values
@@ -406,7 +406,7 @@ public class StructureFrequency
   public static int[] extractProfile(Hashtable hconsensus,
           boolean ignoreGapsInConsensusCalculation)
   {
-    int[] rtnval = new int[51]; // 2*(5*5)+1
+    int[] rtnval = new int[74]; // 2*(5*5)+2
     int[][] profile = (int[][]) hconsensus.get(StructureFrequency.PROFILE);
     int[][] pairs = (int[][]) hconsensus
             .get(StructureFrequency.PAIRPROFILE);
@@ -430,15 +430,17 @@ public class StructureFrequency
     }
     jalview.util.QuickSort.sort(vl, ca);
 
-    rtnval[0] = 1;
+    rtnval[0] = 2;
+    rtnval[1] = 0;
     for (int c = 624; c > 0; c--)
     {
       if (vl[c] > 0)
       {
         rtnval[rtnval[0]++] = ((int[]) ca[c])[0];
         rtnval[rtnval[0]++] = ((int[]) ca[c])[1];
-        rtnval[rtnval[0]++] = (int) ((float) vl[c] * 100f / (float) profile[1][ignoreGapsInConsensusCalculation ? 1
+        rtnval[rtnval[0]] = (int) ((float) vl[c] * 100f / (float) profile[1][ignoreGapsInConsensusCalculation ? 1
                 : 0]);
+        rtnval[1]+=rtnval[rtnval[0]++];
       }
     }