X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FChimeraCommands.java;h=5beee568eb8397fb3fea1121c9d9d8e5407bcaaa;hb=c38d37887ae51d63942ac4321f6769308188ed6b;hp=8f6b2f14eaf1a2bf1bd9c966211924142ed4aa0f;hpb=b0cee3aaf7d8873910939f97b6acb217d518968d;p=jalview.git
diff --git a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
index 8f6b2f1..5beee56 100644
--- a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
+++ b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
@@ -20,23 +20,17 @@
*/
package jalview.ext.rbvi.chimera;
-import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureMappingcommandSet;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.ColorUtils;
-import jalview.util.Comparison;
-
import java.awt.Color;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
+
+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
@@ -44,251 +38,372 @@ import java.util.TreeMap;
* @author JimP
*
*/
-public class ChimeraCommands
+public class ChimeraCommands extends StructureCommandsBase
{
+ 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");
+
+ 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)
{
- Map>>> colourMap = buildColoursMap(
- ssm, files, sequence, sr, fr, alignment);
+ List commands = new ArrayList<>();
+ for (String featureType : featureMap.keySet())
+ {
+ String attributeName = makeAttributeName(featureType);
- List colourCommands = buildColourCommands(colourMap);
+ /*
+ * clear down existing attributes for this feature
+ */
+ // 'problem' - sets attribute to None on all residues - overkill?
+ // commands.add("~setattr r " + attributeName + " :*");
- StructureMappingcommandSet cs = new StructureMappingcommandSet(
- ChimeraCommands.class, null,
- colourCommands.toArray(new String[0]));
+ Map