public void stopListening()
{
- // TODO send this command when viewer connection is closed in Jalview
- String command = isChimeraX
- ? "info notify stop models jalview; info notify stop selection jalview"
- : "listen stop models ; listen stop selection ";
+ String command = "listen stop models ; listen stop selection ";
sendChimeraCommand(command, false);
}
/*
* listen for model changes
*/
- String command = isChimeraX
- ? ("info notify start models prefix ModelChanged jalview url "
- + uri)
- : ("listen start models url " + uri);
+ String command = "listen start models url " + uri;
sendChimeraCommand(command, false);
/*
* listen for selection changes
*/
- command = isChimeraX
- ? ("info notify start selection jalview prefix SelectionChanged url "
- + uri)
- : ("listen start select prefix SelectionChanged url " + uri);
+ command = "listen start select prefix SelectionChanged url " + uri;
sendChimeraCommand(command, false);
}
{
List<String> selectedResidues = new ArrayList<>();
- // in fact 'listinfo' (undocumented) works in ChimeraX
- String command = (isChimeraX
- ? "info"
- : "list") + " selection level residue";
+ String command = "list selection level residue";
List<String> chimeraReply = sendChimeraCommand(command, true);
if (chimeraReply != null)
{
{
List<ChimeraModel> modelList = new ArrayList<>();
String command = "list models type "
- + (isChimeraX ? "AtomicStructure" : "molecule");
+ + (isChimeraX() ? "AtomicStructure" : "molecule");
List<String> list = sendChimeraCommand(command, true);
if (list != null)
{
{
// ensure symbolic links are resolved
chimeraPath = Paths.get(chimeraPath).toRealPath().toString();
- isChimeraX = chimeraPath.toLowerCase().contains("chimerax");
File path = new File(chimeraPath);
// uncomment the next line to simulate Chimera not installed
// path = new File(chimeraPath + "x");
args.add(chimeraPath);
// shows Chimera output window but suppresses REST responses:
// args.add("--debug");
- if (isChimeraX())
- {
- args.add("--cmd");
- args.add("remote rest start");
- }
- else
- {
- args.add("--start");
- args.add("RESTServer");
- }
+ addLaunchArguments(args);
ProcessBuilder pb = new ProcessBuilder(args);
chimera = pb.start();
error = "";
}
/**
+ * Adds command-line arguments to start the REST server
+ * <p>
+ * Method extracted for Jalview to allow override in ChimeraXManager
+ * @param args
+ */
+ protected void addLaunchArguments(List<String> args)
+ {
+ args.add("--start");
+ args.add("RESTServer");
+ }
+
+ /**
* Read and return the port number returned in the reply to --start RESTServer
*/
private int getPortNumber()
public List<String> getAttrList()
{
List<String> attributes = new ArrayList<>();
- String command = (isChimeraX ? "info " : "list ") + "resattr";
+ String command = (isChimeraX() ? "info " : "list ") + "resattr";
final List<String> reply = sendChimeraCommand(command, true);
if (reply != null)
{
private volatile boolean busy = false;
- private boolean isChimeraX;
-
/**
* Send a command to Chimera.
*
{
String restUrl = "http://127.0.0.1:" + this.chimeraRestPort + "/run";
List<NameValuePair> commands = new ArrayList<>(1);
- String method = isChimeraX() ? "GET" : "POST";
+ String method = getHttpRequestMethod();
if ("GET".equals(method))
{
command = command.replace(" ", "+").replace("#", "%23")
}
/**
+ * Returns "POST" as the HTTP request method to use for REST service calls to Chimera
+ * @return
+ */
+ protected String getHttpRequestMethod()
+ {
+ return "POST";
+ }
+
+ /**
* Send a command to stdin of Chimera process, and optionally read any
* responses.
*
public boolean isChimeraX()
{
- return isChimeraX;
- }
-
- public void setChimeraX(boolean b)
- {
- isChimeraX = b;
+ return false;
}
}
*/
public class PymolCommands extends StructureCommandsBase
{
+ private static final StructureCommand CLOSE_PYMOL = new StructureCommand("quit");
+
private static final StructureCommand COLOUR_BY_CHAIN = new StructureCommand("spectrum", "chain");
private static final List<StructureCommandI> COLOR_BY_CHARGE = new ArrayList<>();
public StructureCommandI closeViewer()
{
// https://pymolwiki.org/index.php/Quit
- return new StructureCommand("quit");
+ return CLOSE_PYMOL;
}
}
*/
public class ChimeraCommands extends StructureCommandsBase
{
+ private static final StructureCommand CLOSE_CHIMERA = new StructureCommand("stop really");
+
+ private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand("listen stop selection");
+
+ private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand("listen stop models");
+
+ private static final StructureCommand GET_SELECTION = new StructureCommand("list selection level residue");
+
private static final StructureCommand SHOW_BACKBONE = new StructureCommand(
"~display all;~ribbon;chain @CA|P");
public StructureCommandI closeViewer()
{
// https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/stop.html
- return new StructureCommand("stop really");
+ return CLOSE_CHIMERA;
+ }
+
+ @Override
+ public List<StructureCommandI> startNotifications(String uri)
+ {
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/listen.html
+ List<StructureCommandI> cmds = new ArrayList<>();
+ cmds.add(new StructureCommand("listen start models url " + uri));
+ cmds.add(new StructureCommand("listen start select prefix SelectionChanged url " + uri));
+ return cmds;
+ }
+
+ @Override
+ public List<StructureCommandI> stopNotifications()
+ {
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/listen.html
+ List<StructureCommandI> cmds = new ArrayList<>();
+ cmds.add(STOP_NOTIFY_MODELS);
+ cmds.add(STOP_NOTIFY_SELECTION);
+ return cmds;
+ }
+
+ @Override
+ public StructureCommandI getSelectedResidues()
+ {
+ return GET_SELECTION;
}
}
package jalview.ext.rbvi.chimera;
import java.awt.Color;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
*/
public class ChimeraXCommands extends ChimeraCommands
{
+ private static final StructureCommand CLOSE_CHIMERAX = new StructureCommand("exit");
+
+ private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand("info notify stop selection jalview");
+
+ private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand("info notify stop models jalview");
+
+ private static final StructureCommand GET_SELECTION = new StructureCommand("info selection level residue");
+
private static final StructureCommand SHOW_BACKBONE = new StructureCommand(
"~display all;~ribbon;show @CA|P atoms");
public StructureCommandI closeViewer()
{
// https://www.cgl.ucsf.edu/chimerax/docs/user/commands/exit.html
- return new StructureCommand("exit");
+ return CLOSE_CHIMERAX;
+ }
+
+ @Override
+ public List<StructureCommandI> startNotifications(String uri)
+ {
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify
+ List<StructureCommandI> cmds = new ArrayList<>();
+ cmds.add(new StructureCommand("info notify start models prefix ModelChanged jalview url " + uri));
+ cmds.add(new StructureCommand("info notify start selection jalview prefix SelectionChanged url " + uri));
+ return cmds;
+ }
+
+ @Override
+ public List<StructureCommandI> stopNotifications()
+ {
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify
+ List<StructureCommandI> cmds = new ArrayList<>();
+ cmds.add(STOP_NOTIFY_MODELS);
+ cmds.add(STOP_NOTIFY_SELECTION);
+ return cmds;
+ }
+
+ @Override
+ public StructureCommandI getSelectedResidues()
+ {
+ return GET_SELECTION;
}
}
--- /dev/null
+package jalview.ext.rbvi.chimera;
+
+import java.util.List;
+
+import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
+import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
+
+/**
+ * A class to help Jalview start, stop and send commands to ChimeraX.
+ * <p>
+ * Much of the functionality is common with Chimera, so for convenience we
+ * extend ChimeraManager, however note this class is <em>not</em> based on the
+ * Cytoscape class at
+ * {@code https://github.com/RBVI/structureVizX/blob/master/src/main/java/edu/ucsf/rbvi/structureVizX/internal/model/ChimeraManager.java}.
+ *
+ * @author gmcarstairs
+ *
+ */
+public class ChimeraXManager extends ChimeraManager
+{
+
+ public ChimeraXManager(StructureManager structureManager)
+ {
+ super(structureManager);
+ }
+
+ public boolean isChimeraX()
+ {
+ return true;
+ }
+
+ /**
+ * Returns "POST" as the HTTP request method to use for REST service calls to ChimeraX
+ * @return
+ */
+ protected String getHttpRequestMethod()
+ {
+ return "GET";
+ }
+
+ /**
+ * Adds command-line arguments to start the REST server
+ */
+ protected void addLaunchArguments(List<String> args)
+ {
+ args.add("--cmd");
+ args.add("remote rest start");
+ }
+
+}
String lastHighlightCommand;
/**
+ * Returns a model of the structure positions described by the Chimera format atomspec
+ * @param atomSpec
+ * @return
+ */
+ protected AtomSpec parseAtomSpec(String atomSpec)
+ {
+ return AtomSpec.fromChimeraAtomspec(atomSpec);
+ }
+
+ /**
* 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 reopen
DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, protocol);
- chimeraManager = new ChimeraManager(new StructureManager(true));
- chimeraManager.setChimeraX(ViewerType.CHIMERAX.equals(getViewerType()));
- setStructureCommands(new ChimeraCommands());
+ boolean chimeraX = ViewerType.CHIMERAX.equals(getViewerType());
+ chimeraManager = chimeraX ? new ChimeraXManager(new StructureManager(true)) : new ChimeraManager(new StructureManager(true));
+ setStructureCommands(chimeraX ? new ChimeraXCommands() : new ChimeraCommands());
}
@Override
try
{
chimeraListener = new ChimeraListener(this);
- chimeraManager.startListening(chimeraListener.getUri());
+ startListening(chimeraListener.getUri());
} catch (BindException e)
{
System.err.println(
chimeraListener.shutdown();
chimeraListener = null;
}
+
+ /*
+ * the following call should not be needed but is temporarily included,
+ * to avoid a stack trace error in Chimera after "stop really" is sent
+ */
+ if (closeChimera)
+ {
+ chimeraManager.getChimeraProcess().destroy();
+ }
+
chimeraManager.clearOnChimeraExit();
chimeraManager = null;
}
/*
* Ask Chimera for its current selection
*/
- List<String> selection = chimeraManager.getSelectedResidueSpecs();
+ StructureCommandI command = getCommandGenerator().getSelectedResidues();
+ List<String> chimeraReply = executeCommand(command, true);
+ List<String> selectedResidues = new ArrayList<>();
+ if (chimeraReply != null)
+ {
+ /*
+ * expect 0, 1 or more lines of the format either
+ * Chimera:
+ * residue id #0:43.A type GLY
+ * ChimeraX:
+ * residue id /A:89 name THR index 88
+ * We are only interested in the atomspec (third token of the reply)
+ */
+ for (String inputLine : chimeraReply)
+ {
+ String[] inputLineParts = inputLine.split("\\s+");
+ if (inputLineParts.length >= 5)
+ {
+ selectedResidues.add(inputLineParts[2]);
+ }
+ }
+ }
/*
* 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 = convertStructureResiduesToAlignment(
- selection);
+ selectedResidues);
/*
* Broadcast the selection (which may be empty, if the user just cleared all
}
/**
- * Converts a list of Chimera atomspecs to a list of AtomSpec representing the
+ * Converts a list of Chimera(X) atomspecs to a list of AtomSpec representing the
* corresponding residues (if any) in Jalview
*
* @param structureSelection
protected List<AtomSpec> convertStructureResiduesToAlignment(
List<String> structureSelection)
{
- boolean chimeraX = chimeraManager.isChimeraX();
List<AtomSpec> atomSpecs = new ArrayList<>();
for (String atomSpec : structureSelection)
{
try
{
- AtomSpec spec = AtomSpec.fromChimeraAtomspec(atomSpec, chimeraX);
+ AtomSpec spec = parseAtomSpec(atomSpec);
String pdbfilename = getPdbFileForModel(spec.getModelNumber());
spec.setPdbFile(pdbfilename);
atomSpecs.add(spec);
{
boolean featureAdded = false;
String featureGroup = getViewerFeatureGroup();
- boolean chimeraX = chimeraManager.isChimeraX();
for (String residue : residues)
{
try
{
- spec = AtomSpec.fromChimeraAtomspec(atomSpec, chimeraX);
+ spec = parseAtomSpec(atomSpec);
} catch (IllegalArgumentException e)
{
System.err.println("Problem parsing atomspec " + atomSpec);
*/
package jalview.gui;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
import jalview.api.AlignmentViewPanel;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.io.DataSourceType;
+import jalview.structure.AtomSpec;
import jalview.structure.StructureSelectionManager;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-
public class JalviewChimeraBindingModel extends JalviewChimeraBinding
{
public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
@Override
public void refreshGUI()
{
- javax.swing.SwingUtilities.invokeLater(new Runnable()
+ SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
import jalview.ext.rbvi.chimera.ChimeraXCommands;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
+import jalview.structure.AtomSpec;
import jalview.structure.StructureCommand;
import jalview.structure.StructureSelectionManager;
public class JalviewChimeraXBindingModel extends JalviewChimeraBindingModel
{
-
public static final String CHIMERAX_SESSION_EXTENSION = ".cxs";
public JalviewChimeraXBindingModel(ChimeraViewFrame chimeraViewFrame,
return String.valueOf(pdbfnum + 1);
}
+ /**
+ * Returns a model of the structure positions described by the ChimeraX format atomspec
+ * @param atomSpec
+ * @return
+ */
+ protected AtomSpec parseAtomSpec(String atomSpec)
+ {
+ return AtomSpec.fromChimeraXAtomspec(atomSpec);
+ }
+
}
* <pre>
* Chimera format:
* #1.2:12-20.A model 1, submodel 2, chain A, atoms 12-20
- * ChimeraX format:
- * #1.2/A:12-20
* </pre>
*
* @param spec
- * @param chimeraX
* @return
* @throw IllegalArgumentException if the spec cannot be parsed, or represents
* more than one residue
* @see https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/frameatom_spec.html
- * @see http://rbvi.ucsf.edu/chimerax/docs/user/commands/atomspec.html
*/
- public static AtomSpec fromChimeraAtomspec(String spec, boolean chimeraX)
+ public static AtomSpec fromChimeraAtomspec(String spec)
{
- int modelSeparatorPos = spec.indexOf(chimeraX ? "/" : ":");
+ int modelSeparatorPos = spec.indexOf(":");
if (modelSeparatorPos == -1)
{
throw new IllegalArgumentException(spec);
* ChimeraX: chain:atoms
*/
String atomsAndChain = spec.substring(modelSeparatorPos + 1);
- String[] tokens = atomsAndChain.split(chimeraX ? "\\:" : "\\.");
- String atoms = tokens.length == 1 ? atomsAndChain
- : (chimeraX ? tokens[1] : tokens[0]);
+ String[] tokens = atomsAndChain.split("\\.");
+ String atoms = tokens.length == 1 ? atomsAndChain : (tokens[0]);
int resNum = 0;
try
{
throw new IllegalArgumentException(spec);
}
- String chainId = tokens.length == 1 ? ""
- : (chimeraX ? tokens[0] : tokens[1]);
+ String chainId = tokens.length == 1 ? "" : (tokens[1]);
return new AtomSpec(modelId, chainId, resNum, 0);
}
return "pdbFile: " + pdbFile + ", chain: " + chain + ", res: "
+ pdbResNum + ", atom: " + atomIndex;
}
+
+ /**
+ * Parses a ChimeraX atomspec to construct an AtomSpec model (with
+ * null pdb file name)
+ *
+ * <pre>
+ * ChimeraX format:
+ * #1.2/A:12-20 model 1, submodel 2, chain A, atoms 12-20
+ * </pre>
+ *
+ * @param spec
+ * @return
+ * @throw IllegalArgumentException if the spec cannot be parsed, or represents
+ * more than one residue
+ * @see http://rbvi.ucsf.edu/chimerax/docs/user/commands/atomspec.html
+ */
+ public static AtomSpec fromChimeraXAtomspec(String spec)
+ {
+ int modelSeparatorPos = spec.indexOf("/");
+ if (modelSeparatorPos == -1)
+ {
+ throw new IllegalArgumentException(spec);
+ }
+
+ int hashPos = spec.indexOf("#");
+ if (hashPos == -1 && modelSeparatorPos != 0)
+ {
+ // # is missing but something precedes : - reject
+ throw new IllegalArgumentException(spec);
+ }
+
+ String modelSubmodel = spec.substring(hashPos + 1, modelSeparatorPos);
+ int modelId = 0;
+ try
+ {
+ int subModelPos = modelSubmodel.indexOf(".");
+ modelId = Integer.valueOf(
+ subModelPos > 0 ? modelSubmodel.substring(0, subModelPos)
+ : modelSubmodel);
+ } catch (NumberFormatException e)
+ {
+ // ignore, default to model 0
+ }
+
+ /*
+ * now process what follows the model, either
+ * Chimera: atoms.chain
+ * ChimeraX: chain:atoms
+ */
+ String atomsAndChain = spec.substring(modelSeparatorPos + 1);
+ String[] tokens = atomsAndChain.split("\\:");
+ String atoms = tokens.length == 1 ? atomsAndChain : (tokens[1]);
+ int resNum = 0;
+ try
+ {
+ resNum = Integer.parseInt(atoms);
+ } catch (NumberFormatException e)
+ {
+ // could be a range e.g. #1:4-7.B
+ throw new IllegalArgumentException(spec);
+ }
+
+ String chainId = tokens.length == 1 ? "" : (tokens[0]);
+
+ return new AtomSpec(modelId, chainId, resNum, 0);
+ }
}
// default does nothing, override where this is implemented
return null;
}
+
+ @Override
+ public List<StructureCommandI> startNotifications(String uri)
+ {
+ return null;
+ }
+
+ @Override
+ public List<StructureCommandI> stopNotifications()
+ {
+ return null;
+ }
+
+ @Override
+ public StructureCommandI getSelectedResidues()
+ {
+ return null;
+ }
}
/**
* Returns a command to ask the viewer to close down
+ *
* @return
*/
StructureCommandI closeViewer();
+
+ /**
+ * Returns one or more commands to ask the viewer to notify model or selection
+ * changes to the given uri. Returns null if this is not supported by the
+ * structure viewer.
+ *
+ * @param uri
+ * @return
+ */
+ List<StructureCommandI> startNotifications(String uri);
+
+ /**
+ * Returns one or more commands to ask the viewer to stop notifying model or
+ * selection changes. Returns null if this is not supported by the structure
+ * viewer.
+ *
+ * @return
+ */
+ List<StructureCommandI> stopNotifications();
+
+ /**
+ * Returns a command to ask the viewer for its current residue selection, or
+ * null if no such command is supported
+ *
+ * @return
+ */
+ StructureCommandI getSelectedResidues();
}
externalViewerMonitor = null;
}
+ stopListening();
+
if (forceClose)
{
StructureCommandI cmd = getCommandGenerator().closeViewer();
});
externalViewerMonitor.start();
}
+
+ /**
+ * If supported by the external structure viewer, sends it commands to notify
+ * model or selection changes to the specified URL (where Jalview has started
+ * a listener)
+ *
+ * @param uri
+ */
+ protected void startListening(String uri)
+ {
+ List<StructureCommandI> commands = getCommandGenerator()
+ .startNotifications(uri);
+ if (commands != null)
+ {
+ executeCommands(commands, false, null);
+ }
+ }
+
+ /**
+ * If supported by the external structure viewer, sends it commands to stop
+ * notifying model or selection changes
+ */
+ protected void stopListening()
+ {
+ List<StructureCommandI> commands = getCommandGenerator()
+ .stopNotifications();
+ if (commands != null)
+ {
+ executeCommands(commands, false, null);
+ }
+ }
}
"p.jv_side_chain_binding_='<html>metal <a href=\"http:a.b.c/x\"> 'ion!'");
assertEquals(commands.get(0), expected3);
}
+
+ @Test(groups = "Functional")
+ public void testCloseViewer()
+ {
+ assertEquals(testee.closeViewer(), new StructureCommand("quit"));
+ }
}
import org.testng.annotations.Test;
import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommand;
import jalview.structure.StructureCommandI;
public class ChimeraCommandsTest
assertEquals(testee.setAttribute("jv_kd", "27.3", model).getCommand(),
"setattr res jv_kd '27.3' #1:89-92.A|#2:8-9.B,12-20.B");
}
+
+ @Test(groups = "Functional")
+ public void testCloseViewer()
+ {
+ assertEquals(testee.closeViewer(), new StructureCommand("stop really"));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetSelectedResidues()
+ {
+ assertEquals(testee.getSelectedResidues(),
+ new StructureCommand("list selection level residue"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStartNotifications()
+ {
+ List<StructureCommandI> cmds = testee.startNotifications("to here");
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("listen start models url to here"));
+ assertEquals(cmds.get(1), new StructureCommand("listen start select prefix SelectionChanged url to here"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStopNotifications()
+ {
+ List<StructureCommandI> cmds = testee.stopNotifications();
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("listen stop models"));
+ assertEquals(cmds.get(1), new StructureCommand("listen stop selection"));
+ }
}
import org.testng.annotations.Test;
import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommand;
import jalview.structure.StructureCommandI;
public class ChimeraXCommandsTest
.getCommand(),
"setattr #1/A:89-92|#2/B:8-9,12-20 res jv_kd '27.3' create true");
}
+
+ @Test(groups = "Functional")
+ public void testCloseViewer()
+ {
+ assertEquals(testee.closeViewer(), new StructureCommand("exit"));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetSelectedResidues()
+ {
+ assertEquals(testee.getSelectedResidues(),
+ new StructureCommand("info selection level residue"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStartNotifications()
+ {
+ List<StructureCommandI> cmds = testee.startNotifications("to here");
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("info notify start models prefix ModelChanged jalview url to here"));
+ assertEquals(cmds.get(1), new StructureCommand("info notify start selection jalview prefix SelectionChanged url to here"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStopNotifications()
+ {
+ List<StructureCommandI> cmds = testee.stopNotifications();
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("info notify stop models jalview"));
+ assertEquals(cmds.get(1), new StructureCommand("info notify stop selection jalview"));
+ }
}
public class AtomSpecTest
{
@Test
- public void testFromChimeraAtomSpec_chimera()
+ public void testFromChimeraAtomSpec()
{
- AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B", false);
+ AtomSpec as = AtomSpec.fromChimeraAtomspec("#1:12.B");
assertEquals(as.getModelNumber(), 1);
assertEquals(as.getPdbResNum(), 12);
assertEquals(as.getChain(), "B");
assertNull(as.getPdbFile());
// no model - default to zero
- as = AtomSpec.fromChimeraAtomspec(":13.C", false);
+ as = AtomSpec.fromChimeraAtomspec(":13.C");
assertEquals(as.getModelNumber(), 0);
assertEquals(as.getPdbResNum(), 13);
assertEquals(as.getChain(), "C");
assertNull(as.getPdbFile());
// model.submodel
- as = AtomSpec.fromChimeraAtomspec("#3.2:15", false);
+ as = AtomSpec.fromChimeraAtomspec("#3.2:15");
assertEquals(as.getModelNumber(), 3);
assertEquals(as.getPdbResNum(), 15);
assertEquals(as.getChain(), "");
String spec = "3:12.B";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, false);
+ as = AtomSpec.fromChimeraAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = "#3:12-14.B";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, false);
+ as = AtomSpec.fromChimeraAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = "";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, false);
+ as = AtomSpec.fromChimeraAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = null;
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, false);
+ as = AtomSpec.fromChimeraAtomspec(spec);
fail("Expected exception for " + spec);
} catch (NullPointerException e)
{
}
@Test
- public void testFromChimeraAtomSpec_chimeraX()
+ public void testFromChimeraXAtomSpec()
{
- AtomSpec as = AtomSpec.fromChimeraAtomspec("#1/B:12", true);
+ AtomSpec as = AtomSpec.fromChimeraXAtomspec("#1/B:12");
assertEquals(as.getModelNumber(), 1);
assertEquals(as.getPdbResNum(), 12);
assertEquals(as.getChain(), "B");
assertNull(as.getPdbFile());
// no model - default to zero
- as = AtomSpec.fromChimeraAtomspec("/C:13", true);
+ as = AtomSpec.fromChimeraXAtomspec("/C:13");
assertEquals(as.getModelNumber(), 0);
assertEquals(as.getPdbResNum(), 13);
assertEquals(as.getChain(), "C");
assertNull(as.getPdbFile());
// model.submodel
- as = AtomSpec.fromChimeraAtomspec("#3.2/:15", true);
+ as = AtomSpec.fromChimeraXAtomspec("#3.2/:15");
assertEquals(as.getModelNumber(), 3);
assertEquals(as.getPdbResNum(), 15);
assertEquals(as.getChain(), "");
String spec = "3:12.B";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, true);
+ as = AtomSpec.fromChimeraXAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = "#3:12-14.B";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, true);
+ as = AtomSpec.fromChimeraXAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = "";
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, true);
+ as = AtomSpec.fromChimeraXAtomspec(spec);
fail("Expected exception for " + spec);
} catch (IllegalArgumentException e)
{
spec = null;
try
{
- as = AtomSpec.fromChimeraAtomspec(spec, true);
+ as = AtomSpec.fromChimeraXAtomspec(spec);
fail("Expected exception for " + spec);
} catch (NullPointerException e)
{