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;
*/
public void highlightChimeraSelection()
{
+ /*
+ * Ask Chimera for its current selection
+ */
List<String> 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<String> 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<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
- 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
*/
}
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()