*/
public class FeatureColour implements FeatureColourI
{
- static final Color DEFAULT_NO_COLOUR = Color.LIGHT_GRAY;
+ static final Color DEFAULT_NO_COLOUR = null;
private static final String BAR = "|";
/*
* graduated colour case, optionally with threshold
* may be based on feature score on an attribute value
- * Float.NaN is assigned minimum visible score colour
- * no such attribute is assigned the 'no value' colour
+ * Float.NaN, or no value, is assigned the 'no value' colour
*/
float scr = feature.getScore();
if (attributeName != null)
List<SequenceFeature> features = sequence.findFeatures(column, column,
visibleTypes);
+ /*
+ * include features unless their feature group is not displayed, or
+ * they are hidden (have no colour) based on a filter or colour threshold
+ */
for (SequenceFeature sf : features)
{
- if (!featureGroupNotShown(sf))
+ if (!featureGroupNotShown(sf) && getColour(sf) != null)
{
result.add(sf);
}
for (SequenceFeature sf : features)
{
- if (!featureGroupNotShown(sf))
+ if (!featureGroupNotShown(sf) && getColour(sf) != null)
{
result.add(sf);
}
features = fr.findFeaturesAtColumn(seq, 5);
assertEquals(features.size(), 1);
assertTrue(features.contains(sf8));
+
+ /*
+ * give "Type3" features a graduated colour scheme
+ * - first with no threshold
+ */
+ FeatureColourI gc = new FeatureColour(Color.yellow, Color.red, null, 0f,
+ 10f);
+ fr.getFeatureColours().put("Type3", gc);
+ features = fr.findFeaturesAtColumn(seq, 8);
+ assertTrue(features.contains(sf4));
+ // now with threshold > 2f - feature score of 1f is excluded
+ gc.setAboveThreshold(true);
+ gc.setThreshold(2f);
+ features = fr.findFeaturesAtColumn(seq, 8);
+ assertFalse(features.contains(sf4));
+
+ /*
+ * make "Type3" graduated colour by attribute "AF"
+ * - first with no attribute held - feature should be excluded
+ */
+ gc.setAttributeName("AF");
+ features = fr.findFeaturesAtColumn(seq, 8);
+ assertFalse(features.contains(sf4));
+ // now with the attribute above threshold - should be included
+ sf4.setValue("AF", "2.4");
+ features = fr.findFeaturesAtColumn(seq, 8);
+ assertTrue(features.contains(sf4));
+ // now with the attribute below threshold - should be excluded
+ sf4.setValue("AF", "1.4");
+ features = fr.findFeaturesAtColumn(seq, 8);
+ assertFalse(features.contains(sf4));
}
@Test(groups = "Functional")