-package jalview.schemes;
+package jalview.renderer;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import jalview.datamodel.Profiles;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.schemes.PIDColourScheme;
import java.awt.Color;
import java.util.Collections;
import org.testng.annotations.Test;
-public class CollectionColourSchemeTest
+public class ResidueShaderTest
{
@Test(groups = "Functional")
profiles[1] = new Profile(4, 0, 4, "R");
profiles[2] = new Profile(4, 4, 0, "");
profiles[3] = new Profile(4, 1, 2, "T");
- CollectionColourScheme ccs = new CollectionColourScheme(
- new PIDColourScheme());
+ ResidueShader ccs = new ResidueShader(new PIDColourScheme());
ccs.setConsensus(new Profiles(profiles));
-
+
/*
* no threshold
*/
assertTrue(ccs.aboveThreshold('W', 2));
assertTrue(ccs.aboveThreshold('t', 3));
assertTrue(ccs.aboveThreshold('Q', 3));
-
+
/*
* with threshold, include gaps
*/
assertTrue(ccs.aboveThreshold('R', 1));
assertFalse(ccs.aboveThreshold('W', 2));
assertFalse(ccs.aboveThreshold('t', 3)); // 50% < 60%
-
+
/*
* with threshold, ignore gaps
*/
@Test(groups = "Functional")
public void testApplyConservation()
{
- CollectionColourScheme ccs = new CollectionColourScheme(
- new PIDColourScheme());
-
+ ResidueShader ccs = new ResidueShader(new PIDColourScheme());
+
// no conservation present - no fading
assertEquals(Color.RED, ccs.applyConservation(Color.RED, 12));
-
+
/*
* stub Conservation to return a given consensus string
*/
Collections.<SequenceI> emptyList(), 0, 0)
{
@Override
- public SequenceI getConsSequence() {
+ public SequenceI getConsSequence()
+ {
return new Sequence("seq", consSequence);
}
};
ccs.setConservation(cons);
-
+
// column out of range:
assertEquals(Color.RED,
ccs.applyConservation(Color.RED, consSequence.length()));
-
+
/*
* with 100% threshold, 'fade factor' is
* (11-score)/10 * 100/20 = (11-score)/2
assertEquals(Color.RED, ccs.applyConservation(Color.RED, 10));
assertEquals(Color.RED, ccs.applyConservation(Color.RED, 11));
assertEquals(Color.WHITE, ccs.applyConservation(Color.RED, 12));
-
+
/*
* with 0% threshold, there should be no fading
*/
assertEquals(Color.RED, ccs.applyConservation(Color.RED, 10));
assertEquals(Color.RED, ccs.applyConservation(Color.RED, 11));
assertEquals(Color.WHITE, ccs.applyConservation(Color.RED, 12)); // gap
-
+
/*
* with 40% threshold, 'fade factor' is
* (11-score)/10 * 40/20 = (11-score)/5