1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import org.testng.annotations.BeforeClass; |
28 |
|
import org.testng.annotations.BeforeMethod; |
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
31 |
|
import jalview.bin.Cache; |
32 |
|
import jalview.datamodel.Sequence; |
33 |
|
import jalview.datamodel.SequenceI; |
34 |
|
import jalview.gui.JvOptionPane; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (134) |
Complexity: 11 |
Complexity Density: 0.09 |
|
36 |
|
public class ComparisonTest |
37 |
|
{ |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
1 |
@BeforeClass(alwaysRun = true)... |
40 |
|
public void setUpJvOptionPane() |
41 |
|
{ |
42 |
1 |
JvOptionPane.setInteractiveMode(false); |
43 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
9 |
@BeforeMethod(alwaysRun = true)... |
47 |
|
public void loadProperties() |
48 |
|
{ |
49 |
9 |
Cache.loadProperties("test/jalview/util/comparisonTestProps.jvprops"); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
52 |
1 |
@Test(groups = { "Functional" })... |
53 |
|
public void testIsGap() |
54 |
|
{ |
55 |
1 |
assertTrue(Comparison.isGap('-')); |
56 |
1 |
assertTrue(Comparison.isGap('.')); |
57 |
1 |
assertTrue(Comparison.isGap(' ')); |
58 |
1 |
assertFalse(Comparison.isGap('X')); |
59 |
1 |
assertFalse(Comparison.isGap('x')); |
60 |
1 |
assertFalse(Comparison.isGap('*')); |
61 |
1 |
assertFalse(Comparison.isGap('G')); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
68 |
1 |
@Test(groups = { "Functional" })... |
69 |
|
public void testIsNucleotide_sequences() |
70 |
|
{ |
71 |
1 |
SequenceI seq = new Sequence("eightypercent+fivepercent", "agctuagcPV"); |
72 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
73 |
1 |
assertFalse( |
74 |
|
Comparison.isNucleotide(new SequenceI[][] |
75 |
|
{ new SequenceI[] { seq } })); |
76 |
|
|
77 |
1 |
seq = new Sequence("eightyfivepercent+tenpercent", |
78 |
|
"agctuagcgVagctuagcuVE"); |
79 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
80 |
|
|
81 |
1 |
seq = new Sequence(">nineyfivepercent+0percent", |
82 |
|
"aagctuagcgEagctuagcua"); |
83 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
84 |
|
|
85 |
1 |
seq = new Sequence("nineyfivepercent+0percent", "agctuagcgEagctuagcua"); |
86 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
87 |
|
|
88 |
1 |
seq = new Sequence("nineyfivepercent+fivepercent", |
89 |
|
"agctuagcgWagctuagcua"); |
90 |
1 |
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq })); |
91 |
|
|
92 |
1 |
seq = new Sequence("nineyfivepercent+tenpercent", |
93 |
|
"agctuagcgEWWctuagcua"); |
94 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
95 |
|
|
96 |
1 |
seq = new Sequence("eightyfivepercent+fifteenpercent", |
97 |
|
"agctuagcgWWWctuagcua"); |
98 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
99 |
|
|
100 |
1 |
seq = new Sequence("eightyfivepercentgapped", |
101 |
|
"--agc--tuA--GCPV-a---gct-uA-GC---UV"); |
102 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
103 |
|
|
104 |
1 |
seq = new Sequence("ninetyfivepercentgapped", |
105 |
|
"ag--ct-u-a---gc---g----aag--c---tuagcuV"); |
106 |
1 |
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq })); |
107 |
|
|
108 |
1 |
seq = new Sequence("allgap", "---------"); |
109 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
110 |
|
|
111 |
1 |
seq = new Sequence("DNA", "ACTugGCCAG"); |
112 |
1 |
SequenceI seq2 = new Sequence("Protein", "FLIMVSPTYW"); |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
1 |
assertFalse( |
117 |
|
Comparison.isNucleotide(new SequenceI[] |
118 |
|
{ seq, seq, seq, seq, seq, seq, seq, seq, seq, seq2 })); |
119 |
1 |
assertFalse( |
120 |
|
Comparison.isNucleotide(new SequenceI[][] |
121 |
|
{ new SequenceI[] { seq }, new SequenceI[] { seq, seq, seq }, |
122 |
|
new SequenceI[] |
123 |
|
{ seq, seq, seq, seq, seq, seq2 } })); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
1 |
assertFalse( |
128 |
|
Comparison.isNucleotide(new SequenceI[] |
129 |
|
{ seq, seq, seq, seq, seq, seq, seq, seq, seq2, seq2 })); |
130 |
1 |
assertFalse( |
131 |
|
Comparison.isNucleotide(new SequenceI[][] |
132 |
|
{ new SequenceI[] { seq }, new SequenceI[] { seq, seq, seq }, |
133 |
|
new SequenceI[] |
134 |
|
{ seq, seq, seq, seq, seq2, seq2, null } })); |
135 |
|
|
136 |
1 |
String seqString = "aaatatatatgEcctgagtcgt"; |
137 |
1 |
seq = new Sequence("ShortProteinThatLooksLikeDNA", seqString); |
138 |
1 |
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq })); |
139 |
1 |
seq = new Sequence("LongProteinThatLooksLikeDNA", seqString.repeat(10)); |
140 |
1 |
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq })); |
141 |
|
|
142 |
1 |
assertFalse(Comparison.isNucleotide((SequenceI[]) null)); |
143 |
1 |
assertFalse(Comparison.isNucleotide((SequenceI[][]) null)); |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
149 |
1 |
@Test(groups = { "Functional" })... |
150 |
|
public void testPID_includingGaps() |
151 |
|
{ |
152 |
1 |
String seq1 = "ABCDEFG"; |
153 |
1 |
String seq2 = "abcdef"; |
154 |
1 |
assertEquals("identical", 100f, Comparison.PID(seq1, seq2), 0.001f); |
155 |
|
|
156 |
|
|
157 |
1 |
seq2 = "abcdefghijklmnopqrstuvwxyz"; |
158 |
1 |
assertEquals("identical", 100f, Comparison.PID(seq1, seq2), 0.001f); |
159 |
|
|
160 |
|
|
161 |
1 |
seq1 = "a--b-cdefh"; |
162 |
1 |
seq2 = "a---bcdefg"; |
163 |
1 |
int length = seq1.length(); |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
1 |
assertEquals(90f, Comparison.PID(seq1, seq2, 0, length, true, false), |
168 |
|
0.001f); |
169 |
|
|
170 |
1 |
assertEquals(90f, Comparison.PID(seq1, seq2), 0.001f); |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
1 |
assertEquals(70f, Comparison.PID(seq1, seq2, 0, length, false, false), |
175 |
|
0.001f); |
176 |
|
} |
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
178 |
1 |
@Test(groups = { "Functional" })... |
179 |
|
public void testIsNucleotide() |
180 |
|
{ |
181 |
1 |
assertTrue(Comparison.isNucleotide('a')); |
182 |
1 |
assertTrue(Comparison.isNucleotide('A')); |
183 |
1 |
assertTrue(Comparison.isNucleotide('c')); |
184 |
1 |
assertTrue(Comparison.isNucleotide('C')); |
185 |
1 |
assertTrue(Comparison.isNucleotide('g')); |
186 |
1 |
assertTrue(Comparison.isNucleotide('G')); |
187 |
1 |
assertTrue(Comparison.isNucleotide('t')); |
188 |
1 |
assertTrue(Comparison.isNucleotide('T')); |
189 |
1 |
assertTrue(Comparison.isNucleotide('u')); |
190 |
1 |
assertTrue(Comparison.isNucleotide('U')); |
191 |
1 |
assertFalse(Comparison.isNucleotide('-')); |
192 |
1 |
assertFalse(Comparison.isNucleotide('P')); |
193 |
|
} |
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
195 |
1 |
@Test(groups = { "Functional" })... |
196 |
|
public void testIsNucleotideAmbiguity() |
197 |
|
{ |
198 |
1 |
assertTrue(Comparison.isNucleotide('b', true)); |
199 |
1 |
assertTrue(Comparison.isNucleotide('B', true)); |
200 |
1 |
assertTrue(Comparison.isNucleotide('d', true)); |
201 |
1 |
assertTrue(Comparison.isNucleotide('V', true)); |
202 |
1 |
assertTrue(Comparison.isNucleotide('M', true)); |
203 |
1 |
assertTrue(Comparison.isNucleotide('s', true)); |
204 |
1 |
assertTrue(Comparison.isNucleotide('W', true)); |
205 |
1 |
assertTrue(Comparison.isNucleotide('x', true)); |
206 |
1 |
assertTrue(Comparison.isNucleotide('Y', true)); |
207 |
1 |
assertTrue(Comparison.isNucleotide('r', true)); |
208 |
1 |
assertTrue(Comparison.isNucleotide('i', true)); |
209 |
1 |
assertFalse(Comparison.isNucleotide('-', true)); |
210 |
1 |
assertFalse(Comparison.isNucleotide('n', true)); |
211 |
1 |
assertFalse(Comparison.isNucleotide('P', true)); |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
217 |
1 |
@Test(groups = { "Functional" })... |
218 |
|
public void testPID_ungappedOnly() |
219 |
|
{ |
220 |
|
|
221 |
|
|
222 |
1 |
String seq1 = "a--b-cdefhr"; |
223 |
1 |
String seq2 = "a---bcdefg"; |
224 |
1 |
int length = seq1.length(); |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
1 |
assertEquals(87.5f, Comparison.PID(seq1, seq2, 0, length, true, true), |
237 |
|
0.001f); |
238 |
|
|
239 |
|
|
240 |
1 |
assertEquals(87.5f, Comparison.PID(seq1, seq2, 0, length, false, true), |
241 |
|
0.001f); |
242 |
|
} |
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
244 |
1 |
@Test(groups = { "Functional" })... |
245 |
|
public void testIsNucleotideSequence() |
246 |
|
{ |
247 |
1 |
assertFalse(Comparison.isNucleotideSequence(null, true)); |
248 |
1 |
assertTrue(Comparison.isNucleotideSequence("", true)); |
249 |
1 |
assertTrue(Comparison.isNucleotideSequence("aAgGcCtTuU", true)); |
250 |
1 |
assertTrue(Comparison.isNucleotideSequence("aAgGcCtTuU", false)); |
251 |
1 |
assertFalse(Comparison.isNucleotideSequence("xAgGcCtTuU", false)); |
252 |
1 |
assertFalse(Comparison.isNucleotideSequence("aAgGcCtTuUx", false)); |
253 |
1 |
assertTrue(Comparison.isNucleotideSequence("a A-g.GcCtTuU", true)); |
254 |
1 |
assertFalse(Comparison.isNucleotideSequence("a A-g.GcCtTuU", false)); |
255 |
1 |
assertFalse(Comparison.isNucleotideSequence("gatactawgataca", false)); |
256 |
|
|
257 |
1 |
assertTrue( |
258 |
|
Comparison.isNucleotideSequence("gatacaWgataca", true, true)); |
259 |
1 |
assertFalse( |
260 |
|
Comparison.isNucleotideSequence("gatacaEgataca", true, true)); |
261 |
|
|
262 |
|
|
263 |
1 |
Sequence seq = new Sequence("Ambiguity DNA codes", "gatacagatacabve"); |
264 |
1 |
assertFalse(Comparison.isNucleotide(seq)); |
265 |
|
|
266 |
1 |
seq = new Sequence("Ambiguity DNA codes", "gatacagatacabvt"); |
267 |
1 |
assertFalse(Comparison.isNucleotide(seq)); |
268 |
1 |
seq = new Sequence("Ambiguity DNA codes", "agatacabb"); |
269 |
1 |
assertFalse(Comparison.isNucleotide(seq)); |
270 |
|
|
271 |
1 |
assertTrue(Comparison |
272 |
|
.isNucleotide(new Sequence("dnaWithXs", "gatacaXXXX"))); |
273 |
1 |
assertTrue(Comparison |
274 |
|
.isNucleotide(new Sequence("dnaWithXs", "gatacaNNNN"))); |
275 |
1 |
assertFalse(Comparison |
276 |
|
.isNucleotide(new Sequence("dnaWithXs", "gatacXXXXX"))); |
277 |
1 |
assertFalse(Comparison |
278 |
|
.isNucleotide(new Sequence("dnaWithXs", "gatacNNNNN"))); |
279 |
|
} |
280 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
281 |
1 |
@Test(groups = { "Functional" })... |
282 |
|
public void testIsSameResidue() |
283 |
|
{ |
284 |
1 |
assertTrue(Comparison.isSameResidue('a', 'a', false)); |
285 |
1 |
assertTrue(Comparison.isSameResidue('a', 'a', true)); |
286 |
1 |
assertTrue(Comparison.isSameResidue('A', 'a', false)); |
287 |
1 |
assertTrue(Comparison.isSameResidue('a', 'A', false)); |
288 |
|
|
289 |
1 |
assertFalse(Comparison.isSameResidue('a', 'A', true)); |
290 |
1 |
assertFalse(Comparison.isSameResidue('A', 'a', true)); |
291 |
|
} |
292 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
293 |
1 |
@Test(groups = { "Functional" })... |
294 |
|
public void testNucleotideProportion() |
295 |
|
{ |
296 |
1 |
assertFalse(Comparison.myShortSequenceNucleotideProportionCount(2, 3)); |
297 |
1 |
assertTrue(Comparison.myShortSequenceNucleotideProportionCount(3, 3)); |
298 |
1 |
assertFalse(Comparison.myShortSequenceNucleotideProportionCount(2, 4)); |
299 |
1 |
assertTrue(Comparison.myShortSequenceNucleotideProportionCount(3, 4)); |
300 |
1 |
assertFalse( |
301 |
|
Comparison.myShortSequenceNucleotideProportionCount(17, 20)); |
302 |
1 |
assertTrue(Comparison.myShortSequenceNucleotideProportionCount(18, 20)); |
303 |
1 |
assertFalse( |
304 |
|
Comparison.myShortSequenceNucleotideProportionCount(38, 50)); |
305 |
1 |
assertTrue(Comparison.myShortSequenceNucleotideProportionCount(39, 50)); |
306 |
1 |
assertFalse( |
307 |
|
Comparison.myShortSequenceNucleotideProportionCount(54, 100)); |
308 |
1 |
assertTrue( |
309 |
|
Comparison.myShortSequenceNucleotideProportionCount(55, 100)); |
310 |
|
} |
311 |
|
} |