1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
|
26 |
|
import jalview.gui.JvOptionPane; |
27 |
|
import jalview.util.MapList; |
28 |
|
|
29 |
|
import java.util.Iterator; |
30 |
|
|
31 |
|
import org.testng.Assert; |
32 |
|
import org.testng.annotations.BeforeClass; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@author |
39 |
|
|
40 |
|
|
|
|
| 98.9% |
Uncovered Elements: 1 (92) |
Complexity: 7 |
Complexity Density: 0.08 |
|
41 |
|
public class AlignedCodonIteratorTest |
42 |
|
{ |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
1 |
@BeforeClass(alwaysRun = true)... |
45 |
|
public void setUpJvOptionPane() |
46 |
|
{ |
47 |
1 |
JvOptionPane.setInteractiveMode(false); |
48 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
54 |
1 |
@Test(groups = { "Functional" })... |
55 |
|
public void testNext() |
56 |
|
{ |
57 |
1 |
SequenceI from = new Sequence("Seq1", "-CgC-C-cCtAG-AtG-Gc"); |
58 |
1 |
from.createDatasetSequence(); |
59 |
1 |
SequenceI to = new Sequence("Seq1", "-PQ-R-"); |
60 |
1 |
to.createDatasetSequence(); |
61 |
1 |
MapList map = new MapList(new int[] { 1, 1, 3, 4, 6, 6, 8, 10, 12, 13 }, |
62 |
|
new int[] |
63 |
|
{ 1, 3 }, 3, 1); |
64 |
1 |
Mapping m = new Mapping(to.getDatasetSequence(), map); |
65 |
|
|
66 |
1 |
Iterator<AlignedCodon> codons = m.getCodonIterator(from, '-'); |
67 |
1 |
AlignedCodon codon = codons.next(); |
68 |
1 |
assertEquals("[1, 3, 5]", codon.toString()); |
69 |
1 |
assertEquals("P", codon.product); |
70 |
1 |
codon = codons.next(); |
71 |
1 |
assertEquals("[8, 10, 11]", codon.toString()); |
72 |
1 |
assertEquals("Q", codon.product); |
73 |
1 |
codon = codons.next(); |
74 |
1 |
assertEquals("[13, 15, 17]", codon.toString()); |
75 |
1 |
assertEquals("R", codon.product); |
76 |
1 |
assertFalse(codons.hasNext()); |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
82 |
1 |
@Test(groups = { "Functional" })... |
83 |
|
public void testNext_unmappedPeptide() |
84 |
|
{ |
85 |
1 |
SequenceI from = new Sequence("Seq1", "-CgC-C-cCtAG-AtG-Gc"); |
86 |
1 |
from.createDatasetSequence(); |
87 |
1 |
SequenceI to = new Sequence("Seq1", "-PQ-TR-"); |
88 |
1 |
to.createDatasetSequence(); |
89 |
1 |
MapList map = new MapList(new int[] { 1, 1, 3, 4, 6, 6, 8, 10, 12, 13 }, |
90 |
|
new int[] |
91 |
|
{ 1, 2, 4, 4 }, 3, 1); |
92 |
1 |
Mapping m = new Mapping(to.getDatasetSequence(), map); |
93 |
|
|
94 |
1 |
Iterator<AlignedCodon> codons = m.getCodonIterator(from, '-'); |
95 |
1 |
AlignedCodon codon = codons.next(); |
96 |
1 |
assertEquals("[1, 3, 5]", codon.toString()); |
97 |
1 |
assertEquals("P", codon.product); |
98 |
1 |
codon = codons.next(); |
99 |
1 |
assertEquals("[8, 10, 11]", codon.toString()); |
100 |
1 |
assertEquals("Q", codon.product); |
101 |
1 |
codon = codons.next(); |
102 |
1 |
assertEquals("[13, 15, 17]", codon.toString()); |
103 |
1 |
assertEquals("R", codon.product); |
104 |
1 |
assertFalse(codons.hasNext()); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 2 |
Complexity Density: 0.15 |
1PASS
|
|
110 |
1 |
@Test(groups = { "Functional" })... |
111 |
|
public void testNext_incompleteCodon() |
112 |
|
{ |
113 |
1 |
SequenceI from = new Sequence("Seq1", "-CgC-C-cCgTt"); |
114 |
1 |
from.createDatasetSequence(); |
115 |
1 |
SequenceI to = new Sequence("Seq1", "-PQ-R-"); |
116 |
1 |
to.createDatasetSequence(); |
117 |
1 |
MapList map = new MapList(new int[] { 1, 1, 3, 4, 6, 6, 8, 8 }, |
118 |
|
new int[] |
119 |
|
{ 1, 3 }, 3, 1); |
120 |
1 |
Mapping m = new Mapping(to.getDatasetSequence(), map); |
121 |
|
|
122 |
1 |
Iterator<AlignedCodon> codons = m.getCodonIterator(from, '-'); |
123 |
1 |
AlignedCodon codon = codons.next(); |
124 |
1 |
assertEquals("[1, 3, 5]", codon.toString()); |
125 |
1 |
assertEquals("P", codon.product); |
126 |
1 |
try |
127 |
|
{ |
128 |
1 |
codon = codons.next(); |
129 |
0 |
Assert.fail("expected exception"); |
130 |
|
} catch (IncompleteCodonException e) |
131 |
|
{ |
132 |
|
|
133 |
|
} |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
139 |
1 |
@Test(groups = { "Functional" })... |
140 |
|
public void testAnother() |
141 |
|
{ |
142 |
1 |
SequenceI from = new Sequence("Seq1", "TGCCATTACCAG-"); |
143 |
1 |
from.createDatasetSequence(); |
144 |
1 |
SequenceI to = new Sequence("Seq1", "CHYQ"); |
145 |
1 |
to.createDatasetSequence(); |
146 |
1 |
MapList map = new MapList(new int[] { 1, 12 }, new int[] { 1, 4 }, 3, |
147 |
|
1); |
148 |
1 |
Mapping m = new Mapping(to.getDatasetSequence(), map); |
149 |
|
|
150 |
1 |
Iterator<AlignedCodon> codons = m.getCodonIterator(from, '-'); |
151 |
1 |
AlignedCodon codon = codons.next(); |
152 |
1 |
assertEquals("[0, 1, 2]", codon.toString()); |
153 |
1 |
assertEquals("C", codon.product); |
154 |
1 |
codon = codons.next(); |
155 |
1 |
assertEquals("[3, 4, 5]", codon.toString()); |
156 |
1 |
assertEquals("H", codon.product); |
157 |
1 |
codon = codons.next(); |
158 |
1 |
assertEquals("[6, 7, 8]", codon.toString()); |
159 |
1 |
assertEquals("Y", codon.product); |
160 |
1 |
codon = codons.next(); |
161 |
1 |
assertEquals("[9, 10, 11]", codon.toString()); |
162 |
1 |
assertEquals("Q", codon.product); |
163 |
1 |
assertFalse(codons.hasNext()); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
169 |
1 |
@Test(groups = { "Functional" })... |
170 |
|
public void testNext_withOffset() |
171 |
|
{ |
172 |
1 |
SequenceI from = new Sequence("Seq1", "-CgC-C-cCtAG-AtG-Gc", 7, 20); |
173 |
1 |
from.createDatasetSequence(); |
174 |
1 |
SequenceI to = new Sequence("Seq1/10-12", "-PQ-R-"); |
175 |
1 |
to.createDatasetSequence(); |
176 |
1 |
MapList map = new MapList( |
177 |
|
new int[] |
178 |
|
{ 7, 7, 9, 10, 12, 12, 14, 16, 18, 19 }, new int[] { 10, 12 }, |
179 |
|
3, 1); |
180 |
1 |
Mapping m = new Mapping(to.getDatasetSequence(), map); |
181 |
|
|
182 |
1 |
Iterator<AlignedCodon> codons = m.getCodonIterator(from, '-'); |
183 |
1 |
AlignedCodon codon = codons.next(); |
184 |
1 |
assertEquals("[1, 3, 5]", codon.toString()); |
185 |
1 |
assertEquals("P", codon.product); |
186 |
1 |
codon = codons.next(); |
187 |
1 |
assertEquals("[8, 10, 11]", codon.toString()); |
188 |
1 |
assertEquals("Q", codon.product); |
189 |
1 |
codon = codons.next(); |
190 |
1 |
assertEquals("[13, 15, 17]", codon.toString()); |
191 |
1 |
assertEquals("R", codon.product); |
192 |
1 |
assertFalse(codons.hasNext()); |
193 |
|
} |
194 |
|
} |