JAL-1483 cut and paste from SW score model to allow scores based on sequences to...
[jalview.git] / src / jalview / ws / jws2 / RNAalifoldClient.java
index b8b30c5..c7d8efd 100644 (file)
@@ -7,6 +7,7 @@ import jalview.gui.AlignFrame;
 import jalview.ws.jws2.dm.AAConSettings;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
+import jalview.ws.uimodel.AlignAnalysisUIText;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -62,7 +63,20 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements
   }
   private static String CALC_ID="jalview.ws.jws2.RNAalifoldClient";
 
+  public static AlignAnalysisUIText getAlignAnalysisUITest()
   {
+    return new AlignAnalysisUIText(
+            compbio.ws.client.Services.RNAalifoldWS.toString(),
+            jalview.ws.jws2.RNAalifoldClient.class,
+            CALC_ID,
+            true,
+            false,
+            true,
+            "RNAAliFold Prediction",
+            "When checked, RNA secondary structure predictions will be calculated for the alignment, and updated when edits are made.",
+            "Change RNAAliFold settings...",
+            "Modify settings for the RNAAliFold prediction. Use this to hide or show different results of the RNA calculation, and change RNA folding parameters");
+
   }
 
   @Override
@@ -184,7 +198,7 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements
   private AlignmentAnnotation constructAnnotationFromScoreHolder(
           AlignmentAnnotation annotation, String struct, TreeSet<Score> data)
   {
-    Annotation[] anns = new Annotation[struct.length()];
+    Annotation[] anns = new Annotation[gapMap!= null ? gapMap.length+1 : struct.length()];
 
     if (data != null
             && data.size() > 1
@@ -202,9 +216,17 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements
         basePairs.put(score.getRanges().first(), new Float(score
                 .getScores().get(0)));
       }
-      for (int i = 0; i < struct.length(); i++)
+      
+      for (int i = 0,ri=0,iEnd=struct.length();i<iEnd; i++,ri++)
       {
-
+        if (gapMap!=null)
+        {
+          // skip any gapped columns in the input data
+          while (!gapMap[ri])
+          {
+            ri++;
+          }
+        }
         // Return all the contacts associated with position i
         LinkedHashMap<Range, Float> contacts = isContact(basePairs, i + 1);
 
@@ -228,16 +250,27 @@ public class RNAalifoldClient extends JabawsAlignCalcWorker implements
           }
         }
 
-        anns[i] = new Annotation(struct.substring(i, i + 1), description,
+        anns[ri] = new Annotation(struct.substring(i, i + 1), description,
                 isSS(struct.charAt(i)), prob);
       }
     }
     else if (data == null || data.size() == 1)
     {
-      for (int i = 0; i < struct.length(); i++)
+      for (int i = 0,ri=0,iEnd=struct.length();i<iEnd; i++,ri++)
       {
-
-        anns[i] = new Annotation(struct.substring(i, i + 1), "",
+        if (gapMap!=null)
+        {
+          // skip any gapped columns in the input data
+          while (!gapMap[ri] && ri<gapMap.length)
+          {
+            ri++;
+          }
+          if (ri==gapMap.length)
+          {
+            break;
+          }
+        }
+        anns[ri] = new Annotation(struct.substring(i, i + 1), "",
                 isSS(struct.charAt(i)), Float.NaN);
       }