From: Jim Procter Date: Sun, 24 Apr 2016 10:14:01 +0000 (+0100) Subject: JAL-2075 test showing hidden columns bug in feature score model X-Git-Tag: Release_2_10_0~249^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f2110aa168a187f3207ad4dee2ab54f92f39b984;p=jalview.git JAL-2075 test showing hidden columns bug in feature score model --- diff --git a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java index 7776ccb..029483f 100644 --- a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java @@ -40,8 +40,7 @@ public class FeatureScoreModelTest int[] sf3 = new int[] { -1, -1, -1, -1, -1, -1, 76, 77 }; - @Test(groups = { "Functional" }) - public void testFeatureScoreModel() throws Exception + public AlignFrame getTestAlignmentFrame() { AlignFrame alf = new FileLoader(false).LoadFileWaitTillLoaded( alntestFile, FormatAdapter.PASTE); @@ -75,6 +74,13 @@ public class FeatureScoreModelTest Assert.assertEquals(alf.getFeatureRenderer().getDisplayedFeatureTypes() .size(), 3, "Number of feature types"); Assert.assertTrue(alf.getCurrentView().areFeaturesDisplayed()); + return alf; + } + + @Test(groups = { "Functional" }) + public void testFeatureScoreModel() throws Exception + { + AlignFrame alf = getTestAlignmentFrame(); FeatureScoreModel fsm = new FeatureScoreModel(); Assert.assertTrue(fsm.configureFromAlignmentView(alf .getCurrentView().getAlignPanel())); @@ -85,6 +91,48 @@ public class FeatureScoreModelTest "FER1_MESCR (0) should be identical with RAPSA (2)"); Assert.assertTrue(dm[0][1] > dm[0][2], "FER1_MESCR (0) should be further from SPIOL (1) than it is from RAPSA (2)"); + } + @Test(groups = { "Functional" }) + public void testFeatureScoreModel_hiddenFirstColumn() throws Exception + { + AlignFrame alf = getTestAlignmentFrame(); + // hiding first two columns shouldn't affect the tree + alf.getViewport().hideColumns(0, 1); + FeatureScoreModel fsm = new FeatureScoreModel(); + Assert.assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() + .getAlignPanel())); + alf.selectAllSequenceMenuItem_actionPerformed(null); + float[][] dm = fsm.findDistances(alf.getViewport().getAlignmentView( + true)); + Assert.assertTrue(dm[0][2] == 0f, + "FER1_MESCR (0) should be identical with RAPSA (2)"); + Assert.assertTrue(dm[0][1] > dm[0][2], + "FER1_MESCR (0) should be further from SPIOL (1) than it is from RAPSA (2)"); + } + + @Test(groups = { "Functional" }) + public void testFeatureScoreModel_HiddenColumns() throws Exception + { + AlignFrame alf = getTestAlignmentFrame(); + // hide columns and check tree changes + alf.getViewport().hideColumns(3, 4); + alf.getViewport().hideColumns(0, 1); + FeatureScoreModel fsm = new FeatureScoreModel(); + Assert.assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() + .getAlignPanel())); + alf.selectAllSequenceMenuItem_actionPerformed(null); + float[][] dm = fsm.findDistances(alf.getViewport().getAlignmentView( + true)); + Assert.assertTrue(dm[0][2] == 0f, + "After hiding last two columns FER1_MESCR (0) should still be identical with RAPSA (2)"); + Assert.assertTrue(dm[0][1] == 0f, + "After hiding last two columns FER1_MESCR (0) should now also be identical with SPIOL (1)"); + for (int s=0;s<3;s++) + { + Assert.assertTrue(dm[s][3] > 0f, "After hiding last two columns " + + alf.getViewport().getAlignment().getSequenceAt(s).getName() + + "(" + s + ") should still be distinct from FER1_MAIZE (3)"); + } } }