From: gmungoc Date: Fri, 20 Feb 2015 17:19:21 +0000 (+0000) Subject: JAL-1675 correct highlighting in Chimera for mouseover of sequence X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a30658d78a2ced8b01abacae8ff68a774b0ef81;p=jalview.git JAL-1675 correct highlighting in Chimera for mouseover of sequence --- diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index f511a65..754bc7f 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -66,8 +66,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel private Map chainFile; - private StringBuffer eval = new StringBuffer(); - public String fileLoadingError; /* @@ -88,6 +86,15 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel private boolean loadedInline; /** + * current set of model filenames loaded + */ + String[] modelFileNames = null; + + String lastMousedOverAtomSpec; + + private List lastReply; + + /** * Open a PDB structure file in Chimera and set up mappings from Jalview. * * We check if the PDB model id is already loaded in Chimera, if so don't @@ -152,16 +159,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * current set of model filenames loaded - */ - String[] modelFileNames = null; - - - StringBuffer resetLastRes = new StringBuffer(); - - private List lastReply; - - /** * Constructor * * @param ssm @@ -821,44 +818,44 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel public abstract SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment); - // jmol/ssm only + /** + * Construct and send a command to highlight an atom. + * + *
+   * Done by generating a command like (to 'highlight' position 44)
+   *   ~select #0:43.C;select #0:44.C
+   * Note this removes the selection from the previous position.
+   * 
+ */ public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) { List cms = chimeraMaps.get(pdbfile); if (cms != null) { - int mdlNum = cms.get(0).getModelNumber(); - - viewerCommandHistory(false); - // viewer.stopListening(); - if (resetLastRes.length() > 0) + StringBuilder sb = new StringBuilder(); + sb.append(" #" + cms.get(0).getModelNumber()); + sb.append(":" + pdbResNum); + if (!chain.equals(" ")) { - eval.setLength(0); - eval.append(resetLastRes.toString() + ";"); + sb.append("." + chain); } + String atomSpec = sb.toString(); - eval.append("display "); // +modelNum - - resetLastRes.setLength(0); - resetLastRes.append("~display "); + StringBuilder command = new StringBuilder(32); + if (lastMousedOverAtomSpec != null) { - eval.append(" #" + (mdlNum)); - resetLastRes.append(" #" + (mdlNum)); + command.append("~select " + lastMousedOverAtomSpec + ";"); } - // complete select string - - eval.append(":" + pdbResNum); - resetLastRes.append(":" + pdbResNum); - if (!chain.equals(" ")) + viewerCommandHistory(false); + String cmd = command.toString(); + cmd = "select " + atomSpec; + if (cmd.length() > 0) { - eval.append("." + chain); - resetLastRes.append("." + chain); + viewer.sendChimeraCommand(cmd, false); } - - viewer.sendChimeraCommand(eval.toString(), false); viewerCommandHistory(true); - // viewer.startListening(); + this.lastMousedOverAtomSpec = atomSpec; } } @@ -1262,4 +1259,4 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel return chainNames; } -} \ No newline at end of file +}