X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FChimeraCommands.java;h=bfad8fb7e1dee597505a432f184cceff622d6646;hb=0b6e9403e96ee9f0d41211b2f90130ff850c4e98;hp=d3c8c0950b4f7def85e5d0f226edbdb3baedd718;hpb=e92de6ab4f67f594f4ff1e1abeecdb8ac94d5420;p=jalview.git
diff --git a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
index d3c8c09..bfad8fb 100644
--- a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
+++ b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
@@ -20,19 +20,19 @@
*/
package jalview.ext.rbvi.chimera;
-import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
-import jalview.api.structures.JalviewStructureDisplayI;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureMappingcommandSet;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.Format;
+import java.util.Locale;
import java.awt.Color;
import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.Arrays;
+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 jalview.util.ColorUtils;
/**
* Routines for generating Chimera commands for Jalview/Chimera binding
@@ -40,119 +40,409 @@ import java.util.Hashtable;
* @author JimP
*
*/
-public class ChimeraCommands
+public class ChimeraCommands extends StructureCommandsBase
{
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/focus.html
+ private static final StructureCommand FOCUS_VIEW = new StructureCommand("focus");
+
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/listen.html#listresattr
+ private static final StructureCommand LIST_RESIDUE_ATTRIBUTES = new StructureCommand("list resattr");
+
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/stop.html
+ private static final StructureCommand CLOSE_CHIMERA = new StructureCommand("stop really");
+
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/listen.html
+ private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand("listen stop selection");
+
+ private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand("listen stop models");
+
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/listen.html#listselection
+ 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");
+
+ private static final StructureCommandI COLOUR_BY_CHARGE = new StructureCommand(
+ "color white;color red ::ASP,GLU;color blue ::LYS,ARG;color yellow ::CYS");
+
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/rainbow.html
+ private static final StructureCommandI COLOUR_BY_CHAIN = new StructureCommand(
+ "rainbow chain");
+
+ // Chimera clause to exclude alternate locations in atom selection
+ private static final String NO_ALTLOCS = "&~@.B-Z&~@.2-9";
+
+ @Override
+ public StructureCommandI colourResidues(String atomSpec, Color colour)
+ {
+ // https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/color.html
+ String colourCode = getColourString(colour);
+ return new StructureCommand("color " + colourCode + " " + atomSpec);
+ }
+
+ /**
+ * Returns a colour formatted suitable for use in viewer command syntax
+ *
+ * @param colour
+ * @return
+ */
+ protected String getColourString(Color colour)
+ {
+ return ColorUtils.toTkCode(colour);
+ }
/**
- * utility to construct the commands to colour chains by the given alignment
- * for passing to Chimera
+ * Traverse the map of features/values/models/chains/positions to construct a
+ * list of 'setattr' commands (one per distinct feature type and value).
+ *
+ * The format of each command is
*
- * @returns Object[] { Object[] { ,
+ *
+ * setattr r " " #modelnumber:range.chain
+ * e.g. setattr r jv_chain <value> #0:2.B,4.B,9-12.B|#1:1.A,2-6.A,...
+ *
+ *
*
+ * @param featureMap
+ * @return
*/
- public static StructureMappingcommandSet[] getColourBySequenceCommand(
- StructureSelectionManager ssm, String[] files,
- SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr,
- AlignmentI alignment)
+ @Override
+ public List setAttributes(
+ Map> featureMap)
{
+ List commands = new ArrayList<>();
+ for (String featureType : featureMap.keySet())
+ {
+ String attributeName = makeAttributeName(featureType);
+
+ /*
+ * clear down existing attributes for this feature
+ */
+ // 'problem' - sets attribute to None on all residues - overkill?
+ // commands.add("~setattr r " + attributeName + " :*");
+
+ Map