Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 16:12:26 GMT
  2. Package jalview.gui

File CalculationChooserTest.java

 

Code metrics

4
48
2
1
142
85
4
0.08
24
2
2

Classes

Class Line # Actions
CalculationChooserTest 35 48 4
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.gui;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertSame;
25   
26    import jalview.analysis.scoremodels.ScoreModels;
27    import jalview.api.analysis.ScoreModelI;
28    import jalview.bin.Cache;
29   
30    import java.util.List;
31   
32    import org.testng.annotations.BeforeClass;
33    import org.testng.annotations.Test;
34   
 
35    public class CalculationChooserTest
36    {
 
37  1 toggle @BeforeClass(alwaysRun = true)
38    public void setUp()
39    {
40    // read-only Jalview properties
41  1 Cache.loadProperties("test/jalview/io/testProps.jvprops");
42  1 Cache.applicationProperties.setProperty("BLOSUM62_PCA_FOR_NUCLEOTIDE",
43    Boolean.FALSE.toString());
44    }
45   
 
46  1 toggle @Test(groups = "Functional")
47    public void testGetApplicableScoreModels()
48    {
49  1 ScoreModels models = ScoreModels.getInstance();
50  1 ScoreModelI blosum62 = models.getBlosum62();
51  1 ScoreModelI pam250 = models.getPam250();
52  1 ScoreModelI dna = models.getDefaultModel(false);
53   
54    /*
55    * peptide models for PCA
56    */
57  1 List<ScoreModelI> filtered = CalculationChooser
58    .getApplicableScoreModels(false, true, true, false);
59  1 assertEquals(filtered.size(), 5);
60  1 assertSame(filtered.get(0), blosum62);
61  1 assertSame(filtered.get(1), pam250);
62  1 assertEquals(filtered.get(2).getName(), "PID");
63  1 assertEquals(filtered.get(3).getName(), "Sequence Feature Similarity");
64  1 assertEquals(filtered.get(4).getName(),
65    "Secondary Structure Similarity");
66   
67    /*
68    * peptide models for Tree are the same
69    */
70  1 filtered = CalculationChooser.getApplicableScoreModels(false, false,
71    true, false);
72  1 assertEquals(filtered.size(), 5);
73  1 assertSame(filtered.get(0), blosum62);
74  1 assertSame(filtered.get(1), pam250);
75  1 assertEquals(filtered.get(2).getName(), "PID");
76  1 assertEquals(filtered.get(3).getName(), "Sequence Feature Similarity");
77  1 assertEquals(filtered.get(4).getName(),
78    "Secondary Structure Similarity");
79   
80    /*
81    * nucleotide models for PCA
82    */
83  1 filtered = CalculationChooser.getApplicableScoreModels(true, true,
84    false, false);
85  1 assertEquals(filtered.size(), 3);
86  1 assertSame(filtered.get(0), dna);
87  1 assertEquals(filtered.get(1).getName(), "PID");
88  1 assertEquals(filtered.get(2).getName(), "Sequence Feature Similarity");
89   
90    /*
91    * nucleotide models for Tree are the same
92    */
93  1 filtered = CalculationChooser.getApplicableScoreModels(true, false,
94    false, false);
95  1 assertEquals(filtered.size(), 3);
96  1 assertSame(filtered.get(0), dna);
97  1 assertEquals(filtered.get(1).getName(), "PID");
98  1 assertEquals(filtered.get(2).getName(), "Sequence Feature Similarity");
99   
100    /*
101    * enable inclusion of BLOSUM62 for nucleotide PCA (JAL-2962)
102    */
103  1 Cache.applicationProperties.setProperty("BLOSUM62_PCA_FOR_NUCLEOTIDE",
104    Boolean.TRUE.toString());
105   
106    /*
107    * nucleotide models for Tree are unchanged
108    */
109  1 filtered = CalculationChooser.getApplicableScoreModels(true, false,
110    true, false);
111  1 assertEquals(filtered.size(), 4);
112  1 assertSame(filtered.get(0), dna);
113  1 assertEquals(filtered.get(1).getName(), "PID");
114  1 assertEquals(filtered.get(2).getName(), "Sequence Feature Similarity");
115  1 assertEquals(filtered.get(3).getName(),
116    "Secondary Structure Similarity");
117   
118    /*
119    * nucleotide models for PCA add BLOSUM62 as last option
120    */
121  1 filtered = CalculationChooser.getApplicableScoreModels(true, true,
122    false, false);
123  1 assertEquals(filtered.size(), 4);
124  1 assertSame(filtered.get(0), dna);
125  1 assertEquals(filtered.get(1).getName(), "PID");
126  1 assertEquals(filtered.get(2).getName(), "Sequence Feature Similarity");
127  1 assertSame(filtered.get(3), blosum62);
128   
129  1 filtered = CalculationChooser.getApplicableScoreModels(true, true,
130    false, true);
131  1 assertEquals(filtered.size(), 1); // DNA matrix for DNA pasimap
132  10 for (int i = 0; i <= 8; i++)
133    {
134  9 boolean isDna = (i & 1) != 0, isPca = (i & 2) != 0,
135    isSS = (i & 4) != 0;
136   
137  9 assertEquals(CalculationChooser
138    .getApplicableScoreModels(isDna, isPca, isSS, true).size(),
139  9 (isDna) ? 1 : 2);
140    }
141    }
142    }