JAL-3066 Working custom parameters for clustalo
[jalview.git] / src / jalview / ws / jws2 / RNAalifoldClient.java
index a67029c..7d6d341 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -25,6 +25,7 @@ import jalview.datamodel.Annotation;
 import jalview.gui.AlignFrame;
 import jalview.util.MessageManager;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
 import jalview.ws.params.WsParamSetI;
 import jalview.ws.uimodel.AlignAnalysisUIText;
 
@@ -40,7 +41,6 @@ import compbio.data.sequence.RNAStructReader.AlifoldResult;
 import compbio.data.sequence.RNAStructScoreManager;
 import compbio.data.sequence.Range;
 import compbio.data.sequence.Score;
-import compbio.metadata.Argument;
 
 /**
  * Client for the JABA RNA Alifold Service
@@ -61,11 +61,11 @@ public class RNAalifoldClient extends JabawsCalcWorker
   boolean bpScores;
 
   public RNAalifoldClient(Jws2Instance sh, AlignFrame alignFrame,
-          WsParamSetI preset, List<Argument> paramset)
+          WsParamSetI preset, List<ArgumentI> paramset)
   {
     super(sh, alignFrame, preset, paramset);
     af = alignFrame;
-    methodName = sh.serviceType;
+    methodName = sh.getName();
     alignedSeqs = true;
     submitGaps = true;
     nucleotidesAllowed = true;
@@ -112,7 +112,7 @@ public class RNAalifoldClient extends JabawsCalcWorker
     if (immediate || !calcMan.isWorking(this) && scoremanager != null)
     {
 
-      List<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
+      List<AlignmentAnnotation> ourAnnot = new ArrayList<>();
 
       // Unpack the ScoreManager
       List<String> structs = ((RNAStructScoreManager) scoremanager)
@@ -189,8 +189,8 @@ public class RNAalifoldClient extends JabawsCalcWorker
       descriptionData = data;
     }
 
-    String[] typenameAndDescription = constructTypenameAndDescription(descriptionData
-            .first());
+    String[] typenameAndDescription = constructTypenameAndDescription(
+            descriptionData.first());
     String typename = typenameAndDescription[0];
     String description = typenameAndDescription[1];
 
@@ -219,26 +219,25 @@ public class RNAalifoldClient extends JabawsCalcWorker
   }
 
   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
       // a map
-      LinkedHashMap<Range, Float> basePairs = new LinkedHashMap<Range, Float>();
+      LinkedHashMap<Range, Float> basePairs = new LinkedHashMap<>();
       for (Score score : data)
       {
         // 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(),
+                Float.valueOf(score.getScores().get(0)));
       }
 
       for (int i = 0, ri = 0, iEnd = struct.length(); i < iEnd; i++, ri++)
@@ -320,25 +319,24 @@ public class RNAalifoldClient extends JabawsCalcWorker
 
       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()))
@@ -356,8 +354,8 @@ public class RNAalifoldClient extends JabawsCalcWorker
     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()))
@@ -379,7 +377,7 @@ public class RNAalifoldClient extends JabawsCalcWorker
   private LinkedHashMap<Range, Float> isContact(
           LinkedHashMap<Range, Float> basePairs, int i)
   {
-    LinkedHashMap<Range, Float> contacts = new LinkedHashMap<Range, Float>();
+    LinkedHashMap<Range, Float> contacts = new LinkedHashMap<>();
 
     for (Range contact : basePairs.keySet())
     {