1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io.gff; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertNull; |
25 |
|
import static org.testng.AssertJUnit.assertSame; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; |
28 |
|
|
29 |
|
import jalview.datamodel.AlignedCodonFrame; |
30 |
|
import jalview.datamodel.Alignment; |
31 |
|
import jalview.datamodel.AlignmentI; |
32 |
|
import jalview.datamodel.Mapping; |
33 |
|
import jalview.datamodel.MappingType; |
34 |
|
import jalview.datamodel.Sequence; |
35 |
|
import jalview.datamodel.SequenceDummy; |
36 |
|
import jalview.datamodel.SequenceI; |
37 |
|
import jalview.gui.AlignFrame; |
38 |
|
import jalview.gui.JvOptionPane; |
39 |
|
import jalview.io.DataSourceType; |
40 |
|
import jalview.io.FileLoader; |
41 |
|
|
42 |
|
import java.io.IOException; |
43 |
|
import java.util.ArrayList; |
44 |
|
import java.util.Iterator; |
45 |
|
import java.util.List; |
46 |
|
import java.util.Map; |
47 |
|
|
48 |
|
import org.testng.annotations.BeforeClass; |
49 |
|
import org.testng.annotations.Test; |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (133) |
Complexity: 7 |
Complexity Density: 0.06 |
|
51 |
|
public class ExonerateHelperTest |
52 |
|
{ |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
54 |
1 |
@BeforeClass(alwaysRun = true)... |
55 |
|
public void setUpJvOptionPane() |
56 |
|
{ |
57 |
1 |
JvOptionPane.setInteractiveMode(false); |
58 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
61 |
1 |
@Test(groups = "Functional")... |
62 |
|
public void testGetMappingType() |
63 |
|
{ |
64 |
|
|
65 |
1 |
assertSame(MappingType.PeptideToNucleotide, ExonerateHelper |
66 |
|
.getMappingType("exonerate:protein2genome:local")); |
67 |
1 |
assertSame(MappingType.PeptideToNucleotide, |
68 |
|
ExonerateHelper.getMappingType("exonerate:protein2dna:local")); |
69 |
|
|
70 |
|
|
71 |
1 |
assertSame(MappingType.NucleotideToNucleotide, |
72 |
|
ExonerateHelper.getMappingType("coding2coding")); |
73 |
1 |
assertSame(MappingType.NucleotideToNucleotide, |
74 |
|
ExonerateHelper.getMappingType("coding2genome")); |
75 |
1 |
assertSame(MappingType.NucleotideToNucleotide, |
76 |
|
ExonerateHelper.getMappingType("cdna2genome")); |
77 |
1 |
assertSame(MappingType.NucleotideToNucleotide, |
78 |
|
ExonerateHelper.getMappingType("genome2genome")); |
79 |
1 |
assertNull(ExonerateHelper.getMappingType("affine:local")); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@throws |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
90 |
1 |
@Test(groups = "Functional")... |
91 |
|
public void testProcessGffSimilarity_protein2dna_forward_querygff() |
92 |
|
throws IOException |
93 |
|
{ |
94 |
1 |
ExonerateHelper testee = new ExonerateHelper(); |
95 |
1 |
List<SequenceI> newseqs = new ArrayList<SequenceI>(); |
96 |
1 |
String[] gff = "Seq\texonerate:protein2dna:local\tsimilarity\t3\t10\t.\t+\t.\talignment_id 0 ; Target dna1 ; Align 3 400 8" |
97 |
|
.split("\\t"); |
98 |
1 |
SequenceI seq = new Sequence("Seq", "PQRASTGKEEDVMIWCHQN"); |
99 |
1 |
seq.createDatasetSequence(); |
100 |
1 |
AlignmentI align = new Alignment(new SequenceI[] {}); |
101 |
1 |
Map<String, List<String>> set = Gff2Helper.parseNameValuePairs(gff[8]); |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
1 |
testee.processGffSimilarity(set, seq, gff, align, newseqs, false); |
108 |
1 |
assertEquals(1, newseqs.size()); |
109 |
1 |
assertTrue(newseqs.get(0) instanceof SequenceDummy); |
110 |
1 |
assertEquals("dna1", newseqs.get(0).getName()); |
111 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
112 |
1 |
AlignedCodonFrame mapping = align.getCodonFrames().iterator().next(); |
113 |
1 |
assertEquals(1, mapping.getAaSeqs().length); |
114 |
1 |
assertSame(seq.getDatasetSequence(), mapping.getAaSeqs()[0]); |
115 |
1 |
assertEquals(1, mapping.getdnaSeqs().length); |
116 |
1 |
assertSame(newseqs.get(0), mapping.getdnaSeqs()[0]); |
117 |
1 |
assertEquals(1, mapping.getdnaToProt().length); |
118 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size()); |
119 |
1 |
assertArrayEquals(new int[] { 400, 423 }, |
120 |
|
mapping.getdnaToProt()[0].getFromRanges().get(0)); |
121 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size()); |
122 |
1 |
assertArrayEquals(new int[] { 3, 10 }, |
123 |
|
mapping.getdnaToProt()[0].getToRanges().get(0)); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@throws |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
133 |
1 |
@Test(groups = "Functional")... |
134 |
|
public void testProcessGffSimilarity_protein2dna_reverse_querygff() |
135 |
|
throws IOException |
136 |
|
{ |
137 |
1 |
ExonerateHelper testee = new ExonerateHelper(); |
138 |
1 |
List<SequenceI> newseqs = new ArrayList<SequenceI>(); |
139 |
1 |
String[] gff = "Seq\texonerate:protein2dna:local\tsimilarity\t3\t10\t0\t-\t.\talignment_id 0 ; Target dna1 ; Align 3 400 8" |
140 |
|
.split("\\t"); |
141 |
1 |
SequenceI seq = new Sequence("Seq", "PQRASTGKEEDVMIWCHQN"); |
142 |
1 |
seq.createDatasetSequence(); |
143 |
1 |
AlignmentI align = new Alignment(new SequenceI[] {}); |
144 |
1 |
Map<String, List<String>> set = Gff2Helper.parseNameValuePairs(gff[8]); |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
1 |
testee.processGffSimilarity(set, seq, gff, align, newseqs, false); |
151 |
1 |
assertEquals(1, newseqs.size()); |
152 |
1 |
assertTrue(newseqs.get(0) instanceof SequenceDummy); |
153 |
1 |
assertEquals("dna1", newseqs.get(0).getName()); |
154 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
155 |
1 |
AlignedCodonFrame mapping = align.getCodonFrames().iterator().next(); |
156 |
1 |
assertEquals(1, mapping.getAaSeqs().length); |
157 |
1 |
assertSame(seq.getDatasetSequence(), mapping.getAaSeqs()[0]); |
158 |
1 |
assertEquals(1, mapping.getdnaSeqs().length); |
159 |
1 |
assertSame(newseqs.get(0), mapping.getdnaSeqs()[0]); |
160 |
1 |
assertEquals(1, mapping.getdnaToProt().length); |
161 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size()); |
162 |
1 |
assertArrayEquals(new int[] { 400, 377 }, |
163 |
|
mapping.getdnaToProt()[0].getFromRanges().get(0)); |
164 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size()); |
165 |
1 |
assertArrayEquals(new int[] { 3, 10 }, |
166 |
|
mapping.getdnaToProt()[0].getToRanges().get(0)); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@throws |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
176 |
1 |
@Test(groups = "Functional")... |
177 |
|
public void testProcessGffSimilarity_protein2dna_forward_targetgff() |
178 |
|
throws IOException |
179 |
|
{ |
180 |
1 |
ExonerateHelper testee = new ExonerateHelper(); |
181 |
1 |
List<SequenceI> newseqs = new ArrayList<SequenceI>(); |
182 |
1 |
String[] gff = "dna1\texonerate:protein2dna:local\tsimilarity\t400\t423\t0\t+\t.\talignment_id 0 ; Query Prot1 ; Align 400 3 24" |
183 |
|
.split("\\t"); |
184 |
1 |
SequenceI seq = new Sequence("dna1/391-430", |
185 |
|
"CGATCCGATCCGATCCGATCCGATCCGATCCGATCCGATC"); |
186 |
1 |
seq.createDatasetSequence(); |
187 |
1 |
AlignmentI align = new Alignment(new SequenceI[] { seq }); |
188 |
|
|
189 |
|
|
190 |
1 |
Map<String, List<String>> set = Gff2Helper.parseNameValuePairs(gff[8]); |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
1 |
testee.processGffSimilarity(set, seq, gff, align, newseqs, false); |
197 |
1 |
assertEquals(1, newseqs.size()); |
198 |
1 |
assertTrue(newseqs.get(0) instanceof SequenceDummy); |
199 |
1 |
assertEquals("Prot1", newseqs.get(0).getName()); |
200 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
201 |
1 |
AlignedCodonFrame mapping = align.getCodonFrames().iterator().next(); |
202 |
1 |
assertEquals(1, mapping.getAaSeqs().length); |
203 |
1 |
assertSame(newseqs.get(0), mapping.getAaSeqs()[0]); |
204 |
1 |
assertSame(seq.getDatasetSequence(), mapping.getdnaSeqs()[0]); |
205 |
1 |
assertEquals(1, mapping.getdnaSeqs().length); |
206 |
1 |
assertEquals(1, mapping.getdnaToProt().length); |
207 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size()); |
208 |
1 |
assertArrayEquals(new int[] { 400, 423 }, |
209 |
|
mapping.getdnaToProt()[0].getFromRanges().get(0)); |
210 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size()); |
211 |
1 |
assertArrayEquals(new int[] { 3, 10 }, |
212 |
|
mapping.getdnaToProt()[0].getToRanges().get(0)); |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
@throws |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
222 |
1 |
@Test(groups = "Functional")... |
223 |
|
public void testProcessGffSimilarity_protein2dna_reverse_targetgff() |
224 |
|
throws IOException |
225 |
|
{ |
226 |
1 |
ExonerateHelper testee = new ExonerateHelper(); |
227 |
1 |
List<SequenceI> newseqs = new ArrayList<SequenceI>(); |
228 |
1 |
String[] gff = "dna1\texonerate:protein2dna:local\tsimilarity\t377\t400\t0\t-\t.\talignment_id 0 ; Query Prot1 ; Align 400 3 24" |
229 |
|
.split("\\t"); |
230 |
1 |
SequenceI seq = new Sequence("dna1/371-410", |
231 |
|
"CGATCCGATCCGATCCGATCCGATCCGATCCGATCCGATC"); |
232 |
1 |
seq.createDatasetSequence(); |
233 |
1 |
AlignmentI align = new Alignment(new SequenceI[] { seq }); |
234 |
|
|
235 |
|
|
236 |
1 |
Map<String, List<String>> set = Gff2Helper.parseNameValuePairs(gff[8]); |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
1 |
testee.processGffSimilarity(set, seq, gff, align, newseqs, false); |
243 |
1 |
assertEquals(1, newseqs.size()); |
244 |
1 |
assertTrue(newseqs.get(0) instanceof SequenceDummy); |
245 |
1 |
assertEquals("Prot1", newseqs.get(0).getName()); |
246 |
1 |
assertEquals(1, align.getCodonFrames().size()); |
247 |
1 |
AlignedCodonFrame mapping = align.getCodonFrames().iterator().next(); |
248 |
1 |
assertEquals(1, mapping.getAaSeqs().length); |
249 |
1 |
assertSame(newseqs.get(0), mapping.getAaSeqs()[0]); |
250 |
1 |
assertSame(seq.getDatasetSequence(), mapping.getdnaSeqs()[0]); |
251 |
1 |
assertEquals(1, mapping.getdnaSeqs().length); |
252 |
1 |
assertEquals(1, mapping.getdnaToProt().length); |
253 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size()); |
254 |
1 |
assertArrayEquals(new int[] { 400, 377 }, |
255 |
|
mapping.getdnaToProt()[0].getFromRanges().get(0)); |
256 |
1 |
assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size()); |
257 |
1 |
assertArrayEquals(new int[] { 3, 10 }, |
258 |
|
mapping.getdnaToProt()[0].getToRanges().get(0)); |
259 |
|
} |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
265 |
1 |
@Test(groups = { "Functional" })... |
266 |
|
public void testAddExonerateGffToAlignment() |
267 |
|
{ |
268 |
1 |
FileLoader loader = new FileLoader(false); |
269 |
1 |
AlignFrame af = loader.LoadFileWaitTillLoaded( |
270 |
|
"examples/testdata/exonerateseqs.fa", DataSourceType.FILE); |
271 |
|
|
272 |
1 |
af.loadJalviewDataFile("examples/testdata/exonerateoutput.gff", |
273 |
|
DataSourceType.FILE, null, null); |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
1 |
List<AlignedCodonFrame> mappings = af.getViewport().getAlignment() |
279 |
|
.getDataset().getCodonFrames(); |
280 |
1 |
assertEquals(2, mappings.size()); |
281 |
1 |
Iterator<AlignedCodonFrame> iter = mappings.iterator(); |
282 |
|
|
283 |
|
|
284 |
1 |
AlignedCodonFrame mapping = iter.next(); |
285 |
1 |
Mapping[] mapList = mapping.getProtMappings(); |
286 |
1 |
assertEquals(1, mapList.length); |
287 |
1 |
assertTrue(mapList[0].getTo() instanceof SequenceDummy); |
288 |
1 |
assertEquals("DDB_G0269124", mapList[0].getTo().getName()); |
289 |
|
|
290 |
|
|
291 |
1 |
int[] mappedRegion = mapList[0].getMap().locateInFrom(143, 143); |
292 |
1 |
assertArrayEquals(new int[] { 11270, 11268 }, mappedRegion); |
293 |
|
|
294 |
|
|
295 |
1 |
mapping = iter.next(); |
296 |
1 |
mapList = mapping.getProtMappings(); |
297 |
1 |
assertEquals(1, mapList.length); |
298 |
1 |
SequenceI proteinSeq = af.getViewport().getAlignment() |
299 |
|
.findName("DDB_G0280897"); |
300 |
1 |
assertSame(proteinSeq.getDatasetSequence(), mapList[0].getTo()); |
301 |
1 |
assertEquals(1, mapping.getdnaToProt().length); |
302 |
|
|
303 |
|
|
304 |
1 |
mappedRegion = mapList[0].getMap().locateInFrom(143, 143); |
305 |
1 |
assertArrayEquals(new int[] { 11270, 11268 }, mappedRegion); |
306 |
|
|
307 |
|
|
308 |
1 |
mappedRegion = mapList[0].getMap().locateInFrom(182, 182); |
309 |
1 |
assertArrayEquals(new int[] { 11153, 11151 }, mappedRegion); |
310 |
|
|
311 |
|
|
312 |
1 |
mappedRegion = mapList[0].getMap().locateInTo(11151, 11153); |
313 |
1 |
assertArrayEquals(new int[] { 182, 182 }, mappedRegion); |
314 |
|
|
315 |
|
|
316 |
1 |
mappedRegion = mapList[0].getMap().locateInTo(11150, 11150); |
317 |
1 |
assertNull(mappedRegion); |
318 |
|
|
319 |
|
|
320 |
1 |
mappedRegion = mapList[0].getMap().locateInFrom(183, 183); |
321 |
1 |
assertNull(mappedRegion); |
322 |
|
} |
323 |
|
} |