X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2Fscoremodels%2FFeatureScoreModelTest.java;fp=test%2Fjalview%2Fanalysis%2Fscoremodels%2FFeatureScoreModelTest.java;h=66eb5a51241dfa1c1143a94fabce71820d869d5b;hb=2595e9d4ee0dbbd3406a98c4e49a61ccde806479;hp=309790fe71f117428bdf1dee12358a51e4f54e42;hpb=e20075ba805d744d7cc4976e2b8d5e5840fb0a8d;p=jalview.git diff --git a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java index 309790f..66eb5a5 100644 --- a/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureScoreModelTest.java @@ -24,14 +24,26 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; +import jalview.gui.JvOptionPane; +import jalview.io.DataSourceType; import jalview.io.FileLoader; -import jalview.io.FormatAdapter; + +import java.util.Arrays; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class FeatureScoreModelTest { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + public static String alntestFile = "FER1_MESCR/72-76 DVYIL\nFER1_SPIOL/71-75 DVYIL\nFER3_RAPSA/21-25 DVYVL\nFER1_MAIZE/73-77 DVYIL\n"; int[] sf1 = new int[] { 74, 74, 73, 73, 23, 23, -1, -1 }; @@ -43,7 +55,7 @@ public class FeatureScoreModelTest public AlignFrame getTestAlignmentFrame() { AlignFrame alf = new FileLoader(false).LoadFileWaitTillLoaded( - alntestFile, FormatAdapter.PASTE); + alntestFile, DataSourceType.PASTE); AlignmentI al = alf.getViewport().getAlignment(); Assert.assertEquals(al.getHeight(), 4); Assert.assertEquals(al.getWidth(), 5); @@ -137,4 +149,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, DataSourceType.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); + } + }