1 package jalview.analysis.scoremodels;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertFalse;
5 import static org.testng.Assert.assertTrue;
7 import jalview.api.analysis.PairwiseScoreModelI;
8 import jalview.api.analysis.ScoreModelI;
10 import java.util.Iterator;
12 import org.testng.annotations.Test;
14 public class ScoreModelsTest
17 * Verify that the singleton constructor successfully loads Jalview's built-in
20 @Test(groups = "Functional")
21 public void testConstructor()
23 Iterator<ScoreModelI> models = ScoreModels.getInstance().getModels()
25 assertTrue(models.hasNext());
28 * models are served in order of addition
30 ScoreModelI sm = models.next();
31 assertTrue(sm instanceof SimilarityScoreModel);
32 assertTrue(sm instanceof PairwiseScoreModelI);
33 assertFalse(sm instanceof DistanceScoreModel);
34 assertEquals(sm.getName(), "BLOSUM62");
35 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('I', 'R'), -3f);
38 assertTrue(sm instanceof SimilarityScoreModel);
39 assertTrue(sm instanceof PairwiseScoreModelI);
40 assertFalse(sm instanceof DistanceScoreModel);
41 assertEquals(sm.getName(), "PAM250");
42 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'C'), -4f);
45 assertTrue(sm instanceof SimilarityScoreModel);
46 assertTrue(sm instanceof PairwiseScoreModelI);
47 assertFalse(sm instanceof DistanceScoreModel);
48 assertEquals(sm.getName(), "PID");
49 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'C'), 0f);
50 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('R', 'r'), 1f);
53 assertTrue(sm instanceof SimilarityScoreModel);
54 assertTrue(sm instanceof PairwiseScoreModelI);
55 assertFalse(sm instanceof DistanceScoreModel);
56 assertEquals(sm.getName(), "DNA");
57 assertEquals(((PairwiseScoreModelI) sm).getPairwiseScore('c', 'x'), 1f);
60 assertFalse(sm instanceof SimilarityScoreModel);
61 assertFalse(sm instanceof PairwiseScoreModelI);
62 assertTrue(sm instanceof DistanceScoreModel);
63 assertEquals(sm.getName(), "Sequence Feature Similarity");
67 * 'Test' that prints out score matrices in tab-delimited format. This test is
68 * intentionally not assigned to any group so would not be run as part of a
69 * suite. It makes no assertions and is just provided as a utility method for
70 * printing out matrices. Relocated here from ScoreMatrixPrinter.
72 @Test(groups = "none")
73 public void printAllMatrices_tabDelimited()
75 printAllMatrices(false);
79 * 'Test' that prints out score matrices in html format. This test is
80 * intentionally not assigned to any group so would not be run as part of a
81 * suite. It makes no assertions and is just provided as a utility method for
82 * printing out matrices. Relocated here from ScoreMatrixPrinter.
84 @Test(groups = "none")
85 public void printAllMatrices_asHtml()
87 printAllMatrices(true);
91 * Print all registered ScoreMatrix as plain or html tables
95 protected void printAllMatrices(boolean asHtml)
97 for (ScoreModelI sm : ScoreModels.getInstance().getModels())
99 if (sm instanceof ScoreMatrix)
101 System.out.println(((ScoreMatrix) sm).outputMatrix(asHtml));