JAL-629 parse SubVals once with ArgValue. Ensure SubVals exists. Change to setprops...
[jalview.git] / src / jalview / bin / Commands.java
index 9ff95e3..4a70bd9 100644 (file)
@@ -399,7 +399,7 @@ public class Commands
         for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE))
         {
           String val = av.getValue();
-          SubVals subId = new SubVals(val);
+          SubVals subId = av.getSubVals();
           SequenceI seq = getSpecifiedSequence(af, subId);
           if (seq == null)
           {
@@ -494,7 +494,7 @@ public class Commands
         for (ArgValue av : avm.getArgValueList(Arg.PAEMATRIX))
         {
           String val = av.getValue();
-          SubVals subVals = ArgParser.getSubVals(val);
+          SubVals subVals = av.getSubVals();
           String paeLabel = subVals.get("label");
           File paeFile = new File(subVals.getContent());
           String paePath = null;
@@ -507,10 +507,14 @@ public class Commands
             Console.warn(
                     "Problem with the PAE file path: '" + paePath + "'");
           }
-          String structid = null;
-          String structfile = null;
-          int seqindex = SubVals.NOTSET;
-          if (subVals.notSet())
+          String structid = subVals.get("structid");
+          String structfile = subVals.get("structfile");
+          String seqid = subVals.get("seqid");
+          int seqindex = subVals.getIndex();
+
+          // let's find a structure
+          if (structfile == null && structid == null && seqid == null
+                  && seqindex == SubVals.NOTSET)
           {
             ArgValue likelyStructure = avm
                     .getClosestPreviousArgValueOfArg(av, Arg.STRUCTURE);
@@ -530,41 +534,39 @@ public class Commands
               }
             }
           }
-          else if (subVals.has("structfile"))
-          {
-            structfile = subVals.get("structfile");
-          }
-          else if (subVals.has("structid"))
-          {
-            structid = subVals.get("structid");
-          }
+
           if (structfile != null)
           {
-            Console.info("##### Attaching paeFile '" + paePath + "' to "
+            Console.debug("##### Attaching paeFile '" + paePath + "' to "
                     + "structfile=" + structfile);
             EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
                     paeFile, seqindex, structfile, true, false, paeLabel);
           }
           else if (structid != null)
           {
-            Console.info("##### Attaching paeFile '" + paePath + "' to "
+            Console.debug("##### Attaching paeFile '" + paePath + "' to "
                     + "structid=" + structid);
             EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
-                    paeFile, seqindex, subVals.get("structid"), true, true,
-                    paeLabel);
+                    paeFile, seqindex, structid, true, true, paeLabel);
           }
-          else
+          else if (seqid != null)
+          {
+            Console.debug("##### Attaching paeFile '" + paePath + "' to "
+                    + "seqid=" + seqid);
+            EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
+                    paeFile, seqindex, seqid, false, false, paeLabel);
+          }
+          else if (seqindex >= 0)
           {
-            seqindex = subVals.getIndex();
             Console.debug("##### Attaching paeFile '" + paePath
                     + "' to sequence index " + seqindex);
             EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
                     paeFile, seqindex, null, false, false, paeLabel);
-            // required to readjust the height and position of the PAE
-            // annotation
           }
           for (AlignmentViewPanel ap : af.getAlignPanels())
           {
+            // required to readjust the height and position of the PAE
+            // annotation
             ap.adjustAnnotationHeight();
           }
         }
@@ -605,7 +607,7 @@ public class Commands
       for (ArgValue av : avm.getArgValueList(Arg.IMAGE))
       {
         String val = av.getValue();
-        SubVals subVal = new SubVals(val);
+        SubVals subVal = av.getSubVals();
         String type = "png"; // default
         String fileName = subVal.getContent();
         File file = new File(fileName);