JAL-629 Attempts to add PAE to structure. --headless working. Make HTML output single...
[jalview.git] / src / jalview / bin / Commands.java
index 77ca018..c05194d 100644 (file)
@@ -32,6 +32,7 @@ import jalview.io.HtmlSvgOutput;
 import jalview.io.IdentifyFile;
 import jalview.structure.StructureImportSettings;
 import jalview.structure.StructureImportSettings.TFType;
+import jalview.structure.StructureSelectionManager;
 import jalview.util.HttpUtils;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
@@ -51,10 +52,17 @@ public class Commands
   {
     argParser = ap;
     headless = h;
+
+    if (headless)
+    {
+      System.setProperty("java.awt.headless", "true");
+    }
+
     if (argParser != null && argParser.linkedIds() != null)
     {
       for (String id : argParser.linkedIds())
       {
+        Console.debug("##### id=" + id);
         Commands cmds = new Commands();
         if (id == null)
         {
@@ -67,10 +75,11 @@ public class Commands
         cmds.processImages(id);
       }
 
-      if (argParser.getBool(Arg.QUIT))
-      {
-        Jalview.getInstance().quit();
-      }
+    }
+    if (argParser.getBool(Arg.QUIT))
+    {
+      Jalview.getInstance().quit();
+      // Desktop.instance.quit();
     }
   }
 
@@ -87,6 +96,8 @@ public class Commands
 
   protected void processUnlinked(String id)
   {
+    Map<Arg, ArgValues> m = argParser.linkedArgs(id);
+
     processLinked(id);
   }
 
@@ -104,7 +115,6 @@ public class Commands
     FileFormatI format = null;
     DataSourceType protocol = null;
     */
-
     if (ArgParser.getArgValues(m, Arg.OPEN) != null)
     {
       long progress = -1;
@@ -289,6 +299,16 @@ public class Commands
 
           // store the AlignFrame for this id
           afMap.put(id, af);
+
+          // is it its own structure file?
+          if (format.isStructureFile())
+          {
+            StructureSelectionManager ssm = StructureSelectionManager
+                    .getStructureSelectionManager(Desktop.instance);
+            SequenceI seq = af.alignPanel.getAlignment().getSequenceAt(0);
+            ssm.computeMapping(false, new SequenceI[] { seq }, null,
+                    openFile, DataSourceType.FILE, null);
+          }
         }
         else
         {
@@ -328,11 +348,24 @@ public class Commands
         {
           SubVal subVal = ArgParser.getSubVal(val);
           File paeFile = new File(subVal.content);
-          if ("structid".equals(subVal.index))
+          String structId = "structid".equals(subVal.keyName)
+                  ? subVal.keyValue
+                  : null;
+          if (subVal.notSet())
+          {
+            // take structid from pdbfilename
+          }
+          if ("structfile".equals(subVal.keyName))
+          {
+            EBIAlfaFold.addAlphaFoldPAEToStructure(
+                    af.getCurrentView().getAlignment(), paeFile,
+                    subVal.index, subVal.keyValue, false);
+          }
+          else if ("structid".equals(subVal.keyName))
           {
             EBIAlfaFold.addAlphaFoldPAEToStructure(
                     af.getCurrentView().getAlignment(), paeFile,
-                    subVal.index, subVal.keyValue);
+                    subVal.index, subVal.keyValue, true);
           }
           else
           {