JAL-3551 tidying, improved commands, fix Jmol model number derivation
[jalview.git] / src / jalview / structure / StructureCommandsI.java
index eda5aa9..8725b3d 100644 (file)
@@ -1,7 +1,6 @@
 package jalview.structure;
 
 import jalview.api.AlignmentViewPanel;
-import jalview.api.SequenceRenderer;
 import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
@@ -17,13 +16,12 @@ import java.util.Map;
  */
 public interface StructureCommandsI
 {
-
   /**
    * Returns the command to colour by chain
    * 
    * @return
    */
-  String colourByChain();
+  StructureCommandI colourByChain();
 
   /**
    * Returns the command to colour residues using a charge-based scheme:
@@ -36,7 +34,7 @@ public interface StructureCommandsI
    * 
    * @return
    */
-  String colourByCharge();
+  List<StructureCommandI> colourByCharge();
 
   /**
    * Returns the command to colour residues with the colours provided in the
@@ -45,7 +43,7 @@ public interface StructureCommandsI
    * @param colours
    * @return
    */
-  String colourByResidues(Map<String, Color> colours);
+  List<StructureCommandI> colourByResidues(Map<String, Color> colours);
 
   /**
    * Returns the command to set the background colour of the structure viewer
@@ -53,39 +51,35 @@ public interface StructureCommandsI
    * @param col
    * @return
    */
-  String setBackgroundColour(Color col);
+  StructureCommandI setBackgroundColour(Color col);
 
   /**
    * Returns commands to colour mapped residues of structures according to
-   * Jalview's colouring (including feature colouring if applied)
+   * Jalview's colouring (including feature colouring if applied). Parameter is
+   * a map from Color to a model of all residues assigned that colour.
    * 
-   * @param structureSelectionManager
-   * @param files
-   * @param seqs
-   * @param sr
-   * @param alignmentv
+   * @param colourMap
    * @return
    */
-  String[] colourBySequence(
-          StructureSelectionManager structureSelectionManager,
-          String[] files, SequenceI[][] seqs, SequenceRenderer sr,
-          AlignmentViewPanel alignmentv);
+
+  List<StructureCommandI> colourBySequence(
+          Map<Object, AtomSpecModel> colourMap);
 
   /**
    * Returns a command to centre the display in the structure viewer
    * 
    * @return
    */
-  String focusView();
+  StructureCommandI focusView();
 
   /**
    * Returns a command to show only the selected chains. The items in the input
-   * list should be formatted as "modelno:chainid".
+   * list should be formatted as "modelid:chainid".
    * 
    * @param toShow
    * @return
    */
-  String showChains(List<String> toShow);
+  List<StructureCommandI> showChains(List<String> toShow);
 
   /**
    * Returns zero, one or more commands to set attributes on mapped residues in
@@ -97,7 +91,75 @@ public interface StructureCommandsI
    * @param avp
    * @return
    */
-  String[] setAttributesForFeatures(StructureSelectionManager ssm,
+  List<StructureCommandI> setAttributesForFeatures(
+          StructureSelectionManager ssm,
           String[] files, SequenceI[][] sequence, AlignmentViewPanel avp);
 
+  /**
+   * Returns a command to superpose structures by closest positioning of
+   * residues in {@code atomSpec} to the corresponding residues in
+   * {@code refAtoms}. If wanted, this may include commands to visually
+   * highlight the residues that were used for the superposition.
+   * 
+   * @param refAtoms
+   * @param atomSpec
+   * @return
+   */
+  List<StructureCommandI> superposeStructures(AtomSpecModel refAtoms,
+          AtomSpecModel atomSpec);
+
+  /**
+   * Returns a command to open a file of commands at the given path
+   * 
+   * @param path
+   * @return
+   */
+  StructureCommandI openCommandFile(String path);
+
+  /**
+   * Returns a command to save the current viewer session state to the given
+   * file
+   * 
+   * @param filepath
+   * @return
+   */
+  StructureCommandI saveSession(String filepath);
+
+  /**
+   * Returns a representation of the atom set represented by the model, in
+   * viewer syntax format. If {@code alphaOnly} is true, this is restricted to
+   * Alpha Carbon (peptide) or Phosphorous (rna) only
+   * 
+   * @param model
+   * @param alphaOnly
+   * @return
+   */
+  String getAtomSpec(AtomSpecModel model, boolean alphaOnly);
+
+  /**
+   * Returns the lowest model number used by the structure viewer (likely 0 or
+   * 1)
+   * 
+   * @return
+   */
+  // TODO remove by refactoring so command generation is purely driven by
+  // AtomSpecModel objects derived in the binding classes?
+  int getModelStartNo();
+
+  /**
+   * Returns command(s) to show only the backbone of the peptide (cartoons in
+   * Jmol, chain in Chimera)
+   * 
+   * @return
+   */
+  List<StructureCommandI> showBackbone();
+
+  /**
+   * Returns a command to open a file at the given path
+   * 
+   * @param file
+   * @return
+   */
+  // refactor if needed to distinguish loading data or session files
+  StructureCommandI loadFile(String file);
 }