import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
SequenceFeature sf2 = new SequenceFeature("Cath", "", 6, 8, 6f,
"group1");
// score 6 is half way from yellow(255, 255, 0) to red(255, 0, 0)
- assertEquals(fr.getColour(sf2), new Color(255, 128, 0));
+ Color expected = new Color(255, 128, 0);
+ assertEquals(fr.getColour(sf2), expected);
/*
* above threshold, score is above threshold - no change
*/
gc.setAboveThreshold(true);
gc.setThreshold(5f);
- assertEquals(fr.getColour(sf2), new Color(255, 128, 0));
+ assertEquals(fr.getColour(sf2), expected);
/*
* threshold is min-max; now score 6 is 1/6 of the way from 5 to 11
// with numeric attribute value
sf2.setValue("AF", "6");
- assertEquals(fr.getColour(sf2), new Color(255, 128, 0));
+ assertEquals(fr.getColour(sf2), expected);
// with numeric value outwith threshold
gc.setAboveThreshold(true);
// with filter on AF < 4
gc.setAboveThreshold(false);
- assertEquals(fr.getColour(sf2), new Color(255, 128, 0));
+ assertEquals(fr.getColour(sf2), expected);
KeyedMatcherSetI filter = new KeyedMatcherSet();
filter.and(new KeyedMatcher(Condition.LT, 4f, "AF"));
fr.setFeatureFilter("Cath", filter);
assertNull(fr.getColour(sf2));
// attribute matches filter
sf2.setValue("Consequence", "Missense variant");
- assertEquals(fr.getColour(sf2), new Color(255, 128, 0));
+ assertEquals(fr.getColour(sf2), expected);
+
+ // with filter on CSQ.Feature contains "ENST01234"
+ filter = new KeyedMatcherSet();
+ filter.and(new KeyedMatcher(Condition.Matches, "ENST01234", "CSQ",
+ "Feature"));
+ fr.setFeatureFilter("Cath", filter);
+ // if feature has no CSQ data, no colour
+ assertNull(fr.getColour(sf2));
+ // if CSQ data does not include Feature, no colour
+ Map<String, String> csqData = new HashMap<>();
+ csqData.put("BIOTYPE", "Transcript");
+ sf2.setValue("CSQ", csqData);
+ assertNull(fr.getColour(sf2));
+ // if attribute does not match filter, no colour
+ csqData.put("Feature", "ENST9876");
+ assertNull(fr.getColour(sf2));
+ // attribute matches filter
+ csqData.put("Feature", "ENST01234");
+ assertEquals(fr.getColour(sf2), expected);
}
}