X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Frenderer%2Fseqfeatures%2FFeatureRendererTest.java;h=723f3b8c9dcf3cc7e8404cc1d0bf0908bfda2801;hb=3c8a25936a2d805e7e3d7ab82f83b13135406d18;hp=a9e3754615f2873f93187fb877c3a767f8f5d72d;hpb=ef7d9bed59341ba8a035dc4578cd9c62b655286b;p=jalview.git diff --git a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java index a9e3754..723f3b8 100644 --- a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java +++ b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java @@ -285,8 +285,8 @@ public class FeatureRendererTest * give "Type3" features a graduated colour scheme * - first with no threshold */ - FeatureColourI gc = new FeatureColour(Color.yellow, Color.red, null, 0f, - 10f); + FeatureColourI gc = new FeatureColour(Color.green, Color.yellow, + Color.red, null, 0f, 10f); fr.getFeatureColours().put("Type3", gc); features = fr.findFeaturesAtColumn(seq, 8); assertTrue(features.contains(sf4)); @@ -428,8 +428,8 @@ public class FeatureRendererTest * graduated colour by score, no threshold, no score * */ - FeatureColourI gc = new FeatureColour(Color.yellow, Color.red, - Color.green, 1f, 11f); + FeatureColourI gc = new FeatureColour(Color.red, Color.yellow, + Color.red, Color.green, 1f, 11f); fr.getFeatureColours().put("Cath", gc); assertEquals(fr.getColour(sf1), Color.green); @@ -453,7 +453,8 @@ public class FeatureRendererTest * threshold is min-max; now score 6 is 1/6 of the way from 5 to 11 * or from yellow(255, 255, 0) to red(255, 0, 0) */ - gc = new FeatureColour(Color.yellow, Color.red, Color.green, 5f, 11f); + gc = new FeatureColour(Color.red, Color.yellow, Color.red, Color.green, + 5f, 11f); fr.getFeatureColours().put("Cath", gc); gc.setAutoScaled(false); // this does little other than save a checkbox setting! assertEquals(fr.getColour(sf2), new Color(255, 213, 0)); @@ -476,7 +477,8 @@ public class FeatureRendererTest * colour by feature attribute value * first with no value held */ - gc = new FeatureColour(Color.yellow, Color.red, Color.green, 1f, 11f); + gc = new FeatureColour(Color.red, Color.yellow, Color.red, Color.green, + 1f, 11f); fr.getFeatureColours().put("Cath", gc); gc.setAttributeName("AF"); assertEquals(fr.getColour(sf2), Color.green); @@ -535,4 +537,71 @@ public class FeatureRendererTest csqData.put("Feature", "ENST01234"); assertEquals(fr.getColour(sf2), expected); } + + @Test(groups = "Functional") + public void testIsVisible() + { + String seqData = ">s1\nMLQGIFPRS\n"; + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqData, + DataSourceType.PASTE); + AlignViewportI av = af.getViewport(); + FeatureRenderer fr = new FeatureRenderer(av); + SequenceI seq = av.getAlignment().getSequenceAt(0); + SequenceFeature sf = new SequenceFeature("METAL", "Desc", 10, 10, 1f, + "Group"); + sf.setValue("AC", "11"); + sf.setValue("CLIN_SIG", "Likely Pathogenic"); + seq.addSequenceFeature(sf); + + assertFalse(fr.isVisible(null)); + + /* + * initial state FeatureRenderer hasn't 'found' feature + * and so its feature type has not yet been set visible + */ + assertFalse(fr.getDisplayedFeatureCols().containsKey("METAL")); + assertFalse(fr.isVisible(sf)); + + fr.findAllFeatures(true); + assertTrue(fr.isVisible(sf)); + + /* + * feature group not visible + */ + fr.setGroupVisibility("Group", false); + assertFalse(fr.isVisible(sf)); + fr.setGroupVisibility("Group", true); + assertTrue(fr.isVisible(sf)); + + /* + * feature score outwith colour threshold (score > 2) + */ + FeatureColourI fc = new FeatureColour(null, Color.white, Color.black, + Color.white, 0, 10); + fc.setAboveThreshold(true); + fc.setThreshold(2f); + fr.setColour("METAL", fc); + assertFalse(fr.isVisible(sf)); // score 1 is not above threshold 2 + fc.setBelowThreshold(true); + assertTrue(fr.isVisible(sf)); // score 1 is below threshold 2 + + /* + * colour with threshold on attribute AC (value is 11) + */ + fc.setAttributeName("AC"); + assertFalse(fr.isVisible(sf)); // value 11 is not below threshold 2 + fc.setAboveThreshold(true); + assertTrue(fr.isVisible(sf)); // value 11 is above threshold 2 + + fc.setAttributeName("AF"); // attribute AF is absent in sf + assertTrue(fr.isVisible(sf)); // feature is not excluded by threshold + + FeatureMatcherSetI filter = new FeatureMatcherSet(); + filter.and(FeatureMatcher.byAttribute(Condition.Contains, "pathogenic", + "CLIN_SIG")); + fr.setFeatureFilter("METAL", filter); + assertTrue(fr.isVisible(sf)); // feature matches filter + filter.and(FeatureMatcher.byScore(Condition.LE, "0.4")); + assertFalse(fr.isVisible(sf)); // feature doesn't match filter + } }