X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fpymol%2FPymolCommands.java;h=e4f9f5f8d27911efec4a26791c70e98e05898071;hb=27f24d1f14b8e8704d72797286f7a6e5f60b2119;hp=16386440f5c662b77beacf51ec2fc7cde8e5f83e;hpb=42f4227ed213d422a87d3b22fc9e85d14ffaf53f;p=jalview.git diff --git a/src/jalview/ext/pymol/PymolCommands.java b/src/jalview/ext/pymol/PymolCommands.java index 1638644..e4f9f5f 100644 --- a/src/jalview/ext/pymol/PymolCommands.java +++ b/src/jalview/ext/pymol/PymolCommands.java @@ -1,28 +1,29 @@ package jalview.ext.pymol; +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import jalview.structure.AtomSpecModel; import jalview.structure.StructureCommand; import jalview.structure.StructureCommandI; import jalview.structure.StructureCommandsBase; -import java.awt.Color; -import java.util.ArrayList; -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. + *

+ * 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 COLOR_BY_CHARGE = new ArrayList<>(); private static final List SHOW_BACKBONE = new ArrayList<>(); @@ -33,7 +34,8 @@ public class PymolCommands extends StructureCommandsBase .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")); } @@ -41,8 +43,6 @@ public class PymolCommands extends StructureCommandsBase @Override public StructureCommandI colourByChain() { - // https://pymolwiki.org/index.php/CBC - // TODO this doesn't execute as an xml-rpc command return COLOUR_BY_CHAIN; } @@ -120,9 +120,8 @@ public class PymolCommands extends StructureCommandsBase @Override public StructureCommandI openCommandFile(String path) { - // where is this documented by PyMol? - // todo : xml-rpc answers 'method "@" is not supported' - return new StructureCommand("@" + path); // should be .pml + // https://pymolwiki.org/index.php/Run + return new StructureCommand("run", path); // should be .pml } @Override @@ -211,4 +210,27 @@ public class PymolCommands extends StructureCommandsBase return new StructureCommand("load", file); } + /** + * Overrides the default implementation (which generates concatenated + * commands) to generate one per colour (because the XML-RPC interface to + * PyMOL only accepts one command at a time) + * + * @param colourMap + * @return + */ + @Override + public List colourBySequence( + Map colourMap) + { + List commands = new ArrayList<>(); + for (Object key : colourMap.keySet()) + { + Color colour = (Color) key; + final AtomSpecModel colourData = colourMap.get(colour); + commands.add(getColourCommand(colourData, colour)); + } + + return commands; + } + }