From: gmungoc Date: Tue, 6 Aug 2019 18:58:27 +0000 (+0100) Subject: JAL-3390 first pass refactoring for JalviewJmolBinding.showStructures X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6bf5604d306cbcd55289639967411ddbafcac682;hp=2d62933ef95beb94c1ec2444bcced4a3a7ec42c0;p=jalview.git JAL-3390 first pass refactoring for JalviewJmolBinding.showStructures --- diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index f5ab595..1ac3abc 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -549,7 +549,7 @@ public class AppletJmol extends EmbmenuFrame implements else if (evt.getSource() == seqColour) { setEnabled(seqColour); - jmb.colourBySequence(ap); + jmb.updateStructureColours(ap); } else if (!allChainsSelected) { @@ -582,7 +582,7 @@ public class AppletJmol extends EmbmenuFrame implements public void updateColours(Object source) { AlignmentPanel panel = (AlignmentPanel) source; - jmb.colourBySequence(panel); + jmb.updateStructureColours(panel); } public void updateTitleAndMenus() @@ -593,7 +593,7 @@ public class AppletJmol extends EmbmenuFrame implements return; } setChainMenuItems(jmb.getChainNames()); - jmb.colourBySequence(ap); + jmb.updateStructureColours(ap); setTitle(jmb.getViewerTitle()); } diff --git a/src/jalview/appletgui/AppletJmolBinding.java b/src/jalview/appletgui/AppletJmolBinding.java index e5767b6..f880eea 100644 --- a/src/jalview/appletgui/AppletJmolBinding.java +++ b/src/jalview/appletgui/AppletJmolBinding.java @@ -102,7 +102,7 @@ class AppletJmolBinding extends JalviewJmolBinding public void updateColours(Object source) { AlignmentPanel ap = (AlignmentPanel) source; - colourBySequence(ap); + updateStructureColours(ap); } @Override diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index d317722..8cecf6e 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -27,13 +27,13 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; +import jalview.ext.rbvi.chimera.AtomSpecModel; import jalview.gui.IProgressIndicator; import jalview.io.DataSourceType; import jalview.io.StructureFile; import jalview.schemes.ColourSchemeI; import jalview.schemes.ResidueProperties; import jalview.structure.AtomSpec; -import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; @@ -476,14 +476,14 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } Thread colourby = null; + /** * Sends a set of colour commands to the structure viewer * - * @param colourBySequenceCommands + * @param commands */ @Override - protected void colourBySequence( - final StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(final String[] commands) { if (colourby != null) { @@ -495,12 +495,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @Override public void run() { - for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + for (String cmd : commands) { - for (String cbyseq : cpdbbyseq.commands) - { - executeWhenReady(cbyseq); - } + executeWhenReady(cmd); } } }); @@ -513,11 +510,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel * @return */ @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( + protected String[] getColourBySequenceCommands( String[] files, AlignmentViewPanel viewPanel) { - return JmolCommands.getColourBySequenceCommand(getSsm(), files, - this, viewPanel); + Map map = buildColoursMap(viewPanel); + + return JmolCommands.getColourBySequenceCommand(map); } /** @@ -1417,7 +1415,36 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @Override public void showStructures(AlignViewportI av, boolean refocus) { - // TODO show Jmol structure optionally restricted to visible alignment - // and/or selected chains + StringBuilder cmd = new StringBuilder(128); + + if (isShowAlignmentOnly()) + { + cmd.append("hide *;"); + + AtomSpecModel model = getShownResidues(av); + String atomSpec = JmolCommands.getAtomSpec(model); + + cmd.append("display ").append(atomSpec); + } + else + { + cmd.append("display *"); + } + cmd.append("; cartoon"); + if (refocus) + { + cmd.append("; zoom 100"); + } + evalStateCommand(cmd.toString()); + } + + /** + * Answers a Jmol syntax style structure model specification. Model number 0, 1, + * 2... is formatted as "1.1", "2.1", "3.1" etc. + */ + @Override + public String getModelSpec(int model) + { + return String.valueOf(model + 1) + ".1"; } } diff --git a/src/jalview/ext/jmol/JmolCommands.java b/src/jalview/ext/jmol/JmolCommands.java index c981165..e3625fa 100644 --- a/src/jalview/ext/jmol/JmolCommands.java +++ b/src/jalview/ext/jmol/JmolCommands.java @@ -27,6 +27,7 @@ import jalview.api.SequenceRenderer; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceI; +import jalview.ext.rbvi.chimera.AtomSpecModel; import jalview.renderer.seqfeatures.FeatureColourFinder; import jalview.structure.StructureMapping; import jalview.structure.StructureMappingcommandSet; @@ -36,6 +37,7 @@ import jalview.structures.models.AAStructureBindingModel; import java.awt.Color; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * Routines for generating Jmol commands for Jalview/Jmol binding another @@ -47,6 +49,8 @@ import java.util.List; public class JmolCommands { + private static final String COMMA = ","; + /** * Jmol utility which constructs the commands to colour chains by the given * alignment @@ -138,7 +142,7 @@ public class JmolCommands String newSelcom = (mapping[m].getChain() != " " ? ":" + mapping[m].getChain() : "") + "/" + (pdbfnum + 1) + ".1" + ";color[" - + col.getRed() + "," + col.getGreen() + "," + + col.getRed() + COMMA + col.getGreen() + COMMA + col.getBlue() + "]"; if (command.length() > newSelcom.length() && command .substring(command.length() - newSelcom.length()) @@ -217,4 +221,77 @@ public class JmolCommands return sb; } + /** + * Answers a Jmol 'color' command to colour residues as described by the given + * map of {@code } + * + * @param map + * @return + */ + public static String[] getColourBySequenceCommand( + Map map) + { + String[] cmds = new String[map.keySet().size()]; + + int i = 0; + for (Object o : map.keySet()) + { + StringBuilder cmd = new StringBuilder(128); + Color c = (Color) o; + String atomSpec = getAtomSpec(map.get(o)); + cmd.append("select ").append(atomSpec).append(";color[") + .append(c.getRed()).append(COMMA).append(c.getGreen()) + .append(COMMA).append(c.getBlue()).append("];"); + cmds[i] = cmd.toString(); + i++; + } + + return cmds; + } + + /** + * Builds a Jmol syntax selection expression from the given model, for example + * + *
+   * 61-64,70:A/1.1,12-25,41-44:B/1.1,12:A/2.1
+   * for model 1, chain A, residues 61-64 and 70, chain B residues 12-25 and 41-44, model 2 chain A residue 12
+   * 
+ * + * @param atomSpecModel + * @return + */ + public static String getAtomSpec(AtomSpecModel atomSpecModel) + { + StringBuilder sb = new StringBuilder(64); + for (int model : atomSpecModel.getModels()) + { + for (String chain : atomSpecModel.getChains(model)) + { + if (sb.length() > 0) + { + sb.append(COMMA); + } + boolean firstRange = true; + for (int[] range : atomSpecModel.getRanges(model, chain)) + { + if (!firstRange) + { + sb.append(COMMA); + } + firstRange = false; + sb.append(range[0]); + if (range[1] != range[0]) + { + sb.append("-").append(range[1]); + } + } + sb.append(":").append(chain).append("/") + .append(String.valueOf(model + 1)) + .append(".1"); + } + } + + return sb.toString(); + } + } diff --git a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java index c52b9a2..a6a72e0 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java @@ -65,31 +65,17 @@ public class ChimeraCommands /** * Constructs Chimera commands to colour residues as per the Jalview alignment * - * @param files - * @param viewPanel + * @param colourMap * @param binding * @return */ - public static StructureMappingcommandSet[] getColourBySequenceCommand( - String[] files, AlignmentViewPanel viewPanel, + public static String[] getColourBySequenceCommand( + Map colourMap, AAStructureBindingModel binding) { - StructureSelectionManager ssm = binding.getSsm(); - SequenceRenderer sr = binding.getSequenceRenderer(viewPanel); - SequenceI[][] sequence = binding.getSequence(); - boolean hideHiddenRegions = binding.isShowAlignmentOnly() - && binding.isHideHiddenRegions(); - - Map colourMap = buildColoursMap(ssm, files, - sequence, sr, hideHiddenRegions, viewPanel); - List colourCommands = buildColourCommands(colourMap, binding); - StructureMappingcommandSet cs = new StructureMappingcommandSet( - ChimeraCommands.class, null, - colourCommands.toArray(new String[colourCommands.size()])); - - return new StructureMappingcommandSet[] { cs }; + return colourCommands.toArray(new String[colourCommands.size()]); } /** @@ -234,7 +220,7 @@ public class ChimeraCommands { if (startPos != -1) { - addColourRange(colourMap, lastColour, pdbfnum, startPos, + addMapRange(colourMap, lastColour, pdbfnum, startPos, lastPos, lastChain); } startPos = pos; @@ -246,7 +232,7 @@ public class ChimeraCommands // final colour range if (lastColour != null) { - addColourRange(colourMap, lastColour, pdbfnum, startPos, + addMapRange(colourMap, lastColour, pdbfnum, startPos, lastPos, lastChain); } // break; @@ -258,7 +244,8 @@ public class ChimeraCommands } /** - * Helper method to add one contiguous colour range to the colour map. + * Helper method to add one contiguous range to the map, for a given value key + * (e.g. colour or feature type), structure model number, and chain * * @param map * @param key @@ -267,7 +254,7 @@ public class ChimeraCommands * @param endPos * @param chain */ - protected static void addColourRange(Map map, + public static void addMapRange(Map map, Object key, int model, int startPos, int endPos, String chain) { /* @@ -431,7 +418,7 @@ public class ChimeraCommands } for (int[] range : mappedRanges) { - addColourRange(featureValues, value, modelNumber, range[0], + addMapRange(featureValues, value, modelNumber, range[0], range[1], mapping.getChain()); } } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 44bcbe4..381bbea 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -650,32 +650,32 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /** * Sends a set of colour commands to the structure viewer * - * @param colourBySequenceCommands + * @param commands */ @Override - protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(String[] commands) { - for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands) + for (String command : commands) { - for (String command : cpdbbyseq.commands) - { - sendAsynchronousCommand(command, COLOURING_CHIMERA); - } + sendAsynchronousCommand(command, COLOURING_CHIMERA); } } /** + * Computes and returns a set of commands to colour residues in Chimera the same + * as mapped residues in the alignment + * * @param files * @param viewPanel * @return */ @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( + protected String[] getColourBySequenceCommands( String[] files, AlignmentViewPanel viewPanel) { - return ChimeraCommands.getColourBySequenceCommand(files, viewPanel, - this); + Map colourMap = buildColoursMap(viewPanel); + + return ChimeraCommands.getColourBySequenceCommand(colourMap, this); } /** diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 8eaeed2..2ffcee1 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -896,7 +896,7 @@ public abstract class StructureViewerBase extends GStructureViewer // Set the colour using the current view for the associated alignframe for (AlignmentViewPanel avp : _colourwith) { - binding.colourBySequence(avp); + binding.updateStructureColours(avp); } seqColoursApplied = true; } diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 7a89961..8eea16f 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -22,6 +22,7 @@ package jalview.structures.models; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; +import jalview.api.FeatureRenderer; import jalview.api.SequenceRenderer; import jalview.api.StructureSelectionManagerProvider; import jalview.api.structures.JalviewStructureDisplayI; @@ -30,12 +31,13 @@ import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.ext.rbvi.chimera.AtomSpecModel; +import jalview.ext.rbvi.chimera.ChimeraCommands; import jalview.io.DataSourceType; +import jalview.renderer.seqfeatures.FeatureColourFinder; import jalview.schemes.ColourSchemeI; import jalview.structure.AtomSpec; import jalview.structure.StructureListener; import jalview.structure.StructureMapping; -import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.util.Comparison; import jalview.util.MessageManager; @@ -46,7 +48,9 @@ import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * @@ -789,7 +793,7 @@ public abstract class AAStructureBindingModel public abstract void setBackgroundColour(Color col); - protected abstract StructureMappingcommandSet[] getColourBySequenceCommands( + protected abstract String[] getColourBySequenceCommands( String[] files, AlignmentViewPanel avp); /** @@ -804,7 +808,7 @@ public abstract class AAStructureBindingModel AlignmentViewPanel alignment); protected abstract void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands); + String[] colourBySequenceCommands); public abstract void colourByChain(); @@ -816,7 +820,7 @@ public abstract class AAStructureBindingModel * colours on either change of alignment colours, or change to the visible * region of the alignment. */ - public void colourBySequence(AlignmentViewPanel alignmentv) + public void updateStructureColours(AlignmentViewPanel alignmentv) { if (!isLoadingFinished()) { @@ -842,7 +846,7 @@ public abstract class AAStructureBindingModel } String[] files = getStructureFiles(); - StructureMappingcommandSet[] colourBySequenceCommands = getColourBySequenceCommands( + String[] colourBySequenceCommands = getColourBySequenceCommands( files, alignmentv); colourBySequence(colourBySequenceCommands); } @@ -926,7 +930,7 @@ public abstract class AAStructureBindingModel } if (!isLoadingFromArchive()) { - colourBySequence(ap); + updateStructureColours(ap); } } @@ -1050,4 +1054,124 @@ public abstract class AAStructureBindingModel { return String.valueOf(model); } + + /** + * Build a data structure which records contiguous subsequences for each colour. + * From this we can easily generate the Chimera command for colour by sequence. + * + *
+   * Color
+   *     Model number
+   *         Chain
+   *             list of start/end ranges
+   * 
+ * + * Ordering is by order of addition (for colours and positions), natural + * ordering (for models and chains) + * + * @param viewPanel + * @return + */ + protected Map buildColoursMap( + AlignmentViewPanel viewPanel) + { + FeatureRenderer fr = viewPanel.getFeatureRenderer(); + FeatureColourFinder finder = new FeatureColourFinder(fr); + AlignViewportI viewport = viewPanel.getAlignViewport(); + HiddenColumns cs = viewport.getAlignment().getHiddenColumns(); + AlignmentI al = viewport.getAlignment(); + SequenceRenderer sr = getSequenceRenderer(viewPanel); + String[] files = getStructureFiles(); + + Map colourMap = new LinkedHashMap<>(); + Color lastColour = null; + + for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) + { + StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); + + if (mapping == null || mapping.length < 1) + { + continue; + } + + int startPos = -1, lastPos = -1; + String lastChain = ""; + for (int s = 0; s < sequence[pdbfnum].length; s++) + { + for (int sp, m = 0; m < mapping.length; m++) + { + final SequenceI seq = sequence[pdbfnum][s]; + if (mapping[m].getSequence() == seq + && (sp = al.findIndex(seq)) > -1) + { + SequenceI asp = al.getSequenceAt(sp); + for (int r = 0; r < asp.getLength(); r++) + { + // no mapping to gaps in sequence + if (Comparison.isGap(asp.getCharAt(r))) + { + continue; + } + int pos = mapping[m].getPDBResNum(asp.findPosition(r)); + + if (pos < 1 || pos == lastPos) + { + continue; + } + + Color colour = sr.getResidueColour(seq, r, finder); + + /* + * hidden regions are shown gray or, optionally, ignored + */ + if (!cs.isVisible(r)) + { + if (hideHiddenRegions) + { + continue; + } + else + { + colour = Color.GRAY; + } + } + + final String chain = mapping[m].getChain(); + + /* + * Just keep incrementing the end position for this colour range + * _unless_ colour, PDB model or chain has changed, or there is a + * gap in the mapped residue sequence + */ + final boolean newColour = !colour.equals(lastColour); + final boolean nonContig = lastPos + 1 != pos; + final boolean newChain = !chain.equals(lastChain); + if (newColour || nonContig || newChain) + { + if (startPos != -1) + { + ChimeraCommands.addMapRange(colourMap, lastColour, + pdbfnum, startPos, + lastPos, lastChain); + } + startPos = pos; + } + lastColour = colour; + lastPos = pos; + lastChain = chain; + } + // final colour range + if (lastColour != null) + { + ChimeraCommands.addMapRange(colourMap, lastColour, pdbfnum, + startPos, lastPos, lastChain); + } + // break; + } + } + } + } + return colourMap; + } } diff --git a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java index 24ca6e9..6dd5cc7 100644 --- a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java +++ b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java @@ -38,7 +38,6 @@ import jalview.schemes.ColourSchemeI; import jalview.schemes.JalviewColourScheme; import jalview.structure.AtomSpec; import jalview.structure.StructureMapping; -import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; @@ -95,8 +94,8 @@ public class ChimeraCommandsTest } @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel avp) + protected String[] getColourBySequenceCommands(String[] files, + AlignmentViewPanel avp) { return null; } @@ -109,8 +108,7 @@ public class ChimeraCommandsTest } @Override - protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(String[] colourBySequenceCommands) { } @@ -155,15 +153,15 @@ public class ChimeraCommandsTest { Map map = new LinkedHashMap<>(); - ChimeraCommands.addColourRange(map, Color.blue, 0, 2, 5, "A"); - ChimeraCommands.addColourRange(map, Color.blue, 0, 7, 7, "B"); - ChimeraCommands.addColourRange(map, Color.blue, 0, 9, 23, "A"); - ChimeraCommands.addColourRange(map, Color.blue, 1, 1, 1, "A"); - ChimeraCommands.addColourRange(map, Color.blue, 1, 4, 7, "B"); - ChimeraCommands.addColourRange(map, Color.yellow, 1, 8, 8, "A"); - ChimeraCommands.addColourRange(map, Color.yellow, 1, 3, 5, "A"); - ChimeraCommands.addColourRange(map, Color.red, 0, 3, 5, "A"); - ChimeraCommands.addColourRange(map, Color.red, 0, 6, 9, "A"); + ChimeraCommands.addMapRange(map, Color.blue, 0, 2, 5, "A"); + ChimeraCommands.addMapRange(map, Color.blue, 0, 7, 7, "B"); + ChimeraCommands.addMapRange(map, Color.blue, 0, 9, 23, "A"); + ChimeraCommands.addMapRange(map, Color.blue, 1, 1, 1, "A"); + ChimeraCommands.addMapRange(map, Color.blue, 1, 4, 7, "B"); + ChimeraCommands.addMapRange(map, Color.yellow, 1, 8, 8, "A"); + ChimeraCommands.addMapRange(map, Color.yellow, 1, 3, 5, "A"); + ChimeraCommands.addMapRange(map, Color.red, 0, 3, 5, "A"); + ChimeraCommands.addMapRange(map, Color.red, 0, 6, 9, "A"); // Colours should appear in the Chimera command in the order in which // they were added; within colour, by model, by chain, ranges in start order @@ -188,7 +186,7 @@ public class ChimeraCommandsTest * start with just one feature/value... */ featuresMap.put("chain", featureValues); - ChimeraCommands.addColourRange(featureValues, "X", 0, 8, 20, "A"); + ChimeraCommands.addMapRange(featureValues, "X", 0, 8, 20, "A"); List commands = ChimeraCommands .buildSetAttributeCommands(featuresMap, mockBinding); @@ -201,18 +199,18 @@ public class ChimeraCommandsTest assertEquals(commands.get(0), "setattr r jv_chain 'X' #0:8-20.A"); // add same feature value, overlapping range - ChimeraCommands.addColourRange(featureValues, "X", 0, 3, 9, "A"); + ChimeraCommands.addMapRange(featureValues, "X", 0, 3, 9, "A"); // same feature value, contiguous range - ChimeraCommands.addColourRange(featureValues, "X", 0, 21, 25, "A"); + ChimeraCommands.addMapRange(featureValues, "X", 0, 21, 25, "A"); commands = ChimeraCommands.buildSetAttributeCommands(featuresMap, mockBinding); assertEquals(1, commands.size()); assertEquals(commands.get(0), "setattr r jv_chain 'X' #0:3-25.A"); // same feature value and model, different chain - ChimeraCommands.addColourRange(featureValues, "X", 0, 21, 25, "B"); + ChimeraCommands.addMapRange(featureValues, "X", 0, 21, 25, "B"); // same feature value and chain, different model - ChimeraCommands.addColourRange(featureValues, "X", 1, 26, 30, "A"); + ChimeraCommands.addMapRange(featureValues, "X", 1, 26, 30, "A"); commands = ChimeraCommands.buildSetAttributeCommands(featuresMap, mockBinding); assertEquals(1, commands.size()); @@ -220,7 +218,7 @@ public class ChimeraCommandsTest "setattr r jv_chain 'X' #0:3-25.A,21-25.B|#1:26-30.A"); // same feature, different value - ChimeraCommands.addColourRange(featureValues, "Y", 0, 40, 50, "A"); + ChimeraCommands.addMapRange(featureValues, "Y", 0, 40, 50, "A"); commands = ChimeraCommands.buildSetAttributeCommands(featuresMap, mockBinding); assertEquals(2, commands.size()); @@ -233,7 +231,7 @@ public class ChimeraCommandsTest featuresMap.clear(); featureValues.clear(); featuresMap.put("side-chain binding!", featureValues); - ChimeraCommands.addColourRange(featureValues, + ChimeraCommands.addMapRange(featureValues, "metal 'ion!", 0, 7, 15, "A"); // feature names are sanitised to change non-alphanumeric to underscore @@ -308,11 +306,10 @@ public class ChimeraCommandsTest PA.setValue(mockBinding, "ssm", ssm); PA.setValue(mockBinding, "sequence", seqs); - StructureMappingcommandSet[] commands = ChimeraCommands + String[] commands = ChimeraCommands .getColourBySequenceCommand(files, af.alignPanel, mockBinding); assertEquals(1, commands.length); - assertEquals(1, commands[0].commands.length); - String theCommand = commands[0].commands[0]; + String theCommand = commands[0]; // M colour is #82827d (see strand.html help page) assertTrue(theCommand.contains("color #82827d #0:21.A|#1:21.B")); // H colour is #60609f diff --git a/test/jalview/structures/models/AAStructureBindingModelTest.java b/test/jalview/structures/models/AAStructureBindingModelTest.java index dde7d14..ee155ac 100644 --- a/test/jalview/structures/models/AAStructureBindingModelTest.java +++ b/test/jalview/structures/models/AAStructureBindingModelTest.java @@ -39,7 +39,6 @@ import jalview.io.DataSourceType; import jalview.io.FileFormats; import jalview.schemes.ColourSchemeI; import jalview.structure.AtomSpec; -import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel.SuperposeData; @@ -201,8 +200,8 @@ public class AAStructureBindingModelTest } @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel avp) + protected String[] getColourBySequenceCommands(String[] files, + AlignmentViewPanel avp) { // TODO Auto-generated method stub return null; @@ -216,8 +215,7 @@ public class AAStructureBindingModelTest } @Override - protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(String[] colourBySequenceCommands) { // TODO Auto-generated method stub @@ -328,7 +326,7 @@ public class AAStructureBindingModelTest } @Override - protected StructureMappingcommandSet[] getColourBySequenceCommands( + protected String[] getColourBySequenceCommands( String[] files, AlignmentViewPanel avp) { return null; @@ -342,8 +340,7 @@ public class AAStructureBindingModelTest } @Override - protected void colourBySequence( - StructureMappingcommandSet[] colourBySequenceCommands) + protected void colourBySequence(String[] colourBySequenceCommands) { }