From 8b795f97aa57877aee49a46778283706dbf3e71b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 8 Jun 2020 16:17:55 +0100 Subject: [PATCH] JAL-3390 obsolete classes/methods removed --- src/jalview/ext/jmol/JmolCommands.java | 6 - src/jalview/ext/rbvi/chimera/AtomSpecModel.java | 126 --------- src/jalview/ext/rbvi/chimera/ChimeraXCommands.java | 11 - src/jalview/structure/StructureCommandsBase.java | 11 - src/jalview/structure/StructureCommandsI.java | 10 - src/jalview/util/StructureCommands.java | 273 -------------------- test/jalview/ext/jmol/JmolCommandsTest.java | 6 - test/jalview/ext/pymol/PymolCommandsTest.java | 6 - .../ext/rbvi/chimera/ChimeraCommandsTest.java | 6 - .../ext/rbvi/chimera/ChimeraXCommandsTest.java | 6 - 10 files changed, 461 deletions(-) delete mode 100644 src/jalview/ext/rbvi/chimera/AtomSpecModel.java delete mode 100644 src/jalview/util/StructureCommands.java diff --git a/src/jalview/ext/jmol/JmolCommands.java b/src/jalview/ext/jmol/JmolCommands.java index 7dc5224..35ee8d2 100644 --- a/src/jalview/ext/jmol/JmolCommands.java +++ b/src/jalview/ext/jmol/JmolCommands.java @@ -76,12 +76,6 @@ public class JmolCommands extends StructureCommandsBase private static final String SLASH = "/"; - @Override - public int getModelStartNo() - { - return 1; - } - /** * Returns a string representation of the given colour suitable for inclusion * in Jmol commands diff --git a/src/jalview/ext/rbvi/chimera/AtomSpecModel.java b/src/jalview/ext/rbvi/chimera/AtomSpecModel.java deleted file mode 100644 index f0d1e84..0000000 --- a/src/jalview/ext/rbvi/chimera/AtomSpecModel.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ext.rbvi.chimera; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * A class to model a Chimera or Jmol residue set, as - * {@code Map>>}. This can then be - * traversed to generate the required display command in Chimera or Jmol syntax. - */ -public class AtomSpecModel -{ - private Map>> atomSpec; - - /** - * Constructor - */ - public AtomSpecModel() - { - atomSpec = new TreeMap<>(); - } - - public Map>> getMap() - { - return atomSpec; - } - - /** - * Adds one contiguous range to this atom spec - * - * @param model - * @param startPos - * @param endPos - * @param chain - */ - public void addRange(int model, int startPos, int endPos, String chain) - { - /* - * Get/initialize map of data for the colour and model - */ - Map> modelData = atomSpec.get(model); - if (modelData == null) - { - atomSpec.put(model, modelData = new TreeMap<>()); - } - - /* - * Get/initialize map of data for colour, model and chain - */ - List chainData = modelData.get(chain); - if (chainData == null) - { - chainData = new ArrayList<>(); - modelData.put(chain, chainData); - } - - /* - * Add the start/end positions - */ - chainData.add(new int[] { startPos, endPos }); - // TODO add intelligently, using a RangeList class - } - - /** - * Answers an iterable set of the structure models in this model - * - * @return - */ - public Iterable getModels() - { - return atomSpec.keySet(); - } - - /** - * Answers an iterable set of the chains in this model for the given structure - * model, or an empty set if none - * - * @param model - * @return - */ - public Iterable getChains(Integer model) - { - if (atomSpec.containsKey(model)) - { - return atomSpec.get(model).keySet(); - } - return Collections.emptySet(); - } - - public List getRanges(Integer model, String chain) - { - Map> modelData = atomSpec.get(model); - if (modelData != null) - { - List chainData = modelData.get(chain); - if (chainData != null) - { - return chainData; - } - } - return Collections.EMPTY_LIST; - } -} diff --git a/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java index 9da1738..8a4a299 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraXCommands.java @@ -72,17 +72,6 @@ public class ChimeraXCommands extends ChimeraCommands } /** - * {@inheritDoc} - * - * @return - */ - @Override - public int getModelStartNo() - { - return 1; - } - - /** * Returns a viewer command to set the given residue attribute value on * residues specified by the AtomSpecModel, for example * diff --git a/src/jalview/structure/StructureCommandsBase.java b/src/jalview/structure/StructureCommandsBase.java index e4f7ac1..121bcba 100644 --- a/src/jalview/structure/StructureCommandsBase.java +++ b/src/jalview/structure/StructureCommandsBase.java @@ -30,17 +30,6 @@ public abstract class StructureCommandsBase implements StructureCommandsI } /** - * Returns the lowest model number used by the structure viewer - * - * @return - */ - @Override - public int getModelStartNo() - { - return 0; - } - - /** * Helper method to add one contiguous range to the AtomSpec model for the given * value (creating the model if necessary). As used by Jalview, {@code value} is *
    diff --git a/src/jalview/structure/StructureCommandsI.java b/src/jalview/structure/StructureCommandsI.java index 5a0db0a..2169184 100644 --- a/src/jalview/structure/StructureCommandsI.java +++ b/src/jalview/structure/StructureCommandsI.java @@ -120,16 +120,6 @@ public interface StructureCommandsI 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) * diff --git a/src/jalview/util/StructureCommands.java b/src/jalview/util/StructureCommands.java deleted file mode 100644 index b45ca5d..0000000 --- a/src/jalview/util/StructureCommands.java +++ /dev/null @@ -1,273 +0,0 @@ -package jalview.util; - -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.api.FeatureRenderer; -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.structures.models.AAStructureBindingModel; - -import java.awt.Color; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * A class with common methods for building commands for Jmol, Chimera, or other - * - * @author gmcarstairs - */ -public abstract class StructureCommands -{ - - /** - * Helper method to add one contiguous range to the AtomSpec model for the given - * value (creating the model if necessary). As used by Jalview, {@code value} is - *
      - *
    • a colour, when building a 'colour structure by sequence' command
    • - *
    • a feature value, when building a 'set Chimera attributes from features' - * command
    • - *
    - * - * @param map - * @param value - * @param model - * @param startPos - * @param endPos - * @param chain - */ - public static void addAtomSpecRange(Map map, - Object value, - int model, int startPos, int endPos, String chain) - { - /* - * Get/initialize map of data for the colour - */ - AtomSpecModel atomSpec = map.get(value); - if (atomSpec == null) - { - atomSpec = new AtomSpecModel(); - map.put(value, atomSpec); - } - - atomSpec.addRange(model, startPos, endPos, chain); - } - - /** - * Build a data structure which records contiguous subsequences by colour, model - * and chain. From this we can easily generate the Chimera or Jmol specific - * selection expression. - * - *
    -   * 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 - */ - public static Map buildColoursMap( - AAStructureBindingModel binding, 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 = binding.getSequenceRenderer(viewPanel); - String[] files = binding.getStructureFiles(); - SequenceI[][] sequence = binding.getSequence(); - - Map colourMap = new LinkedHashMap<>(); - Color lastColour = null; - - for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) - { - String fileName = files[pdbfnum]; - final int modelNumber = binding.getModelForPdbFile(fileName, pdbfnum); - StructureMapping[] mapping = binding.getSsm() - .getMapping(fileName); - - 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 (binding.isHideHiddenRegions()) - { - 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) - { - StructureCommands.addAtomSpecRange(colourMap, lastColour, - modelNumber, startPos, lastPos, lastChain); - } - startPos = pos; - } - lastColour = colour; - lastPos = pos; - lastChain = chain; - } - // final colour range - if (lastColour != null) - { - StructureCommands.addAtomSpecRange(colourMap, lastColour, - modelNumber, startPos, lastPos, lastChain); - } - } - } - } - } - return colourMap; - } - - /** - * A helper method that takes a list of [start-end] ranges, format them as - * s1-e1,s2-e2 etc and appends to the string buffer. Ranges are sorted, and - * coalesced if they overlap. The chain token, if not null, is appended to each - * resulting subrange. - * - * @param sb - * @param rangeList - * @param chainToken - * @param firstPositionForModel - */ - protected static void appendResidueRange(StringBuilder sb, List rangeList, - String chainToken, boolean firstPositionForModel) - { - /* - * sort ranges into ascending start position order - */ - Collections.sort(rangeList, IntRangeComparator.ASCENDING); - - int start = rangeList.isEmpty() ? 0 : rangeList.get(0)[0]; - int end = rangeList.isEmpty() ? 0 : rangeList.get(0)[1]; - - Iterator iterator = rangeList.iterator(); - while (iterator.hasNext()) - { - int[] range = iterator.next(); - if (range[0] <= end + 1) - { - /* - * range overlaps or is contiguous with the last one - * - so just extend the end position, and carry on - * (unless this is the last in the list) - */ - end = Math.max(end, range[1]); - } - else - { - /* - * we have a break so append the last range - */ - appendRange(sb, start, end, chainToken, firstPositionForModel); - firstPositionForModel = false; - start = range[0]; - end = range[1]; - } - } - - /* - * and append the last range - */ - if (!rangeList.isEmpty()) - { - appendRange(sb, start, end, chainToken, firstPositionForModel); - } - } - - /** - * A helper method that appends one start-end range, and an (optional) chain - * token to an atomspec (a null token is not appended) - * - * @param sb - * @param start - * @param end - * @param chainToken - * @param firstPositionForModel - */ - protected static void appendRange(StringBuilder sb, int start, int end, - String chainToken, boolean firstPositionForModel) - { - if (!firstPositionForModel) - { - sb.append(","); - } - if (end == start) - { - sb.append(start); - } - else - { - sb.append(start).append("-").append(end); - } - if (chainToken != null) - { - sb.append(chainToken); - } - } - -} diff --git a/test/jalview/ext/jmol/JmolCommandsTest.java b/test/jalview/ext/jmol/JmolCommandsTest.java index c0bb629..cbb9e10 100644 --- a/test/jalview/ext/jmol/JmolCommandsTest.java +++ b/test/jalview/ext/jmol/JmolCommandsTest.java @@ -237,12 +237,6 @@ public class JmolCommandsTest } @Test(groups = "Functional") - public void testGetModelStartNo() - { - assertEquals(testee.getModelStartNo(), 1); - } - - @Test(groups = "Functional") public void testColourByChain() { StructureCommandI cmd = testee.colourByChain(); diff --git a/test/jalview/ext/pymol/PymolCommandsTest.java b/test/jalview/ext/pymol/PymolCommandsTest.java index 9759ff3..90d0cc7 100644 --- a/test/jalview/ext/pymol/PymolCommandsTest.java +++ b/test/jalview/ext/pymol/PymolCommandsTest.java @@ -173,12 +173,6 @@ public class PymolCommandsTest } @Test(groups = "Functional") - public void testGetModelStartNo() - { - assertEquals(testee.getModelStartNo(), 0); - } - - @Test(groups = "Functional") public void testGetResidueSpec() { assertEquals(testee.getResidueSpec("ALA"), "resn ALA"); diff --git a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java index d8eb7bc..b8ca2dd 100644 --- a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java +++ b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java @@ -251,12 +251,6 @@ public class ChimeraCommandsTest } @Test(groups = "Functional") - public void testGetModelStartNo() - { - assertEquals(testee.getModelStartNo(), 0); - } - - @Test(groups = "Functional") public void testGetResidueSpec() { assertEquals(testee.getResidueSpec("ALA"), "::ALA"); diff --git a/test/jalview/ext/rbvi/chimera/ChimeraXCommandsTest.java b/test/jalview/ext/rbvi/chimera/ChimeraXCommandsTest.java index cb951c6..02a9dd5 100644 --- a/test/jalview/ext/rbvi/chimera/ChimeraXCommandsTest.java +++ b/test/jalview/ext/rbvi/chimera/ChimeraXCommandsTest.java @@ -269,12 +269,6 @@ public class ChimeraXCommandsTest } @Test(groups = "Functional") - public void testGetModelStartNo() - { - assertEquals(testee.getModelStartNo(), 1); - } - - @Test(groups = "Functional") public void testGetResidueSpec() { assertEquals(testee.getResidueSpec("ALA"), ":ALA"); -- 1.7.10.2