From: gmungoc Date: Mon, 11 May 2020 08:32:57 +0000 (+0100) Subject: JAL-2422 restore saved ChimeraX session from project X-Git-Tag: Release_2_11_2_0~37^2~19 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0fef78440888c7cf6980fe1349661512e3f1b62d;p=jalview.git JAL-2422 restore saved ChimeraX session from project --- diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 732fb16..476a933 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -56,6 +56,8 @@ import jalview.structures.models.AAStructureBindingModel; public abstract class JalviewChimeraBinding extends AAStructureBindingModel { + public static final String CHIMERA_SESSION_EXTENSION = ".py"; + public static final String CHIMERA_FEATURE_GROUP = "Chimera"; // Chimera clause to exclude alternate locations in atom selection @@ -870,7 +872,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel @Override public String getSessionFileExtension() { - return ".py"; + return CHIMERA_SESSION_EXTENSION; } public String getHelpURL() diff --git a/src/jalview/gui/ChimeraXViewFrame.java b/src/jalview/gui/ChimeraXViewFrame.java index 56b2fe1..d0353f3 100644 --- a/src/jalview/gui/ChimeraXViewFrame.java +++ b/src/jalview/gui/ChimeraXViewFrame.java @@ -27,6 +27,26 @@ public class ChimeraXViewFrame extends ChimeraViewFrame super(pdbsForFile, superposeAdded, theSeqs, ap); } + /** + * Constructor given a session file to be loaded + * + * @param chimeraSessionFile + * @param alignPanel + * @param pdbArray + * @param seqsArray + * @param colourByChimera + * @param colourBySequence + * @param newViewId + */ + public ChimeraXViewFrame(String chimeraSessionFile, + AlignmentPanel alignPanel, PDBEntry[] pdbArray, + SequenceI[][] seqsArray, boolean colourByChimera, + boolean colourBySequence, String newViewId) + { + super(chimeraSessionFile, alignPanel, pdbArray, seqsArray, + colourByChimera, colourBySequence, newViewId); + } + @Override public ViewerType getViewerType() { diff --git a/src/jalview/gui/JalviewChimeraXBindingModel.java b/src/jalview/gui/JalviewChimeraXBindingModel.java index d7b5a94..c685f0f 100644 --- a/src/jalview/gui/JalviewChimeraXBindingModel.java +++ b/src/jalview/gui/JalviewChimeraXBindingModel.java @@ -16,6 +16,8 @@ import jalview.structure.StructureSelectionManager; public class JalviewChimeraXBindingModel extends JalviewChimeraBindingModel { + public static final String CHIMERAX_SESSION_EXTENSION = ".cxs"; + public JalviewChimeraXBindingModel(ChimeraViewFrame chimeraViewFrame, StructureSelectionManager ssm, PDBEntry[] pdbentry, SequenceI[][] sequenceIs, DataSourceType protocol) @@ -65,7 +67,7 @@ public class JalviewChimeraXBindingModel extends JalviewChimeraBindingModel @Override public String getSessionFileExtension() { - return ".cxs"; + return CHIMERAX_SESSION_EXTENSION; } @Override diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index e7af837..b6295d9 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -102,13 +102,16 @@ import jalview.datamodel.features.FeatureMatcher; import jalview.datamodel.features.FeatureMatcherI; import jalview.datamodel.features.FeatureMatcherSet; import jalview.datamodel.features.FeatureMatcherSetI; +import jalview.ext.rbvi.chimera.JalviewChimeraBinding; import jalview.ext.varna.RnaModel; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; import jalview.gui.AlignmentPanel; import jalview.gui.AppVarna; import jalview.gui.ChimeraViewFrame; +import jalview.gui.ChimeraXViewFrame; import jalview.gui.Desktop; +import jalview.gui.JalviewChimeraXBindingModel; import jalview.gui.JvOptionPane; import jalview.gui.OOMWarning; import jalview.gui.PCAPanel; @@ -4400,34 +4403,41 @@ public class Jalview2XML * From 2.9: stateData.type contains JMOL or CHIMERA, data is in jar entry * "viewer_"+stateData.viewId */ - String viewerType = stateData.getType(); - if (ViewerType.CHIMERA.toString().equals(viewerType)) - { - createChimeraViewer(viewerData, af, jprovider); - } - if (ViewerType.PYMOL.toString().equals(viewerType)) + ViewerType viewerType = ViewerType.valueOf(stateData.getType()); + try { - createPymolViewer(viewerData, af, jprovider); - } - else + switch (viewerType) + { + case CHIMERA: + createChimeraViewer(viewerData, af, jprovider, false); + break; + case CHIMERAX: + createChimeraViewer(viewerData, af, jprovider, true); + break; + case PYMOL: + createPymolViewer(viewerData, af, jprovider); + break; + case JMOL: + createJmolViewer(viewerData, af, jprovider); + } + } catch (IllegalArgumentException | NullPointerException e) { - /* - * else Jmol (if pre-2.9, stateData contains JMOL state string) - */ - createJmolViewer(viewerData, af, jprovider); + Cache.log.error( + "Invalid structure viewer type: " + stateData.getType()); } } /** - * Create a new Chimera viewer. + * Create a new Chimera or ChimeraX viewer * * @param data * @param af * @param jprovider + * @param isChimeraX */ protected void createChimeraViewer( Entry viewerData, AlignFrame af, - jarInputStreamProvider jprovider) + jarInputStreamProvider jprovider, boolean isChimeraX) { StructureViewerModel data = viewerData.getValue(); String chimeraSessionFile = data.getStateData(); @@ -4439,8 +4449,11 @@ public class Jalview2XML * 'uniquified' sviewid used to reconstruct the viewer here */ String viewerJarEntryName = getViewerJarEntryName(data.getViewId()); + String extension = isChimeraX + ? JalviewChimeraXBindingModel.CHIMERAX_SESSION_EXTENSION + : JalviewChimeraBinding.CHIMERA_SESSION_EXTENSION; chimeraSessionFile = copyJarEntry(jprovider, viewerJarEntryName, - "chimera", ".py"); + "chimera", extension); Set> fileData = data.getFileData() .entrySet(); @@ -4466,9 +4479,13 @@ public class Jalview2XML .toArray(new SequenceI[allseqs.size()][]); String newViewId = viewerData.getKey(); - ChimeraViewFrame cvf = new ChimeraViewFrame(chimeraSessionFile, - af.alignPanel, pdbArray, seqsArray, colourByChimera, - colourBySequence, newViewId); + ChimeraViewFrame cvf = isChimeraX + ? new ChimeraXViewFrame(chimeraSessionFile, af.alignPanel, + pdbArray, seqsArray, colourByChimera, colourBySequence, + newViewId) + : new ChimeraViewFrame(chimeraSessionFile, af.alignPanel, + pdbArray, seqsArray, colourByChimera, colourBySequence, + newViewId); cvf.setSize(data.getWidth(), data.getHeight()); cvf.setLocation(data.getX(), data.getY()); }