X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2Fscoremodels%2FFeatureScoreModelTest.java;h=309790fe71f117428bdf1dee12358a51e4f54e42;hb=528c0f1815bc67b54618ad5b16c2162946974caf;hp=4f71d5518142423daed1e44dda1e1550ba50109c;hpb=52288466dd1e71946a06fd1e6ea15fa8e652c693;p=jalview.git diff --git a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java index 4f71d55..309790f 100644 --- a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.analysis.scoremodels; import jalview.datamodel.AlignmentI; @@ -7,7 +27,7 @@ import jalview.gui.AlignFrame; import jalview.io.FileLoader; import jalview.io.FormatAdapter; -import org.testng.AssertJUnit; +import org.testng.Assert; import org.testng.annotations.Test; public class FeatureScoreModelTest @@ -20,14 +40,13 @@ 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); AlignmentI al = alf.getViewport().getAlignment(); - AssertJUnit.assertEquals(4, al.getHeight()); - AssertJUnit.assertEquals(5, al.getWidth()); + Assert.assertEquals(al.getHeight(), 4); + Assert.assertEquals(al.getWidth(), 5); for (int i = 0; i < 4; i++) { SequenceI ds = al.getSequenceAt(i).getDatasetSequence(); @@ -52,21 +71,70 @@ public class FeatureScoreModelTest alf.getFeatureRenderer().setVisible("sf2"); alf.getFeatureRenderer().setVisible("sf3"); alf.getFeatureRenderer().findAllFeatures(true); - AssertJUnit.assertEquals("Number of feature types", 3, alf - .getFeatureRenderer().getDisplayedFeatureTypes().length); - AssertJUnit.assertTrue(alf.getCurrentView().areFeaturesDisplayed()); + 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())); + 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_hiddenFirstColumn() throws Exception + { + AlignFrame alf = getTestAlignmentFrame(); + // hiding first two columns shouldn't affect the tree + alf.getViewport().hideColumns(0, 1); FeatureScoreModel fsm = new FeatureScoreModel(); - AssertJUnit.assertTrue(fsm.configureFromAlignmentView(alf - .getCurrentView().getAlignPanel())); + Assert.assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() + .getAlignPanel())); alf.selectAllSequenceMenuItem_actionPerformed(null); float[][] dm = fsm.findDistances(alf.getViewport().getAlignmentView( true)); - AssertJUnit.assertTrue("FER1_MESCR should be identical with RAPSA (2)", - dm[0][2] == 0f); - AssertJUnit - .assertTrue( - "FER1_MESCR should be further from SPIOL (1) than it is from RAPSA (2)", - dm[0][1] > dm[0][2]); + 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)"); + } } }