From bf68bd00205b1216a5744c9db11b5a8ebc4c7af9 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 30 Jan 2020 16:11:37 +0000 Subject: [PATCH] JAL-2422 save/restore ChimeraX session --- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 19 +++++++++++++++++-- src/jalview/gui/ChimeraViewFrame.java | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 5d61b86..786fc6c 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -1144,7 +1144,12 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel { if (isChimeraRunning()) { - List 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 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(); + } } diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 430d302..520b74d 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -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(); } -- 1.7.10.2