X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FChimeraCommands.java;h=d3dd6250a3e51a7c13383c13dee4954b2d6f109e;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=507837d26d45426d686e9dcbce8455318059d6c4;hpb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;p=jalview.git
diff --git a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java
index 507837d..d3dd625 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.9.0b2)
- * Copyright (C) 2015 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,22 +20,20 @@
*/
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.util.Locale;
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.TreeMap;
+
+import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommand;
+import jalview.structure.StructureCommandI;
+import jalview.structure.StructureCommandsBase;
+import jalview.structure.StructureCommandsI.AtomSpecType;
+import jalview.util.ColorUtils;
/**
* Routines for generating Chimera commands for Jalview/Chimera binding
@@ -43,251 +41,419 @@ import java.util.TreeMap;
* @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)
{
- 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