JAL-2422 save/restore ChimeraX session
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 30 Jan 2020 16:11:37 +0000 (16:11 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 30 Jan 2020 16:11:37 +0000 (16:11 +0000)
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/gui/ChimeraViewFrame.java

index 5d61b86..786fc6c 100644 (file)
@@ -1144,7 +1144,12 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   {
     if (isChimeraRunning())
     {
-      List<String> reply = viewer.sendChimeraCommand("save " + filepath,
+      /*
+       * Chimera:  https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/save.html
+       * ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html
+       */
+      String command = isChimeraX() ? "save session " : "save ";
+      List<String> reply = viewer.sendChimeraCommand(command + filepath,
               true);
       if (reply.contains("Session written"))
       {
@@ -1161,13 +1166,18 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 
   /**
    * Ask Chimera to open a session file. Returns true if successful, else false.
-   * The filename must have a .py extension for this command to work.
+   * The filename must have a .py (Chimera) or .cxs (ChimeraX) extension for
+   * this command to work.
    * 
    * @param filepath
    * @return
    */
   public boolean openSession(String filepath)
   {
+    /*
+     * Chimera:  https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/open.html
+     * ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html
+     */
     sendChimeraCommand("open " + filepath, true);
     // todo: test for failure - how?
     return true;
@@ -1465,4 +1475,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     }
     return atts;
   }
+
+  public boolean isChimeraX()
+  {
+    return viewer.isChimeraX();
+  }
 }
index 430d302..520b74d 100644 (file)
@@ -738,7 +738,8 @@ public class ChimeraViewFrame extends StructureViewerBase
     {
       if (pathUsed == null)
       {
-        File tempFile = File.createTempFile("chimera", ".py");
+        String suffix = jmb.isChimeraX() ? ".cxs" : ".py";
+        File tempFile = File.createTempFile("chimera", suffix);
         tempFile.deleteOnExit();
         pathUsed = tempFile.getPath();
       }