import java.util.List;
/**
- * A class that generates commands to send to PyMol
+ * A class that generates commands to send to PyMol over its XML-RPC interface.
+ * <p>
+ * Note that because the xml-rpc interface can only accept one command at a
+ * time, we can't concatenate commands, and must instead form and send them
+ * individually.
*
* @see https://pymolwiki.org/index.php/Category:Commands
+ * @see https://pymolwiki.org/index.php/RPC
*/
public class PymolCommands extends StructureCommandsBase
{
- private static final StructureCommandI COLOUR_BY_CHAIN = new StructureCommand(
- "util.cbc");
+ private static final StructureCommand COLOUR_BY_CHAIN = new StructureCommand("spectrum", "chain");
- /*
- * because the xml-rpc interface can only accept one command at a time, we can't
- * concatenate commands and must instead form and send them individually
- */
private static final List<StructureCommandI> COLOR_BY_CHARGE = new ArrayList<>();
private static final List<StructureCommandI> SHOW_BACKBONE = new ArrayList<>();
.add(new StructureCommand("color", "red", "resn ASP resn GLU"));
COLOR_BY_CHARGE.add(
new StructureCommand("color", "blue", "resn LYS resn ARG"));
- COLOR_BY_CHARGE.add(new StructureCommand("color"));
+ COLOR_BY_CHARGE
+ .add(new StructureCommand("color", "yellow", "resn CYS"));
SHOW_BACKBONE.add(new StructureCommand("hide", "everything"));
SHOW_BACKBONE.add(new StructureCommand("show", "ribbon"));
}
@Override
public StructureCommandI colourByChain()
{
- // https://pymolwiki.org/index.php/CBC
- // TODO this doesn't execute as an xml-rpc command
return COLOUR_BY_CHAIN;
}
}
@Test(groups = "Functional")
+ public void testColourByCharge()
+ {
+ PymolCommands testee = new PymolCommands();
+ List<StructureCommandI> cmds = testee.colourByCharge();
+ assertEquals(cmds.size(), 4);
+ assertEquals(cmds.get(0).toString(), "color(white,*)");
+ assertEquals(cmds.get(1).toString(), "color(red,resn ASP resn GLU)");
+ assertEquals(cmds.get(2).toString(), "color(blue,resn LYS resn ARG)");
+ assertEquals(cmds.get(3).toString(), "color(yellow,resn CYS)");
+ }
+
+ @Test(groups = "Functional")
public void testOpenCommandFile()
{
PymolCommands testee = new PymolCommands();
}
@Test(groups = "Functional")
+ public void testColourByChain()
+ {
+ PymolCommands testee = new PymolCommands();
+ assertEquals(testee.colourByChain().toString(), "spectrum(chain)");
+ }
+
+ @Test(groups = "Functional")
public void testGetColourCommand()
{
PymolCommands testee = new PymolCommands();