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 static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertFalse;
25 import static org.testng.Assert.assertTrue;
27 import jalview.api.analysis.PairwiseScoreModelI;
28 import jalview.api.analysis.ScoreModelI;
30 import java.util.Iterator;
32 import org.testng.annotations.Test;
34 public class ScoreModelsTest
37 * Verify that the singleton constructor successfully loads Jalview's built-in
40 @Test(groups = "Functional")
41 public void testConstructor()
43 Iterator<ScoreModelI> models = ScoreModels.getInstance().getModels()
45 assertTrue(models.hasNext());
48 * models are served in order of addition
50 ScoreModelI sm = models.next();
51 assertTrue(sm instanceof SimilarityScoreModel);
52 assertTrue(sm instanceof PairwiseScoreModelI);
53 assertFalse(sm instanceof DistanceScoreModel);
54 assertEquals(sm.getName(), "BLOSUM62");
55 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('I', 'R'),
59 assertTrue(sm instanceof SimilarityScoreModel);
60 assertTrue(sm instanceof PairwiseScoreModelI);
61 assertFalse(sm instanceof DistanceScoreModel);
62 assertEquals(sm.getName(), "PAM250");
63 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'C'),
67 assertTrue(sm instanceof SimilarityScoreModel);
68 assertTrue(sm instanceof PairwiseScoreModelI);
69 assertFalse(sm instanceof DistanceScoreModel);
70 assertEquals(sm.getName(), "DNA");
71 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('c', 'x'), 1f);
74 assertTrue(sm instanceof SimilarityScoreModel);
75 assertTrue(sm instanceof PairwiseScoreModelI);
76 assertFalse(sm instanceof DistanceScoreModel);
77 assertEquals(sm.getName(), "PID");
78 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'C'), 0f);
79 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'r'), 1f);
82 assertFalse(sm instanceof SimilarityScoreModel);
83 assertFalse(sm instanceof PairwiseScoreModelI);
84 assertTrue(sm instanceof DistanceScoreModel);
85 assertEquals(sm.getName(), "Sequence Feature Similarity");
89 * 'Test' that prints out score matrices in tab-delimited format. This test is
90 * intentionally not assigned to any group so would not be run as part of a
91 * suite. It makes no assertions and is just provided as a utility method for
92 * printing out matrices. Relocated here from ScoreMatrixPrinter.
94 @Test(groups = "none")
95 public void printAllMatrices_tabDelimited()
97 printAllMatrices(false);
101 * 'Test' that prints out score matrices in html format. This test is
102 * intentionally not assigned to any group so would not be run as part of a
103 * suite. It makes no assertions and is just provided as a utility method for
104 * printing out matrices. Relocated here from ScoreMatrixPrinter.
106 @Test(groups = "none")
107 public void printAllMatrices_asHtml()
109 printAllMatrices(true);
113 * Print all registered ScoreMatrix as plain or html tables
117 protected void printAllMatrices(boolean asHtml)
119 for (ScoreModelI sm : ScoreModels.getInstance().getModels())
121 if (sm instanceof ScoreMatrix)
123 System.out.println(((ScoreMatrix) sm).outputMatrix(asHtml));