X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Frbvi%2Fchimera%2FChimeraCommands.java;h=6d4caa220bb32d991fc3b65da2a6a574dc046ce6;hb=f9062df1303c1ff071075256cf4b7ad7c9db9658;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..6d4caa2 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,20 @@ */ 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.structure.StructureCommandsI.AtomSpecType; +import jalview.util.ColorUtils; /** * Routines for generating Chimera commands for Jalview/Chimera binding @@ -40,119 +41,412 @@ 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); + } + + /** + * 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 + * + *
+ *+ * + * @param featureMap + * @return + */ + @Override + public Listsetattr 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,... + *