Merge branch 'bug/JAL-2507_rnasecstrstockholm' into develop
[jalview.git] / src / jalview / io / StockholmFile.java
index e4d9f60..c2f3683 100644 (file)
@@ -33,6 +33,7 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.schemes.ResidueProperties;
+import jalview.util.Comparison;
 import jalview.util.Format;
 import jalview.util.MessageManager;
 
@@ -817,12 +818,16 @@ public class StockholmFile extends AlignFile
       type = (label.indexOf("_cons") == label.length() - 5) ? label
               .substring(0, label.length() - 5) : label;
     }
-    boolean ss = false;
+    boolean ss = false, posterior = false;
     type = id2type(type);
-    if (type.equals("secondary structure"))
+    if (type.equalsIgnoreCase("secondary structure"))
     {
       ss = true;
     }
+    if (type.equalsIgnoreCase("posterior probability"))
+    {
+      posterior = true;
+    }
     // decide on secondary structure or not.
     Annotation[] els = new Annotation[annots.length()];
     for (int i = 0; i < annots.length(); i++)
@@ -857,6 +862,25 @@ public class StockholmFile extends AlignFile
         }
 
       }
+      if (posterior && !ann.isWhitespace()
+              && !Comparison.isGap(pos.charAt(0)))
+      {
+        float val = 0;
+        // symbol encodes values - 0..*==0..10
+        if (pos.charAt(0) == '*')
+        {
+          val = 10;
+        }
+        else
+        {
+          val = pos.charAt(0) - '0';
+          if (val > 9)
+          {
+            val = 10;
+          }
+        }
+        ann.value = val;
+      }
 
       els[i] = ann;
     }
@@ -1139,10 +1163,10 @@ public class StockholmFile extends AlignFile
     if (typeIds == null)
     {
       typeIds = new Hashtable();
-      typeIds.put("SS", "secondary structure");
-      typeIds.put("SA", "surface accessibility");
+      typeIds.put("SS", "Secondary Structure");
+      typeIds.put("SA", "Surface Accessibility");
       typeIds.put("TM", "transmembrane");
-      typeIds.put("PP", "posterior probability");
+      typeIds.put("PP", "Posterior Probability");
       typeIds.put("LI", "ligand binding");
       typeIds.put("AS", "active site");
       typeIds.put("IN", "intron");
@@ -1153,7 +1177,7 @@ public class StockholmFile extends AlignFile
       typeIds.put("DE", "description");
       typeIds.put("DR", "reference");
       typeIds.put("LO", "look");
-      typeIds.put("RF", "reference positions");
+      typeIds.put("RF", "Reference Positions");
 
     }
   }
@@ -1176,7 +1200,7 @@ public class StockholmFile extends AlignFile
     while (e.hasMoreElements())
     {
       Object ll = e.nextElement();
-      if (typeIds.get(ll).toString().equals(type))
+      if (typeIds.get(ll).toString().equalsIgnoreCase(type))
       {
         key = (String) ll;
         break;