JAL-2422 correct ChimeraX save/open session commands; check for null
[jalview.git] / src / jalview / ext / rbvi / chimera / ChimeraXCommands.java
index b7d9ce3..6df5ab9 100644 (file)
  */
 package jalview.ext.rbvi.chimera;
 
+import java.awt.Color;
+import java.util.Arrays;
+import java.util.List;
+
 import jalview.structure.AtomSpecModel;
 import jalview.structure.StructureCommand;
 import jalview.structure.StructureCommandI;
 import jalview.util.ColorUtils;
 
-import java.awt.Color;
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * Routines for generating ChimeraX commands for Jalview/ChimeraX binding
  */
@@ -125,7 +125,8 @@ public class ChimeraXCommands extends ChimeraCommands
   public StructureCommandI saveSession(String filepath)
   {
     // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html
-    return new StructureCommand("save session " + filepath);
+    // note ChimeraX will append ".cxs" to the filepath!
+    return new StructureCommand("save " + filepath + " format session");
   }
 
   /**
@@ -222,4 +223,10 @@ public class ChimeraXCommands extends ChimeraCommands
     return Arrays.asList(new StructureCommand(cmd.toString()));
   }
 
+  @Override
+  public StructureCommandI openSession(String filepath)
+  {
+    // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html#composite
+    return new StructureCommand("open " + filepath + " format session");
+  }
 }