import jalview.datamodel.Profiles;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.schemes.ColourSchemeI;
import jalview.schemes.PIDColourScheme;
+import jalview.schemes.ResidueProperties;
+import jalview.schemes.UserColourScheme;
import java.awt.Color;
import java.util.Collections;
assertEquals(Color.WHITE, ccs.applyConservation(colour, 12));
}
+ /**
+ * A custom gap colour should not be affected by Colour by Conservation
+ */
+ @Test(groups = "Functional")
+ public void testFindColour_gapColour()
+ {
+ Color[] colours = new Color[ResidueProperties.maxProteinIndex + 1];
+ colours[5] = Color.blue; // Q colour
+ colours[23] = Color.red; // gap colour
+ ColourSchemeI cs = new UserColourScheme(colours);
+ ResidueShader ccs = new ResidueShader(cs);
+
+ assertEquals(Color.red, ccs.findColour(' ', 7, null));
+
+ /*
+ * stub Conservation to return a given consensus string
+ */
+ final String consSequence = "0123456789+*-";
+ Conservation cons = new Conservation(null,
+ Collections.<SequenceI> emptyList(), 0, 0)
+ {
+ @Override
+ public SequenceI getConsSequence()
+ {
+ return new Sequence("seq", consSequence);
+ }
+ };
+ ccs.setConservation(cons);
+
+ /*
+ * with 0% threshold, there should be no fading
+ */
+ ccs.setConservationInc(0);
+ assertEquals(Color.red, ccs.findColour(' ', 7, null));
+ assertEquals(Color.blue, ccs.findColour('Q', 7, null));
+
+ /*
+ * with 40% threshold, 'fade factor' is
+ * (11-score)/10 * 40/20 = (11-score)/5
+ * so position 7, score 7 fades 80% of the way to white (255, 255, 255)
+ */
+ ccs.setConservationInc(40);
+
+ /*
+ * gap colour is unchanged for Conservation
+ */
+ assertEquals(Color.red, ccs.findColour(' ', 7, null));
+
+ /*
+ * residue colour is faded 80% of the way from
+ * blue(0, 0, 255) to white(255, 255, 255)
+ * making (204, 204, 255)
+ */
+ assertEquals(new Color(204, 204, 255), ccs.findColour('Q', 7, null));
+ }
+
}