X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2Fscoremodels%2FFeatureScoreModelTest.java;h=292b5760471dd6b34e72f455676e289364469321;hb=2fb8ded1937a137d5bb33abfd8f103ff4edd9747;hp=7776ccbd590e6468c88852916c29f2c4fc1472d6;hpb=a8ab01a310aa5c5cbbceef54f6ea6705fe427853;p=jalview.git diff --git a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java index 7776ccb..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; @@ -40,8 +42,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,9 +76,34 @@ 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())); + 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(); - Assert.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)); @@ -85,6 +111,73 @@ 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_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)"); + } + } + + /** + * 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); } + }