X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FJalviewChimeraBinding.java;h=3c751e76b887c9897b8beca65f2d5062065aa852;hb=6f9e452300ac8853e5c10ec29828f420f3909341;hp=1434c7680afa9322d18d5ca974124f44d1359a00;hpb=ab97cf4af61bd67f20676c686601522d0ba0875d;p=jalview.git 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()