From 6f9e452300ac8853e5c10ec29828f420f3909341 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 6 May 2015 12:50:25 +0100 Subject: [PATCH] JAL-1725 parse atomSpec with submodel; debug output removed --- src/jalview/ext/rbvi/chimera/ChimeraListener.java | 2 +- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 83 ++++++++++---------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/jalview/ext/rbvi/chimera/ChimeraListener.java b/src/jalview/ext/rbvi/chimera/ChimeraListener.java index 2479a1b..c9ec136 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraListener.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraListener.java @@ -122,7 +122,7 @@ public class ChimeraListener extends AbstractRequestHandler implements */ protected void processModelChanged(String message) { - System.out.println(message + " (not implemented in Jalview)"); + // System.out.println(message + " (not implemented in Jalview)"); } /** diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 1434c76..3c751e7 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -23,7 +23,6 @@ package jalview.ext.rbvi.chimera; import java.awt.Color; import java.net.BindException; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -931,58 +930,43 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel */ public void highlightChimeraSelection() { + /* + * Ask Chimera for its current selection + */ List selection = viewer.getSelectedResidueSpecs(); - // System.out.println("Chimera selection: " + selection.toString()); - // TODO handle more than one!! - if (selection.size() > 0) - { - highlightChimeraSelection(selection); - } - } - - private void log(String message) - { - System.err.println("## Chimera log: " + message); - } - - private void viewerCommandHistory(boolean enable) - { - // log("(Not yet implemented) History " - // + ((debug || enable) ? "on" : "off")); - } - - /** - * Propagate atom selections from Chimera - * - * @param atoms - * for example "#0:70.A" (model/residue/chain) - */ - public void highlightChimeraSelection(List atoms) - { + /* + * Parse model number, residue and chain for each selected position, + * formatted as #0:123.A or #1.2:87.B (#model.submodel:residue.chain) + */ List atomSpecs = new ArrayList(); - for (String atomSpec : atoms) + for (String atomSpec : selection) { - int hashPos = atomSpec.indexOf("#"); int colonPos = atomSpec.indexOf(":"); - int dotPos = atomSpec.indexOf("."); - if (colonPos == -1) { continue; // malformed } - int pdbResNum = Integer.parseInt(dotPos == -1 ? atomSpec - .substring(colonPos) : atomSpec.substring(colonPos + 1, - dotPos)); - - String chainId = dotPos == -1 ? "" : atomSpec.substring(dotPos + 1); + + int hashPos = atomSpec.indexOf("#"); + String modelSubmodel = atomSpec.substring(hashPos + 1, colonPos); + int dotPos = modelSubmodel.indexOf("."); int modelId = 0; try { - modelId = Integer.valueOf(atomSpec.substring(hashPos + 1, colonPos)); + modelId = Integer.valueOf(dotPos == -1 ? modelSubmodel + : modelSubmodel.substring(0, dotPos)); } catch (NumberFormatException e) { // ignore, default to model 0 } - + + String residueChain = atomSpec.substring(colonPos + 1); + dotPos = residueChain.indexOf("."); + int pdbResNum = Integer.parseInt(dotPos == -1 ? residueChain + : residueChain.substring(0, dotPos)); + + String chainId = dotPos == -1 ? "" : residueChain + .substring(dotPos + 1); + /* * Work out the pdbfilename from the model number */ @@ -1000,10 +984,23 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } atomSpecs.add(new AtomSpec(pdbfilename, chainId, pdbResNum, 0)); } - if (!atomSpecs.isEmpty()) - { - getSsm().mouseOverStructure(atomSpecs); - } + + /* + * Broadcast the selection (which may be empty, if the user just cleared all + * selections) + */ + getSsm().mouseOverStructure(atomSpecs); + } + + private void log(String message) + { + System.err.println("## Chimera log: " + message); + } + + private void viewerCommandHistory(boolean enable) + { + // log("(Not yet implemented) History " + // + ((debug || enable) ? "on" : "off")); } public long getLoadNotifiesHandled() -- 1.7.10.2