From b6c3048d27b10617873e6fd70fc73cff259de28f Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 25 Mar 2019 12:22:55 +0000 Subject: [PATCH] JAL-3215 remove redundant min/max constants, refactor ctr, add tests --- src/jalview/schemes/BuriedColourScheme.java | 3 +- src/jalview/schemes/HelixColourScheme.java | 3 +- src/jalview/schemes/HydrophobicColourScheme.java | 3 +- src/jalview/schemes/ResidueProperties.java | 46 ++---------------- src/jalview/schemes/ScoreColourScheme.java | 51 ++++++++++++++------ src/jalview/schemes/StrandColourScheme.java | 3 +- src/jalview/schemes/TurnColourScheme.java | 3 +- test/jalview/schemes/BuriedColourSchemeTest.java | 38 +++++++++++++-- test/jalview/schemes/HelixColourSchemeTest.java | 29 +++++++++++ .../schemes/HydrophobicColourSchemeTest.java | 36 ++++++++++++-- test/jalview/schemes/ResidueColourSchemeTest.java | 6 +-- test/jalview/schemes/StrandColourSchemeTest.java | 34 +++++++++++-- test/jalview/schemes/TurnColourSchemeTest.java | 28 +++++++++++ 13 files changed, 199 insertions(+), 84 deletions(-) diff --git a/src/jalview/schemes/BuriedColourScheme.java b/src/jalview/schemes/BuriedColourScheme.java index e6672fc..938417d 100755 --- a/src/jalview/schemes/BuriedColourScheme.java +++ b/src/jalview/schemes/BuriedColourScheme.java @@ -38,8 +38,7 @@ public class BuriedColourScheme extends ScoreColourScheme */ public BuriedColourScheme() { - super(ResidueProperties.aaIndex, ResidueProperties.buried, - ResidueProperties.buriedmin, ResidueProperties.buriedmax); + super(ResidueProperties.aaIndex, ResidueProperties.buried); } /** diff --git a/src/jalview/schemes/HelixColourScheme.java b/src/jalview/schemes/HelixColourScheme.java index 2724f77..10a7ce5 100755 --- a/src/jalview/schemes/HelixColourScheme.java +++ b/src/jalview/schemes/HelixColourScheme.java @@ -29,8 +29,7 @@ public class HelixColourScheme extends ScoreColourScheme { public HelixColourScheme() { - super(ResidueProperties.aaIndex, ResidueProperties.helix, - ResidueProperties.helixmin, ResidueProperties.helixmax); + super(ResidueProperties.aaIndex, ResidueProperties.helix); } @Override diff --git a/src/jalview/schemes/HydrophobicColourScheme.java b/src/jalview/schemes/HydrophobicColourScheme.java index d886bdf..c8cf4c7 100755 --- a/src/jalview/schemes/HydrophobicColourScheme.java +++ b/src/jalview/schemes/HydrophobicColourScheme.java @@ -38,8 +38,7 @@ public class HydrophobicColourScheme extends ScoreColourScheme */ public HydrophobicColourScheme() { - super(ResidueProperties.aaIndex, ResidueProperties.hyd, - ResidueProperties.hydmin, ResidueProperties.hydmax); + super(ResidueProperties.aaIndex, ResidueProperties.hyd); } /** diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index d435065..fb5d5a8 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -433,35 +433,19 @@ public class ResidueProperties public static final double[] helix = { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, 1.45, 1.13, 0.57, 0.77, 0.83, - 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 }; - - public static final double helixmin = 0.57; - - public static final double helixmax = 1.51; + 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.57 }; public static final double[] strand = { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, 1.05, 1.38, 0.55, 0.75, - 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 }; - - public static final double strandmin = 0.37; - - public static final double strandmax = 1.7; + 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.37 }; public static final double[] turn = { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, 0.60, 0.60, 1.52, 1.43, 0.96, - 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0 }; - - public static final double turnmin = 0.47; - - public static final double turnmax = 1.56; + 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0.47, 0.47 }; public static final double[] buried = { 1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, - 0.3, 1.358, 0.00 }; - - public static final double buriedmin = 0.05; - - public static final double buriedmax = 4.6; + 0.3, 1.358, 0.05 }; // This is hydropathy index // Kyte, J., and Doolittle, R.F., J. Mol. Biol. @@ -470,13 +454,6 @@ public class ResidueProperties -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 }; - public static final double hydmax = 4.5; - - public static final double hydmin = -3.9; - - // public static final double hydmax = 1.38; - // public static final double hydmin = -2.53; - // not currently used // public static final Map ssHash = new Hashtable(); @@ -874,21 +851,6 @@ public class ResidueProperties { } - public static double getHydmax() - { - return hydmax; - } - - public static double getHydmin() - { - return hydmin; - } - - public static double[] getHyd() - { - return hyd; - } - public static Map getAA3Hash() { return aa3Hash; diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index eae76e1..442306d 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -28,10 +28,13 @@ import jalview.util.Comparison; import java.awt.Color; /** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision$ + * A base class for colour schemes which define a graduated colour range based + * on + *
    + *
  • a minimum colour
  • + *
  • a maximum colour
  • + *
  • a score assigned to each residue
  • + *
*/ public class ScoreColourScheme extends ResidueColourScheme { @@ -42,23 +45,19 @@ public class ScoreColourScheme extends ResidueColourScheme public double[] scores; /** - * Creates a new ScoreColourScheme object. + * Constructor * + * @param symbolIndex + * a lookup where the index is a character e.g. 'R' or 'r', and the + * value is its position in the colour table lookup * @param scores - * DOCUMENT ME! - * @param min - * DOCUMENT ME! - * @param max - * DOCUMENT ME! + * per residue, indices matching colors lookup */ - public ScoreColourScheme(int symbolIndex[], double[] scores, double min, - double max) + public ScoreColourScheme(int symbolIndex[], double[] scores) { super(symbolIndex); - + setMinMax(scores); this.scores = scores; - this.min = min; - this.max = max; // Make colours in constructor // Why wasn't this done earlier? @@ -84,6 +83,26 @@ public class ScoreColourScheme extends ResidueColourScheme } } + /** + * Inspects score values and saves the minimum and maximum + * + * @param vals + */ + void setMinMax(double[] vals) + { + double dMin = Double.MAX_VALUE; + double dMax = -Double.MAX_VALUE; + + for (int i = 0; i < vals.length - 1; i++) + { + dMin = Math.min(dMin, vals[i]); + dMax = Math.max(dMax, vals[i]); + } + + this.min = vals.length == 0 ? 0d : dMin; + this.max = vals.length == 0 ? 0d : dMax; + } + @Override public Color findColour(char c, int j, SequenceI seq) { @@ -121,6 +140,6 @@ public class ScoreColourScheme extends ResidueColourScheme public ColourSchemeI getInstance(AlignViewportI view, AnnotatedCollectionI coll) { - return new ScoreColourScheme(symbolIndex, scores, min, max); + return new ScoreColourScheme(symbolIndex, scores); } } diff --git a/src/jalview/schemes/StrandColourScheme.java b/src/jalview/schemes/StrandColourScheme.java index ef55d69..c1b15e4 100755 --- a/src/jalview/schemes/StrandColourScheme.java +++ b/src/jalview/schemes/StrandColourScheme.java @@ -38,8 +38,7 @@ public class StrandColourScheme extends ScoreColourScheme */ public StrandColourScheme() { - super(ResidueProperties.aaIndex, ResidueProperties.strand, - ResidueProperties.strandmin, ResidueProperties.strandmax); + super(ResidueProperties.aaIndex, ResidueProperties.strand); } /** diff --git a/src/jalview/schemes/TurnColourScheme.java b/src/jalview/schemes/TurnColourScheme.java index 7d8035a..b8b2d90 100755 --- a/src/jalview/schemes/TurnColourScheme.java +++ b/src/jalview/schemes/TurnColourScheme.java @@ -38,8 +38,7 @@ public class TurnColourScheme extends ScoreColourScheme */ public TurnColourScheme() { - super(ResidueProperties.aaIndex, ResidueProperties.turn, - ResidueProperties.turnmin, ResidueProperties.turnmax); + super(ResidueProperties.aaIndex, ResidueProperties.turn); } /** diff --git a/test/jalview/schemes/BuriedColourSchemeTest.java b/test/jalview/schemes/BuriedColourSchemeTest.java index cdb0e80..034fd5d 100644 --- a/test/jalview/schemes/BuriedColourSchemeTest.java +++ b/test/jalview/schemes/BuriedColourSchemeTest.java @@ -9,8 +9,8 @@ import org.testng.annotations.Test; public class BuriedColourSchemeTest { /** - * Turn colours are based on the scores in ResidueProperties.buried A = 1.7, R - * = 0.1, N = 0.4, D = 0.4... min = 0.05 max = 4.6 + * Buried colours are derived from the scores in ResidueProperties.buried A = + * 1.7, R = 0.1, N = 0.4, D = 0.4... min = 0.05 max = 4.6 *

* scores are scaled to c 0-1 between min and max and colour is (0, 1-c, c) */ @@ -21,13 +21,43 @@ public class BuriedColourSchemeTest float min = 0.05f; float max = 4.6f; + assertEquals((float) scheme.min, min); + assertEquals((float) scheme.max, max); + float a = (1.7f - min) / (max - min); - assertEquals(scheme.findColour('A', 0, null), new Color(0, 1 - a, a)); + Color expected = new Color(0, 1 - a, a); + assertEquals(scheme.findColour('A', 0, null), expected); float d = (0.4f - min) / (max - min); - assertEquals(scheme.findColour('D', 0, null), new Color(0, 1 - d, d)); + expected = new Color(0, 1 - d, d); + assertEquals(scheme.findColour('D', 0, null), expected); assertEquals(scheme.findColour('-', 0, null), Color.WHITE); + assertEquals(scheme.findColour('A', 0, null), new Color(0, 163, 92)); + assertEquals(scheme.findColour('r', 0, null), new Color(0, 252, 3)); + assertEquals(scheme.findColour('n', 0, null), new Color(0, 235, 20)); + assertEquals(scheme.findColour('d', 0, null), new Color(0, 235, 20)); + assertEquals(scheme.findColour('c', 0, null), new Color(0, 0, 255)); + assertEquals(scheme.findColour('q', 0, null), new Color(0, 241, 14)); + assertEquals(scheme.findColour('e', 0, null), new Color(0, 241, 14)); + assertEquals(scheme.findColour('g', 0, null), new Color(0, 157, 98)); + assertEquals(scheme.findColour('h', 0, null), new Color(0, 213, 42)); + assertEquals(scheme.findColour('I', 0, null), new Color(0, 84, 171)); + assertEquals(scheme.findColour('L', 0, null), new Color(0, 123, 132)); + assertEquals(scheme.findColour('K', 0, null), new Color(0, 255, 0)); + assertEquals(scheme.findColour('M', 0, null), new Color(0, 151, 104)); + assertEquals(scheme.findColour('F', 0, null), new Color(0, 135, 120)); + assertEquals(scheme.findColour('P', 0, null), new Color(0, 224, 31)); + assertEquals(scheme.findColour('S', 0, null), new Color(0, 213, 42)); + assertEquals(scheme.findColour('T', 0, null), new Color(0, 219, 36)); + assertEquals(scheme.findColour('W', 0, null), new Color(0, 168, 87)); + assertEquals(scheme.findColour('Y', 0, null), new Color(0, 230, 25)); + assertEquals(scheme.findColour('v', 0, null), new Color(0, 95, 160)); + assertEquals(scheme.findColour('b', 0, null), new Color(0, 235, 20)); + assertEquals(scheme.findColour('z', 0, null), new Color(0, 241, 14)); + assertEquals(scheme.findColour('x', 0, null), new Color(0, 182, 73)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 0)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 0)); } } diff --git a/test/jalview/schemes/HelixColourSchemeTest.java b/test/jalview/schemes/HelixColourSchemeTest.java index ed46419..ddca303 100644 --- a/test/jalview/schemes/HelixColourSchemeTest.java +++ b/test/jalview/schemes/HelixColourSchemeTest.java @@ -21,6 +21,9 @@ public class HelixColourSchemeTest float min = 0.57f; float max = 1.51f; + assertEquals((float) scheme.min, min); + assertEquals((float) scheme.max, max); + float a = (1.42f - min) / (max - min); assertEquals(scheme.findColour('A', 0, null), new Color(a, 1 - a, a)); @@ -28,6 +31,32 @@ public class HelixColourSchemeTest assertEquals(scheme.findColour('D', 0, null), new Color(d, 1 - d, d)); assertEquals(scheme.findColour('-', 0, null), Color.WHITE); + + assertEquals(scheme.findColour('A', 0, null), new Color(231, 24, 231)); + assertEquals(scheme.findColour('r', 0, null), new Color(111, 144, 111)); + assertEquals(scheme.findColour('n', 0, null), new Color(27, 228, 27)); + assertEquals(scheme.findColour('d', 0, null), new Color(119, 136, 119)); + assertEquals(scheme.findColour('c', 0, null), new Color(35, 220, 35)); + assertEquals(scheme.findColour('q', 0, null), new Color(146, 109, 146)); + assertEquals(scheme.findColour('e', 0, null), new Color(255, 0, 255)); + assertEquals(scheme.findColour('g', 0, null), new Color(0, 255, 0)); + assertEquals(scheme.findColour('h', 0, null), new Color(117, 138, 117)); + assertEquals(scheme.findColour('I', 0, null), new Color(138, 117, 138)); + assertEquals(scheme.findColour('L', 0, null), new Color(174, 81, 174)); + assertEquals(scheme.findColour('K', 0, null), new Color(160, 95, 160)); + assertEquals(scheme.findColour('M', 0, null), new Color(239, 16, 239)); + assertEquals(scheme.findColour('F', 0, null), new Color(152, 103, 152)); + assertEquals(scheme.findColour('P', 0, null), new Color(0, 255, 0)); + assertEquals(scheme.findColour('S', 0, null), new Color(54, 201, 54)); + assertEquals(scheme.findColour('T', 0, null), new Color(71, 184, 71)); + assertEquals(scheme.findColour('W', 0, null), new Color(138, 117, 138)); + assertEquals(scheme.findColour('Y', 0, null), new Color(33, 222, 33)); + assertEquals(scheme.findColour('v', 0, null), new Color(133, 122, 133)); + assertEquals(scheme.findColour('b', 0, null), new Color(73, 182, 73)); + assertEquals(scheme.findColour('z', 0, null), new Color(201, 54, 201)); + assertEquals(scheme.findColour('x', 0, null), new Color(117, 138, 117)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 0)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 0)); } } diff --git a/test/jalview/schemes/HydrophobicColourSchemeTest.java b/test/jalview/schemes/HydrophobicColourSchemeTest.java index f3b93a9..a0a2281 100644 --- a/test/jalview/schemes/HydrophobicColourSchemeTest.java +++ b/test/jalview/schemes/HydrophobicColourSchemeTest.java @@ -19,17 +19,43 @@ public class HydrophobicColourSchemeTest { ScoreColourScheme scheme = new HydrophobicColourScheme(); - float min = -3.9f; + float min = -4.5f; float max = 4.5f; + assertEquals((float) scheme.min, min); + assertEquals((float) scheme.max, max); + float a = (1.8f - min) / (max - min); - assertEquals(scheme.findColour('A', 0, null), - new Color(a, 0, 1 - a)); + assertEquals(scheme.findColour('A', 0, null), new Color(a, 0, 1 - a)); float d = (-3.5f - min) / (max - min); - assertEquals(scheme.findColour('D', 0, null), - new Color(d, 0, 1 - d)); + assertEquals(scheme.findColour('D', 0, null), new Color(d, 0, 1 - d)); assertEquals(scheme.findColour('-', 0, null), Color.WHITE); + assertEquals(scheme.findColour('A', 0, null), new Color(179, 0, 76)); + assertEquals(scheme.findColour('r', 0, null), new Color(0, 0, 255)); + assertEquals(scheme.findColour('n', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('d', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('c', 0, null), new Color(198, 0, 57)); + assertEquals(scheme.findColour('q', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('e', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('g', 0, null), new Color(116, 0, 139)); + assertEquals(scheme.findColour('h', 0, null), new Color(37, 0, 218)); + assertEquals(scheme.findColour('I', 0, null), new Color(255, 0, 0)); + assertEquals(scheme.findColour('L', 0, null), new Color(235, 0, 20)); + assertEquals(scheme.findColour('K', 0, null), new Color(17, 0, 238)); + assertEquals(scheme.findColour('M', 0, null), new Color(181, 0, 74)); + assertEquals(scheme.findColour('F', 0, null), new Color(207, 0, 48)); + assertEquals(scheme.findColour('P', 0, null), new Color(82, 0, 173)); + assertEquals(scheme.findColour('S', 0, null), new Color(105, 0, 150)); + assertEquals(scheme.findColour('T', 0, null), new Color(108, 0, 147)); + assertEquals(scheme.findColour('W', 0, null), new Color(102, 0, 153)); + assertEquals(scheme.findColour('Y', 0, null), new Color(91, 0, 164)); + assertEquals(scheme.findColour('v', 0, null), new Color(247, 0, 9)); + assertEquals(scheme.findColour('b', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('z', 0, null), new Color(28, 0, 227)); + assertEquals(scheme.findColour('x', 0, null), new Color(114, 0, 141)); + assertEquals(scheme.findColour('?', 0, null), new Color(128, 0, 128)); + assertEquals(scheme.findColour('?', 0, null), new Color(128, 0, 128)); } } diff --git a/test/jalview/schemes/ResidueColourSchemeTest.java b/test/jalview/schemes/ResidueColourSchemeTest.java index b45e0d3..decd9dd 100644 --- a/test/jalview/schemes/ResidueColourSchemeTest.java +++ b/test/jalview/schemes/ResidueColourSchemeTest.java @@ -102,9 +102,9 @@ public class ResidueColourSchemeTest */ assertTrue(new UserColourScheme().isApplicableTo(peptide)); assertTrue(new UserColourScheme().isApplicableTo(nucleotide)); - assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}, 0, 0d) + assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}) .isApplicableTo(peptide)); - assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}, 0, 0d) + assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}) .isApplicableTo(nucleotide)); ResidueColourScheme rcs = new PIDColourScheme(); assertTrue(rcs.isApplicableTo(peptide)); @@ -190,7 +190,7 @@ public class ResidueColourSchemeTest new RNAInteractionColourScheme().getSchemeName()); assertEquals("User Defined", new UserColourScheme().getSchemeName()); assertEquals("Score", new ScoreColourScheme(new int[] {}, - new double[] {}, 0, 0d).getSchemeName()); + new double[] {}).getSchemeName()); assertEquals("% Identity", new PIDColourScheme().getSchemeName()); assertEquals("Follower", new FollowerColourScheme().getSchemeName()); assertEquals("T-Coffee Scores", diff --git a/test/jalview/schemes/StrandColourSchemeTest.java b/test/jalview/schemes/StrandColourSchemeTest.java index 4a8d0e9..db3f7a2 100644 --- a/test/jalview/schemes/StrandColourSchemeTest.java +++ b/test/jalview/schemes/StrandColourSchemeTest.java @@ -21,15 +21,41 @@ public class StrandColourSchemeTest float min = 0.37f; float max = 1.7f; + assertEquals((float) scheme.min, min); + assertEquals((float) scheme.max, max); + float a = (0.83f - min) / (max - min); - assertEquals(scheme.findColour('A', 0, null), - new Color(a, a, 1 - a)); + assertEquals(scheme.findColour('A', 0, null), new Color(a, a, 1 - a)); float d = (0.54f - min) / (max - min); - assertEquals(scheme.findColour('D', 0, null), - new Color(d, d, 1 - d)); + assertEquals(scheme.findColour('D', 0, null), new Color(d, d, 1 - d)); assertEquals(scheme.findColour('-', 0, null), Color.WHITE); + assertEquals(scheme.findColour('A', 0, null), new Color(88, 88, 167)); + assertEquals(scheme.findColour('r', 0, null), new Color(107, 107, 148)); + assertEquals(scheme.findColour('n', 0, null), new Color(100, 100, 155)); + assertEquals(scheme.findColour('d', 0, null), new Color(33, 33, 222)); + assertEquals(scheme.findColour('c', 0, null), new Color(157, 157, 98)); + assertEquals(scheme.findColour('q', 0, null), new Color(140, 140, 115)); + assertEquals(scheme.findColour('e', 0, null), new Color(0, 0, 255)); + assertEquals(scheme.findColour('g', 0, null), new Color(73, 73, 182)); + assertEquals(scheme.findColour('h', 0, null), new Color(96, 96, 159)); + assertEquals(scheme.findColour('I', 0, null), new Color(236, 236, 19)); + assertEquals(scheme.findColour('L', 0, null), new Color(178, 178, 77)); + assertEquals(scheme.findColour('K', 0, null), new Color(71, 71, 184)); + assertEquals(scheme.findColour('M', 0, null), new Color(130, 130, 125)); + assertEquals(scheme.findColour('F', 0, null), new Color(194, 194, 61)); + assertEquals(scheme.findColour('P', 0, null), new Color(35, 35, 220)); + assertEquals(scheme.findColour('S', 0, null), new Color(73, 73, 182)); + assertEquals(scheme.findColour('T', 0, null), new Color(157, 157, 98)); + assertEquals(scheme.findColour('W', 0, null), new Color(192, 192, 63)); + assertEquals(scheme.findColour('Y', 0, null), new Color(211, 211, 44)); + assertEquals(scheme.findColour('v', 0, null), new Color(255, 255, 0)); + assertEquals(scheme.findColour('b', 0, null), new Color(67, 67, 188)); + assertEquals(scheme.findColour('z', 0, null), new Color(71, 71, 184)); + assertEquals(scheme.findColour('x', 0, null), new Color(121, 121, 134)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 0, 255)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 0, 255)); } } diff --git a/test/jalview/schemes/TurnColourSchemeTest.java b/test/jalview/schemes/TurnColourSchemeTest.java index 5e6baf0..29b555a 100644 --- a/test/jalview/schemes/TurnColourSchemeTest.java +++ b/test/jalview/schemes/TurnColourSchemeTest.java @@ -21,6 +21,9 @@ public class TurnColourSchemeTest float min = 0.47f; float max = 1.56f; + assertEquals((float) scheme.min, min); + assertEquals((float) scheme.max, max); + float a = (0.66f - min) / (max - min); assertEquals(scheme.findColour('A', 0, null), new Color(a, 1 - a, 1 - a)); @@ -30,6 +33,31 @@ public class TurnColourSchemeTest new Color(d, 1 - d, 1 - d)); assertEquals(scheme.findColour('-', 0, null), Color.WHITE); + assertEquals(scheme.findColour('A', 0, null), new Color(44, 211, 211)); + assertEquals(scheme.findColour('r', 0, null), new Color(112, 143, 143)); + assertEquals(scheme.findColour('n', 0, null), new Color(255, 0, 0)); + assertEquals(scheme.findColour('d', 0, null), new Color(232, 23, 23)); + assertEquals(scheme.findColour('c', 0, null), new Color(168, 87, 87)); + assertEquals(scheme.findColour('q', 0, null), new Color(119, 136, 136)); + assertEquals(scheme.findColour('e', 0, null), new Color(63, 192, 192)); + assertEquals(scheme.findColour('g', 0, null), new Color(255, 0, 0)); + assertEquals(scheme.findColour('h', 0, null), new Color(112, 143, 143)); + assertEquals(scheme.findColour('I', 0, null), new Color(0, 255, 255)); + assertEquals(scheme.findColour('L', 0, null), new Color(28, 227, 227)); + assertEquals(scheme.findColour('K', 0, null), new Color(126, 129, 129)); + assertEquals(scheme.findColour('M', 0, null), new Color(30, 225, 225)); + assertEquals(scheme.findColour('F', 0, null), new Color(30, 225, 225)); + assertEquals(scheme.findColour('P', 0, null), new Color(246, 9, 9)); + assertEquals(scheme.findColour('S', 0, null), new Color(225, 30, 30)); + assertEquals(scheme.findColour('T', 0, null), new Color(115, 140, 140)); + assertEquals(scheme.findColour('W', 0, null), new Color(115, 140, 140)); + assertEquals(scheme.findColour('Y', 0, null), new Color(157, 98, 98)); + assertEquals(scheme.findColour('v', 0, null), new Color(7, 248, 248)); + assertEquals(scheme.findColour('b', 0, null), new Color(243, 12, 12)); + assertEquals(scheme.findColour('z', 0, null), new Color(91, 164, 164)); + assertEquals(scheme.findColour('x', 0, null), new Color(124, 131, 131)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 255)); + assertEquals(scheme.findColour('?', 0, null), new Color(0, 255, 255)); } } -- 1.7.10.2