X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FChimeraXCommands.java;h=f1a8b5fd64051001d6ba4c634d1aba63c3d2385b;hb=4994aa94fd62af0058f2db96f0ea6c4ca1abe80b;hp=9636a6a2a089fb9c8e4f7b24e1625217ccd59637;hpb=42f4227ed213d422a87d3b22fc9e85d14ffaf53f;p=jalview.git diff --git a/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java index 9636a6a..f1a8b5f 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java @@ -20,22 +20,31 @@ */ package jalview.ext.rbvi.chimera; +import java.awt.Color; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import jalview.structure.AtomSpecModel; import jalview.structure.StructureCommand; import jalview.structure.StructureCommandI; import jalview.util.ColorUtils; -import java.awt.Color; -import java.util.Arrays; -import java.util.List; - /** * Routines for generating ChimeraX commands for Jalview/ChimeraX binding */ 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;show @CA|P pbonds"); + "~display all;~ribbon;show @CA|P atoms"); private static final StructureCommand FOCUS_VIEW = new StructureCommand( "view"); @@ -56,14 +65,7 @@ public class ChimeraXCommands extends ChimeraCommands } @Override - public StructureCommandI setBackgroundColour(Color col) - { - // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/set.html - return new StructureCommand("set bgColor " + ColorUtils.toTkCode(col)); - } - - @Override - public StructureCommandI getColourCommand(String atomSpec, Color colour) + public StructureCommandI colourResidues(String atomSpec, Color colour) { // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/color.html String colourCode = getColourString(colour); @@ -125,7 +127,8 @@ public class ChimeraXCommands extends ChimeraCommands public StructureCommandI saveSession(String filepath) { // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html - return new StructureCommand("save session " + filepath); + // note ChimeraX will append ".cxs" to the filepath! + return new StructureCommand("save " + filepath + " format session"); } /** @@ -150,7 +153,8 @@ public class ChimeraXCommands extends ChimeraCommands appendModel(sb, model, atomSpec); if (alphaOnly) { - sb.append("@CA|P"); + // TODO @P if RNA - add nucleotide flag to AtomSpecModel? + sb.append("@CA"); } // todo: is there ChimeraX syntax to exclude altlocs? } @@ -195,16 +199,15 @@ public class ChimeraXCommands extends ChimeraCommands } @Override - public List superposeStructures(AtomSpecModel spec, - AtomSpecModel ref) + public List superposeStructures(AtomSpecModel ref, + AtomSpecModel spec) { /* * Form ChimeraX match command to match spec to ref * * match #1/A:2-94 toAtoms #2/A:1-93 * - * @see - * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html + * @see https://www.cgl.ucsf.edu/chimerax/docs/user/commands/align.html */ StringBuilder cmd = new StringBuilder(); String atomSpec = getAtomSpec(spec, true); @@ -222,4 +225,44 @@ public class ChimeraXCommands extends ChimeraCommands return Arrays.asList(new StructureCommand(cmd.toString())); } + @Override + public StructureCommandI openSession(String filepath) + { + // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html#composite + // this version of the command has no dependency on file extension + return new StructureCommand("open " + filepath + " format session"); + } + + @Override + public StructureCommandI closeViewer() + { + // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/exit.html + return CLOSE_CHIMERAX; + } + + @Override + public List startNotifications(String uri) + { + // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify + List 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 stopNotifications() + { + // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify + List cmds = new ArrayList<>(); + cmds.add(STOP_NOTIFY_MODELS); + cmds.add(STOP_NOTIFY_SELECTION); + return cmds; + } + + @Override + public StructureCommandI getSelectedResidues() + { + return GET_SELECTION; + } }