From 2fb8ded1937a137d5bb33abfd8f103ff4edd9747 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 21 Nov 2016 16:22:19 +0000 Subject: [PATCH] JAL-2335 failing test for FeatureRendererModel.findFeaturesAt and contact features --- .../scoremodels/FeatureScoreModelTest.java | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java index 309790f..292b576 100644 --- a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java @@ -27,6 +27,8 @@ import jalview.gui.AlignFrame; import jalview.io.FileLoader; import jalview.io.FormatAdapter; +import java.util.Arrays; + import org.testng.Assert; import org.testng.annotations.Test; @@ -137,4 +139,45 @@ public class FeatureScoreModelTest + "(" + s + ") should still be distinct from FER1_MAIZE (3)"); } } + + /** + * Check findFeatureAt doesn't return contact features except at contact + * points TODO:move to under the FeatureRendererModel test suite + */ + @Test(groups = { "Functional" }) + public void testFindFeatureAt_PointFeature() throws Exception + { + String alignment = "a CCCCCCGGGGGGCCCCCC\n" + "b CCCCCCGGGGGGCCCCCC\n" + + "c CCCCCCGGGGGGCCCCCC\n"; + AlignFrame af = new jalview.io.FileLoader(false) + .LoadFileWaitTillLoaded(alignment, FormatAdapter.PASTE); + SequenceI aseq = af.getViewport().getAlignment().getSequenceAt(0); + SequenceFeature sf = null; + sf = new SequenceFeature("disulphide bond", "", 2, 5, Float.NaN, ""); + aseq.addSequenceFeature(sf); + Assert.assertTrue(sf.isContactFeature()); + af.refreshFeatureUI(true); + af.getFeatureRenderer().setAllVisible(Arrays.asList("disulphide bond")); + Assert.assertEquals(af.getFeatureRenderer().getDisplayedFeatureTypes() + .size(), 1, "Should be just one feature type displayed"); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 1) + .size(), 0); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 2) + .size(), 1); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 3) + .size(), 0); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 4) + .size(), 0); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 5) + .size(), 1); + // step through and check for pointwise feature presence/absence + Assert.assertEquals(af.getFeatureRenderer().findFeaturesAtRes(aseq, 6) + .size(), 0); + } + } -- 1.7.10.2