2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.analysis.scoremodels;
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.SequenceFeature;
25 import jalview.datamodel.SequenceI;
26 import jalview.gui.AlignFrame;
27 import jalview.io.FileLoader;
28 import jalview.io.FormatAdapter;
30 import org.testng.AssertJUnit;
31 import org.testng.annotations.Test;
33 public class FeatureScoreModelTest
35 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";
37 int[] sf1 = new int[] { 74, 74, 73, 73, 23, 23, -1, -1 };
39 int[] sf2 = new int[] { -1, -1, 74, 75, -1, -1, 76, 77 };
41 int[] sf3 = new int[] { -1, -1, -1, -1, -1, -1, 76, 77 };
43 @Test(groups = { "Functional" })
44 public void testFeatureScoreModel() throws Exception
46 AlignFrame alf = new FileLoader(false).LoadFileWaitTillLoaded(
47 alntestFile, FormatAdapter.PASTE);
48 AlignmentI al = alf.getViewport().getAlignment();
49 AssertJUnit.assertEquals(4, al.getHeight());
50 AssertJUnit.assertEquals(5, al.getWidth());
51 for (int i = 0; i < 4; i++)
53 SequenceI ds = al.getSequenceAt(i).getDatasetSequence();
56 ds.addSequenceFeature(new SequenceFeature("sf1", "sf1", "sf1",
57 sf1[i * 2], sf1[i * 2 + 1], "sf1"));
61 ds.addSequenceFeature(new SequenceFeature("sf2", "sf2", "sf2",
62 sf2[i * 2], sf2[i * 2 + 1], "sf2"));
66 ds.addSequenceFeature(new SequenceFeature("sf3", "sf3", "sf3",
67 sf3[i * 2], sf3[i * 2 + 1], "sf3"));
70 alf.setShowSeqFeatures(true);
71 alf.getFeatureRenderer().setVisible("sf1");
72 alf.getFeatureRenderer().setVisible("sf2");
73 alf.getFeatureRenderer().setVisible("sf3");
74 alf.getFeatureRenderer().findAllFeatures(true);
75 AssertJUnit.assertEquals("Number of feature types", 3, alf
76 .getFeatureRenderer().getDisplayedFeatureTypes().size());
77 AssertJUnit.assertTrue(alf.getCurrentView().areFeaturesDisplayed());
78 FeatureScoreModel fsm = new FeatureScoreModel();
79 AssertJUnit.assertTrue(fsm.configureFromAlignmentView(alf
80 .getCurrentView().getAlignPanel()));
81 alf.selectAllSequenceMenuItem_actionPerformed(null);
82 float[][] dm = fsm.findDistances(alf.getViewport().getAlignmentView(
84 AssertJUnit.assertTrue("FER1_MESCR should be identical with RAPSA (2)",
88 "FER1_MESCR should be further from SPIOL (1) than it is from RAPSA (2)",