import jalview.structure.AtomSpecModel;
import jalview.structure.StructureCommand;
import jalview.structure.StructureCommandI;
-import jalview.util.ColorUtils;
+import jalview.structure.StructureCommandsI.AtomSpecType;
/**
* Routines for generating ChimeraX commands for Jalview/ChimeraX binding
*/
public class ChimeraXCommands extends ChimeraCommands
{
- private static final StructureCommand CLOSE_CHIMERAX = new StructureCommand("exit");
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#resattr
+ private static final StructureCommand LIST_RESIDUE_ATTRIBUTES = new StructureCommand(
+ "info resattr");
- private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand("info notify stop selection jalview");
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/exit.html
+ private static final StructureCommand CLOSE_CHIMERAX = new StructureCommand(
+ "exit");
- private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand("info notify stop models jalview");
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify
+ private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand(
+ "info notify stop selection jalview");
- private static final StructureCommand GET_SELECTION = new StructureCommand("info selection level residue");
+ private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand(
+ "info notify stop models jalview");
+
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#selection
+ 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");
+ // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/view.html
private static final StructureCommand FOCUS_VIEW = new StructureCommand(
"view");
@Override
public StructureCommandI focusView()
{
- // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/view.html
return FOCUS_VIEW;
}
String attributeValue, AtomSpecModel atomSpecModel)
{
StringBuilder sb = new StringBuilder(128);
- sb.append("setattr ").append(getAtomSpec(atomSpecModel, false));
+ sb.append("setattr ")
+ .append(getAtomSpec(atomSpecModel, AtomSpecType.RESIDUE_ONLY));
sb.append(" res ").append(attributeName).append(" '")
.append(attributeValue).append("'");
sb.append(" create true");
* Returns the range(s) formatted as a ChimeraX atomspec, for example
* <p>
* #1/A:2-20,30-40/B:10-20|#2/A:12-30
+ * <p>
+ * Note there is no need to explicitly exclude ALTLOC atoms when
+ * {@code alphaOnly == true}, as this is the default behaviour of ChimeraX (a
+ * change from Chimera)
*
* @return
*/
@Override
- public String getAtomSpec(AtomSpecModel atomSpec, boolean alphaOnly)
+ public String getAtomSpec(AtomSpecModel atomSpec, AtomSpecType specType)
{
StringBuilder sb = new StringBuilder(128);
boolean firstModel = true;
}
firstModel = false;
appendModel(sb, model, atomSpec);
- if (alphaOnly)
+ if (specType == AtomSpecType.ALPHA)
{
- // TODO @P if RNA - add nucleotide flag to AtomSpecModel?
sb.append("@CA");
}
- // todo: is there ChimeraX syntax to exclude altlocs?
+ if (specType == AtomSpecType.PHOSPHATE)
+ {
+ sb.append("@P");
+ }
}
return sb.toString();
}
@Override
public List<StructureCommandI> superposeStructures(AtomSpecModel ref,
- AtomSpecModel spec)
+ AtomSpecModel spec, AtomSpecType backbone)
{
/*
* Form ChimeraX match command to match spec to ref
* @see https://www.cgl.ucsf.edu/chimerax/docs/user/commands/align.html
*/
StringBuilder cmd = new StringBuilder();
- String atomSpec = getAtomSpec(spec, true);
- String refSpec = getAtomSpec(ref, true);
+ String atomSpec = getAtomSpec(spec, backbone);
+ String refSpec = getAtomSpec(ref, backbone);
cmd.append("align ").append(atomSpec).append(" toAtoms ")
.append(refSpec);
* show superposed residues as ribbon, others as chain
*/
cmd.append("; ribbon ");
- cmd.append(getAtomSpec(spec, false)).append("|");
- cmd.append(getAtomSpec(ref, false)).append("; view");
+ cmd.append(getAtomSpec(spec, AtomSpecType.RESIDUE_ONLY)).append("|");
+ cmd.append(getAtomSpec(ref, AtomSpecType.RESIDUE_ONLY))
+ .append("; view");
return Arrays.asList(new StructureCommand(cmd.toString()));
}
@Override
public StructureCommandI closeViewer()
{
- // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/exit.html
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));
+ cmds.add(new StructureCommand(
+ "info notify start models jalview prefix ModelChanged 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 GET_SELECTION;
}
+
+ @Override
+ public StructureCommandI listResidueAttributes()
+ {
+ return LIST_RESIDUE_ATTRIBUTES;
+ }
}