Merge: 497958b 68dcaa7
[jalview.git] / src / jalview / datamodel / AlignmentAnnotation.java
index 0731991..e137225 100755 (executable)
@@ -75,9 +75,10 @@ public class AlignmentAnnotation
   public SequenceFeature[] _rnasecstr = null;
 
   /**
-   * position of annotation resulting in invalid WUSS parsing or -1
+   * position of annotation resulting in invalid WUSS parsing or -1. -2 means
+   * there was no RNA structure in this annotation
    */
-  private long invalidrnastruc = -1;
+  private long invalidrnastruc = -2;
 
   /**
    * Updates the _rnasecstr field Determines the positions that base pair and
@@ -110,10 +111,47 @@ public class AlignmentAnnotation
       isrna = true;
       showAllColLabels = true;
       scaleColLabel = true;
+      _markRnaHelices();
     }
     // System.out.println("featuregroup " + _rnasecstr[0].getFeatureGroup());
+
   }
 
+  private void _markRnaHelices()
+  {
+    int mxval = 0;
+    // Figure out number of helices
+    // Length of rnasecstr is the number of pairs of positions that base pair
+    // with each other in the secondary structure
+    for (int x = 0; x < _rnasecstr.length; x++)
+    {
+
+      /*
+       * System.out.println(this.annotation._rnasecstr[x] + " Begin" +
+       * this.annotation._rnasecstr[x].getBegin());
+       */
+      // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
+      int val = 0;
+      try
+      {
+        val = Integer.valueOf(_rnasecstr[x].getFeatureGroup());
+        if (mxval < val)
+        {
+          mxval = val;
+        }
+      } catch (NumberFormatException q)
+      {
+      }
+      ;
+
+      annotations[_rnasecstr[x].getBegin()].value = val;
+      annotations[_rnasecstr[x].getEnd()].value = val;
+
+      // annotations[_rnasecstr[x].getBegin()].displayCharacter = "" + val;
+      // annotations[_rnasecstr[x].getEnd()].displayCharacter = "" + val;
+    }
+    setScore(mxval);
+  }
   /**
    * map of positions in the associated annotation
    */
@@ -455,11 +493,10 @@ public class AlignmentAnnotation
     @Override
     public char charAt(int index)
     {
-      String dc;
       return ((index + offset < 0) || (index + offset) >= max
-              || annotations[index + offset] == null || (dc = annotations[index
-              + offset].displayCharacter.trim()).length() < 1) ? '.' : dc
-              .charAt(0);
+              || annotations[index + offset] == null || (annotations[index
+ + offset].secondaryStructure < ' ') ? ' '
+              : annotations[index + offset].secondaryStructure);
     }
 
     public String toString()
@@ -469,9 +506,8 @@ public class AlignmentAnnotation
 
       for (int i = offset; i < mx; i++)
       {
-        String dc;
-        string[i] = (annotations[i] == null || (dc = annotations[i].displayCharacter
-                .trim()).length() < 1) ? '.' : dc.charAt(0);
+        string[i] = (annotations[i] == null || (annotations[i].secondaryStructure < 32)) ? ' '
+                : annotations[i].secondaryStructure;
       }
       return new String(string);
     }