1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import static org.testng.AssertJUnit.assertEquals; |
26 |
|
import static org.testng.AssertJUnit.assertFalse; |
27 |
|
import static org.testng.AssertJUnit.assertNull; |
28 |
|
import static org.testng.AssertJUnit.assertTrue; |
29 |
|
import static org.testng.AssertJUnit.fail; |
30 |
|
|
31 |
|
import jalview.analysis.SecStrConsensus.SimpleBP; |
32 |
|
import jalview.datamodel.SequenceFeature; |
33 |
|
import jalview.gui.JvOptionPane; |
34 |
|
|
35 |
|
import java.util.List; |
36 |
|
|
37 |
|
import org.testng.annotations.BeforeClass; |
38 |
|
import org.testng.annotations.Test; |
39 |
|
|
|
|
| 97.1% |
Uncovered Elements: 5 (170) |
Complexity: 81 |
Complexity Density: 0.67 |
|
40 |
|
public class RnaTest |
41 |
|
{ |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
43 |
1 |
@BeforeClass(alwaysRun = true)... |
44 |
|
public void setUpJvOptionPane() |
45 |
|
{ |
46 |
1 |
JvOptionPane.setInteractiveMode(false); |
47 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
50 |
1 |
@Test(groups = { "Functional" })... |
51 |
|
public void testGetSimpleBPs() throws WUSSParseException |
52 |
|
{ |
53 |
1 |
String rna = "([{})]"; |
54 |
1 |
List<SimpleBP> bps = Rna.getSimpleBPs(rna); |
55 |
1 |
assertEquals(3, bps.size()); |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
1 |
assertEquals(2, bps.get(0).bp5); |
62 |
1 |
assertEquals(3, bps.get(0).bp3); |
63 |
1 |
assertEquals(0, bps.get(1).bp5); |
64 |
1 |
assertEquals(4, bps.get(1).bp3); |
65 |
1 |
assertEquals(1, bps.get(2).bp5); |
66 |
1 |
assertEquals(5, bps.get(2).bp3); |
67 |
|
} |
68 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
1PASS
|
|
69 |
1 |
@Test(groups = { "Functional" })... |
70 |
|
public void testGetSimpleBPs_unmatchedOpener() |
71 |
|
{ |
72 |
1 |
String rna = "(([{})]"; |
73 |
1 |
try |
74 |
|
{ |
75 |
1 |
Rna.getSimpleBPs(rna); |
76 |
0 |
fail("expected exception"); |
77 |
|
} catch (WUSSParseException e) |
78 |
|
{ |
79 |
|
|
80 |
1 |
assertEquals(rna.length(), e.getProblemPos()); |
81 |
|
} |
82 |
|
} |
83 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.3 |
1PASS
|
|
84 |
1 |
@Test(groups = { "Functional" })... |
85 |
|
public void testGetSimpleBPs_unmatchedCloser() |
86 |
|
{ |
87 |
1 |
String rna = "([{})]]]"; |
88 |
1 |
try |
89 |
|
{ |
90 |
1 |
Rna.getSimpleBPs(rna); |
91 |
0 |
fail("expected exception"); |
92 |
|
} catch (WUSSParseException e) |
93 |
|
{ |
94 |
|
|
95 |
1 |
assertEquals(6, e.getProblemPos()); |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
1 |
rna = "((()])"; |
103 |
1 |
try |
104 |
|
{ |
105 |
1 |
Rna.getSimpleBPs(rna); |
106 |
0 |
fail("expected exception"); |
107 |
|
} catch (WUSSParseException e) |
108 |
|
{ |
109 |
1 |
assertEquals(4, e.getProblemPos()); |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 7 |
Complexity Density: 0.88 |
1PASS
|
|
113 |
1 |
@Test(groups = { "Functional" })... |
114 |
|
public void testGetRNASecStrucState() |
115 |
|
{ |
116 |
1 |
assertNull(Rna.getRNASecStrucState(null)); |
117 |
257 |
for (int i = 0; i <= 255; i++) |
118 |
|
{ |
119 |
256 |
String s = String.valueOf((char) i); |
120 |
256 |
String ss = Rna.getRNASecStrucState(s); |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
256 |
if ((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') |
127 |
|
|| "()[]{}<>".indexOf(s) > -1) |
128 |
|
{ |
129 |
60 |
assertEquals("" + i, s, ss); |
130 |
|
} |
131 |
|
else |
132 |
|
{ |
133 |
196 |
assertEquals(" ", ss); |
134 |
|
} |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
1 |
assertEquals("a [K ]z} {Q b(w)p><i", |
141 |
|
Rna.getRNASecStrucState("a.[K-]z}?{Q b(w)p><i")); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 8 |
Complexity Density: 0.8 |
1PASS
|
|
147 |
1 |
@Test(groups = { "Functional" })... |
148 |
|
public void testIsClosingParenthesis() |
149 |
|
{ |
150 |
1 |
assertFalse(Rna.isClosingParenthesis(null)); |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
257 |
for (int i = 0; i <= 255; i++) |
156 |
|
{ |
157 |
256 |
boolean isClosingChar = Rna.isClosingParenthesis((char) i); |
158 |
256 |
boolean isClosingString = Rna |
159 |
|
.isClosingParenthesis(String.valueOf((char) i)); |
160 |
256 |
if ((i >= 'a' && i <= 'z') || i == ')' || i == '}' || i == ']' |
161 |
|
|| i == '>') |
162 |
|
{ |
163 |
30 |
assertTrue(String.format("close base pair %c", i), isClosingChar); |
164 |
30 |
assertTrue(String.format("close base pair %c", i), isClosingString); |
165 |
|
} |
166 |
|
else |
167 |
|
{ |
168 |
226 |
assertFalse(String.format("close base pair %c", i), isClosingChar); |
169 |
226 |
assertFalse(String.format("close base pair %c", i), |
170 |
|
isClosingString); |
171 |
|
} |
172 |
256 |
assertFalse(Rna.isClosingParenthesis(String.valueOf((char) i) + " ")); |
173 |
|
} |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 13 |
Complexity Density: 1.3 |
1PASS
|
|
176 |
1 |
@Test(groups = { "Functional" })... |
177 |
|
public void testIsCanonicalOrWobblePair() |
178 |
|
{ |
179 |
1 |
String bases = "acgtuACGTU"; |
180 |
11 |
for (int i = 0; i < bases.length(); i++) |
181 |
|
{ |
182 |
110 |
for (int j = 0; j < bases.length(); j++) |
183 |
|
{ |
184 |
100 |
char first = bases.charAt(i); |
185 |
100 |
char second = bases.charAt(j); |
186 |
100 |
boolean result = Rna.isCanonicalOrWobblePair(first, second); |
187 |
100 |
String pair = new String(new char[] { first, second }) |
188 |
|
.toUpperCase(Locale.ROOT); |
189 |
100 |
if (pair.equals("AT") || pair.equals("TA") || pair.equals("AU") |
190 |
|
|| pair.equals("UA") || pair.equals("GC") |
191 |
|
|| pair.equals("CG") || pair.equals("GT") |
192 |
|
|| pair.equals("TG") || pair.equals("GU") |
193 |
|
|| pair.equals("UG")) |
194 |
|
{ |
195 |
40 |
assertTrue(pair + " should be valid", result); |
196 |
|
} |
197 |
|
else |
198 |
|
{ |
199 |
60 |
assertFalse(pair + " should be invalid", result); |
200 |
|
} |
201 |
|
} |
202 |
|
} |
203 |
|
} |
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 9 |
Complexity Density: 0.9 |
1PASS
|
|
205 |
1 |
@Test(groups = { "Functional" })... |
206 |
|
public void testIsCanonicalPair() |
207 |
|
{ |
208 |
1 |
String bases = "acgtuACGTU"; |
209 |
11 |
for (int i = 0; i < bases.length(); i++) |
210 |
|
{ |
211 |
110 |
for (int j = 0; j < bases.length(); j++) |
212 |
|
{ |
213 |
100 |
char first = bases.charAt(i); |
214 |
100 |
char second = bases.charAt(j); |
215 |
100 |
boolean result = Rna.isCanonicalPair(first, second); |
216 |
100 |
String pair = new String(new char[] { first, second }) |
217 |
|
.toUpperCase(Locale.ROOT); |
218 |
100 |
if (pair.equals("AT") || pair.equals("TA") || pair.equals("AU") |
219 |
|
|| pair.equals("UA") || pair.equals("GC") |
220 |
|
|| pair.equals("CG")) |
221 |
|
{ |
222 |
24 |
assertTrue(pair + " should be valid", result); |
223 |
|
} |
224 |
|
else |
225 |
|
{ |
226 |
76 |
assertFalse(pair + " should be invalid", result); |
227 |
|
} |
228 |
|
} |
229 |
|
} |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 8 |
Complexity Density: 0.89 |
1PASS
|
|
235 |
1 |
@Test(groups = { "Functional" })... |
236 |
|
public void testIsOpeningParenthesis() |
237 |
|
{ |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
257 |
for (int i = 0; i <= 255; i++) |
242 |
|
{ |
243 |
256 |
boolean isOpeningChar = Rna.isOpeningParenthesis((char) i); |
244 |
256 |
boolean isOpeningString = Rna |
245 |
|
.isOpeningParenthesis(String.valueOf((char) i)); |
246 |
256 |
if ((i >= 'A' && i <= 'Z') || i == '(' || i == '{' || i == '[' |
247 |
|
|| i == '<') |
248 |
|
{ |
249 |
30 |
assertTrue(String.format("Open base pair %c", i), isOpeningChar); |
250 |
30 |
assertTrue(String.format("Open base pair %c", i), isOpeningString); |
251 |
|
} |
252 |
|
else |
253 |
|
{ |
254 |
226 |
assertFalse(String.format("Open base pair %c", i), isOpeningChar); |
255 |
226 |
assertFalse(String.format("Open base pair %c", i), isOpeningString); |
256 |
|
} |
257 |
256 |
assertFalse(Rna.isOpeningParenthesis(String.valueOf((char) i) + " ")); |
258 |
|
} |
259 |
|
} |
260 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 13 |
Complexity Density: 1.62 |
1PASS
|
|
261 |
1 |
@Test(groups = { "Functional" })... |
262 |
|
public void testGetMatchingOpeningParenthesis() throws WUSSParseException |
263 |
|
{ |
264 |
257 |
for (int i = 0; i <= 255; i++) |
265 |
|
{ |
266 |
256 |
boolean isClosing = Rna.isClosingParenthesis((char) i); |
267 |
256 |
if (isClosing) |
268 |
|
{ |
269 |
30 |
char opening = Rna.getMatchingOpeningParenthesis((char) i); |
270 |
30 |
if (i >= 'a' && i <= 'z') |
271 |
|
{ |
272 |
26 |
assertEquals(i + 'A' - 'a', opening); |
273 |
|
} |
274 |
4 |
else if (i == ')' && opening == '(' || i == ']' && opening == '[' |
275 |
|
|| i == '}' && opening == '{' || i == '>' && opening == '<') |
276 |
|
{ |
277 |
|
|
278 |
|
} |
279 |
|
else |
280 |
|
{ |
281 |
0 |
fail("Got " + opening + " as opening bracket pair for " |
282 |
|
+ ((char) i)); |
283 |
|
} |
284 |
|
} |
285 |
|
} |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 14 |
Complexity Density: 1.4 |
1PASS
|
|
291 |
1 |
@Test(groups = { "Functional" })... |
292 |
|
public void testIsRnaSecondaryStructureSymbol() |
293 |
|
{ |
294 |
1 |
assertFalse(Rna.isRnaSecondaryStructureSymbol(null)); |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
257 |
for (int i = 0; i <= 255; i++) |
300 |
|
{ |
301 |
256 |
boolean isValidChar = Rna.isRnaSecondaryStructureSymbol((char) i); |
302 |
256 |
boolean isValidString = Rna |
303 |
|
.isRnaSecondaryStructureSymbol(String.valueOf((char) i)); |
304 |
256 |
if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || i == '(' |
305 |
|
|| i == ')' || i == '{' || i == '}' || i == '[' || i == ']' |
306 |
|
|| i == '<' || i == '>') |
307 |
|
{ |
308 |
60 |
assertTrue(String.format("close base pair %c", i), isValidChar); |
309 |
60 |
assertTrue(String.format("close base pair %c", i), isValidString); |
310 |
|
} |
311 |
|
else |
312 |
|
{ |
313 |
196 |
assertFalse(String.format("close base pair %c", i), isValidChar); |
314 |
196 |
assertFalse(String.format("close base pair %c", i), isValidString); |
315 |
|
} |
316 |
256 |
assertFalse(Rna.isRnaSecondaryStructureSymbol( |
317 |
|
String.valueOf((char) i) + " ")); |
318 |
|
} |
319 |
|
} |
320 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
321 |
1 |
@Test(groups = "Functional")... |
322 |
|
public void testGetHelixMap_oneHelix() throws WUSSParseException |
323 |
|
{ |
324 |
1 |
String rna = ".(..[{.<..>}..].)"; |
325 |
1 |
SequenceFeature[] sfs = Rna.getHelixMap(rna); |
326 |
1 |
assertEquals(4, sfs.length); |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
1 |
assertEquals(7, sfs[0].getBegin()); |
333 |
1 |
assertEquals(10, sfs[0].getEnd()); |
334 |
1 |
assertEquals("0", sfs[0].getFeatureGroup()); |
335 |
1 |
assertEquals(5, sfs[1].getBegin()); |
336 |
1 |
assertEquals(11, sfs[1].getEnd()); |
337 |
1 |
assertEquals("0", sfs[1].getFeatureGroup()); |
338 |
1 |
assertEquals(4, sfs[2].getBegin()); |
339 |
1 |
assertEquals(14, sfs[2].getEnd()); |
340 |
1 |
assertEquals("0", sfs[2].getFeatureGroup()); |
341 |
1 |
assertEquals(1, sfs[3].getBegin()); |
342 |
1 |
assertEquals(16, sfs[3].getEnd()); |
343 |
1 |
assertEquals("0", sfs[3].getFeatureGroup()); |
344 |
|
} |
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
346 |
1 |
@Test(groups = "Functional")... |
347 |
|
public void testGetHelixMap_twoHelices() throws WUSSParseException |
348 |
|
{ |
349 |
1 |
String rna = ".([.)]..{.<}.>"; |
350 |
1 |
SequenceFeature[] sfs = Rna.getHelixMap(rna); |
351 |
1 |
assertEquals(4, sfs.length); |
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
1 |
assertEquals(1, sfs[0].getBegin()); |
358 |
1 |
assertEquals(4, sfs[0].getEnd()); |
359 |
1 |
assertEquals("0", sfs[0].getFeatureGroup()); |
360 |
1 |
assertEquals(2, sfs[1].getBegin()); |
361 |
1 |
assertEquals(5, sfs[1].getEnd()); |
362 |
1 |
assertEquals("0", sfs[1].getFeatureGroup()); |
363 |
1 |
assertEquals(8, sfs[2].getBegin()); |
364 |
1 |
assertEquals(11, sfs[2].getEnd()); |
365 |
1 |
assertEquals("1", sfs[2].getFeatureGroup()); |
366 |
1 |
assertEquals(10, sfs[3].getBegin()); |
367 |
1 |
assertEquals(13, sfs[3].getEnd()); |
368 |
1 |
assertEquals("1", sfs[3].getFeatureGroup()); |
369 |
|
} |
370 |
|
} |