*/
public BuriedColourScheme()
{
- super(ResidueProperties.aaIndex, ResidueProperties.buried,
- ResidueProperties.buriedmin, ResidueProperties.buriedmax);
+ super(ResidueProperties.aaIndex, ResidueProperties.buried);
}
/**
{
public HelixColourScheme()
{
- super(ResidueProperties.aaIndex, ResidueProperties.helix,
- ResidueProperties.helixmin, ResidueProperties.helixmax);
+ super(ResidueProperties.aaIndex, ResidueProperties.helix);
}
@Override
*/
public HydrophobicColourScheme()
{
- super(ResidueProperties.aaIndex, ResidueProperties.hyd,
- ResidueProperties.hydmin, ResidueProperties.hydmax);
+ super(ResidueProperties.aaIndex, ResidueProperties.hyd);
}
/**
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.
-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<String, Color> ssHash = new Hashtable<String,
// Color>();
{
}
- public static double getHydmax()
- {
- return hydmax;
- }
-
- public static double getHydmin()
- {
- return hydmin;
- }
-
- public static double[] getHyd()
- {
- return hyd;
- }
-
public static Map<String, Integer> getAA3Hash()
{
return aa3Hash;
import java.awt.Color;
/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
+ * A base class for colour schemes which define a graduated colour range based
+ * on
+ * <ul>
+ * <li>a minimum colour</li>
+ * <li>a maximum colour</li>
+ * <li>a score assigned to each residue</li>
+ * </ul>
*/
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?
}
}
+ /**
+ * 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)
{
public ColourSchemeI getInstance(AlignViewportI view,
AnnotatedCollectionI coll)
{
- return new ScoreColourScheme(symbolIndex, scores, min, max);
+ return new ScoreColourScheme(symbolIndex, scores);
}
}
*/
public StrandColourScheme()
{
- super(ResidueProperties.aaIndex, ResidueProperties.strand,
- ResidueProperties.strandmin, ResidueProperties.strandmax);
+ super(ResidueProperties.aaIndex, ResidueProperties.strand);
}
/**
*/
public TurnColourScheme()
{
- super(ResidueProperties.aaIndex, ResidueProperties.turn,
- ResidueProperties.turnmin, ResidueProperties.turnmax);
+ super(ResidueProperties.aaIndex, ResidueProperties.turn);
}
/**
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
* <p>
* scores are scaled to c 0-1 between min and max and colour is (0, 1-c, c)
*/
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));
}
}
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));
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));
}
}
{
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));
}
}
*/
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));
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",
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));
}
}
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));
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));
}
}