Merge branch 'feature/JAL-2664' into feature/JAL-2527
[jalview.git] / src / jalview / ws / jws2 / RNAalifoldClient.java
index 55ade66..80c9ce9 100644 (file)
  */
 package jalview.ws.jws2;
 
-import jalview.api.AlignCalcWorkerI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.gui.AlignFrame;
-import jalview.ws.jws2.dm.AAConSettings;
+import jalview.util.MessageManager;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
 import jalview.ws.uimodel.AlignAnalysisUIText;
@@ -36,8 +35,8 @@ import java.util.List;
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 
-import compbio.data.sequence.RNAStructReader.AlifoldResult;
 import compbio.data.sequence.FastaSequence;
+import compbio.data.sequence.RNAStructReader.AlifoldResult;
 import compbio.data.sequence.RNAStructScoreManager;
 import compbio.data.sequence.Range;
 import compbio.data.sequence.Score;
@@ -50,8 +49,7 @@ import compbio.metadata.Argument;
  * 
  */
 
-public class RNAalifoldClient extends JabawsCalcWorker implements
-        AlignCalcWorkerI
+public class RNAalifoldClient extends JabawsCalcWorker
 {
 
   String methodName;
@@ -75,6 +73,7 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
     initViewportParams();
   }
 
+  @Override
   public String getCalcId()
   {
     return CALC_ID;
@@ -86,16 +85,11 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
   {
     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");
-
+            jalview.ws.jws2.RNAalifoldClient.class, CALC_ID, true, false,
+            true, MessageManager.getString("label.rnalifold_calculations"),
+            MessageManager.getString("tooltip.rnalifold_calculations"),
+            MessageManager.getString("label.rnalifold_settings"),
+            MessageManager.getString("tooltip.rnalifold_settings"));
   }
 
   @Override
@@ -185,14 +179,18 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
      * same data object as was overwritten with the contact probabilites data.
      */
     if (data == null)
+    {
       data = compbio.data.sequence.RNAStructReader
               .newEmptyScore(AlifoldResult.consensusAlignment);
+    }
 
     if (descriptionData == null)
+    {
       descriptionData = data;
+    }
 
-    String[] typenameAndDescription = constructTypenameAndDescription(descriptionData
-            .first());
+    String[] typenameAndDescription = constructTypenameAndDescription(
+            descriptionData.first());
     String typename = typenameAndDescription[0];
     String description = typenameAndDescription[1];
 
@@ -221,15 +219,14 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
   }
 
   private AlignmentAnnotation constructAnnotationFromScoreHolder(
-          AlignmentAnnotation annotation, String struct, TreeSet<Score> data)
+          AlignmentAnnotation annotation, String struct,
+          TreeSet<Score> data)
   {
     Annotation[] anns = new Annotation[gapMap != null ? gapMap.length + 1
             : struct.length()];
 
-    if (data != null
-            && data.size() > 1
-            && data.first().getMethod()
-                    .equals(AlifoldResult.contactProbabilities.toString()))
+    if (data != null && data.size() > 1 && data.first().getMethod()
+            .equals(AlifoldResult.contactProbabilities.toString()))
     {
 
       // The base pair probabilities are stored in a set in scoreholder. we want
@@ -239,8 +236,8 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
       {
         // The Score objects contain a set of size one containing the range and
         // an ArrayList<float> of size one containing the probabilty
-        basePairs.put(score.getRanges().first(), new Float(score
-                .getScores().get(0)));
+        basePairs.put(score.getRanges().first(),
+                new Float(score.getScores().get(0)));
       }
 
       for (int i = 0, ri = 0, iEnd = struct.length(); i < iEnd; i++, ri++)
@@ -269,7 +266,9 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
           {
             float t = contacts.get(contact);
             if (t > prob)
+            {
               prob = t;
+            }
             description += Integer.toString(contact.from) + "->"
                     + Integer.toString(contact.to) + ": "
                     + Float.toString(t) + "%  |  ";
@@ -320,25 +319,24 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
 
       description = MessageFormat.format(
               "Minimum Free Energy Structure. Energy: {0} = {1} + {2}",
-              score.getScores().get(0), score.getScores().get(1), score
-                      .getScores().get(2));
+              score.getScores().get(0), score.getScores().get(1),
+              score.getScores().get(2));
       typename = "MFE Structure";
     }
-    else if (datatype.equals(AlifoldResult.contactProbabilityStructure
-            .toString()))
+    else if (datatype
+            .equals(AlifoldResult.contactProbabilityStructure.toString()))
     {
-      description = MessageFormat
-              .format("Base Pair Contact Probabilities. "
-                      + "Energy of Ensemble: {0}  Frequency of Ensemble: {1}",
-                      score.getScores().get(0), score.getScores().get(1));
+      description = MessageFormat.format("Base Pair Contact Probabilities. "
+              + "Energy of Ensemble: {0}  Frequency of Ensemble: {1}",
+              score.getScores().get(0), score.getScores().get(1));
       typename = "Contact Probabilities";
     }
     else if (datatype.equals(AlifoldResult.centroidStructure.toString()))
     {
       description = MessageFormat.format(
-              "Centroid Structure. Energy: {0} = {1} + {2}", score
-                      .getScores().get(0), score.getScores().get(1), score
-                      .getScores().get(2));
+              "Centroid Structure. Energy: {0} = {1} + {2}",
+              score.getScores().get(0), score.getScores().get(1),
+              score.getScores().get(2));
       typename = "Centroid Structure";
     }
     else if (datatype.equals(AlifoldResult.stochBTStructure.toString()))
@@ -349,13 +347,15 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
                 score.getScores().get(0), score.getScores().get(1));
       }
       else
+      {
         description = "Stochastic Backtrack Structure";
+      }
     }
     else if (datatype.equals(AlifoldResult.MEAStucture.toString()))
     {
       description = MessageFormat.format(
-              "Maximum Expected Accuracy Values: '{' {0} MEA={1} '}", score
-                      .getScores().get(0), score.getScores().get(1));
+              "Maximum Expected Accuracy Values: '{' {0} MEA={1} '}",
+              score.getScores().get(0), score.getScores().get(1));
       typename = "MEA Structure";
     }
     else if (datatype.equals(AlifoldResult.consensusAlignment.toString()))
@@ -369,8 +369,7 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
       description = typename;
     }
 
-    return new String[]
-    { typename, description };
+    return new String[] { typename, description };
   }
 
   // Check whether, at position i there is a base contact and return all the
@@ -386,7 +385,9 @@ public class RNAalifoldClient extends JabawsCalcWorker implements
       // ordering of the Scores TreeSet in ScoreManager which is, descending
       // probability
       if (contact.from == i || contact.to == i)
+      {
         contacts.put(contact, basePairs.get(contact));
+      }
     }
 
     return contacts;