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 java.util.AbstractList; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import jalview.util.MapList; |
28 |
|
import jalview.util.MappingUtils; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 90.8% |
Uncovered Elements: 27 (293) |
Complexity: 97 |
Complexity Density: 0.56 |
|
34 |
|
public class AlignedCodonFrame |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 87.5% |
Uncovered Elements: 14 (112) |
Complexity: 35 |
Complexity Density: 0.53 |
|
40 |
|
public class SequenceToSequenceMapping |
41 |
|
{ |
42 |
|
private SequenceI fromSeq; |
43 |
|
|
44 |
|
private Mapping mapping; |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
420 |
SequenceToSequenceMapping(SequenceI from, Mapping map)... |
47 |
|
{ |
48 |
420 |
this.fromSeq = from; |
49 |
420 |
this.mapping = map; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0 |
@Override... |
56 |
|
public String toString() |
57 |
|
{ |
58 |
0 |
return String.format("From %s %s", fromSeq.getName(), |
59 |
|
mapping.toString()); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
@see |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
67 |
0 |
@Override... |
68 |
|
public int hashCode() |
69 |
|
{ |
70 |
0 |
return (fromSeq == null ? 0 : fromSeq.hashCode() * 31) |
71 |
|
+ mapping.hashCode(); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@see |
79 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
80 |
2683 |
@Override... |
81 |
|
public boolean equals(Object obj) |
82 |
|
{ |
83 |
2683 |
if (!(obj instanceof SequenceToSequenceMapping)) |
84 |
|
{ |
85 |
0 |
return false; |
86 |
|
} |
87 |
2683 |
SequenceToSequenceMapping that = (SequenceToSequenceMapping) obj; |
88 |
2683 |
if (this.mapping == null) |
89 |
|
{ |
90 |
0 |
return that.mapping == null; |
91 |
|
} |
92 |
|
|
93 |
2683 |
return (this.fromSeq == that.fromSeq |
94 |
|
|| (this.fromSeq != null && that.fromSeq != null |
95 |
|
&& this.fromSeq.getDatasetSequence() != null |
96 |
|
&& this.fromSeq.getDatasetSequence() == that.fromSeq |
97 |
|
.getDatasetSequence())) |
98 |
|
&& this.mapping.equals(that.mapping); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
65 |
public SequenceI getFromSeq()... |
102 |
|
{ |
103 |
65 |
return fromSeq; |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
314 |
public Mapping getMapping()... |
107 |
|
{ |
108 |
314 |
return mapping; |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@param |
117 |
|
@return |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
280 |
public boolean covers(SequenceI seq)... |
120 |
|
{ |
121 |
280 |
return covers(seq, false, false); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
@param |
127 |
|
@param |
128 |
|
|
129 |
|
|
130 |
|
@param |
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
135 |
|
|
|
|
| 95.9% |
Uncovered Elements: 2 (49) |
Complexity: 14 |
Complexity Density: 0.45 |
|
136 |
579 |
public boolean covers(SequenceI seq, boolean localCover, boolean either)... |
137 |
|
{ |
138 |
579 |
List<int[]> mappedRanges = null, otherRanges = null; |
139 |
579 |
MapList mapList = mapping.getMap(); |
140 |
579 |
int mstart = seq.getStart(), mend = seq.getEnd(), ostart, oend; |
141 |
579 |
; |
142 |
579 |
if (fromSeq == seq || fromSeq == seq.getDatasetSequence()) |
143 |
|
{ |
144 |
153 |
if (localCover && fromSeq != seq) |
145 |
|
{ |
146 |
72 |
mstart = fromSeq.getStart(); |
147 |
72 |
mend = fromSeq.getEnd(); |
148 |
|
} |
149 |
153 |
mappedRanges = mapList.getFromRanges(); |
150 |
153 |
otherRanges = mapList.getToRanges(); |
151 |
153 |
ostart = mapping.to.getStart(); |
152 |
153 |
oend = mapping.to.getEnd(); |
153 |
|
} |
154 |
426 |
else if (mapping.to == seq || mapping.to == seq.getDatasetSequence()) |
155 |
|
{ |
156 |
124 |
if (localCover && mapping.to != seq) |
157 |
|
{ |
158 |
65 |
mstart = mapping.to.getStart(); |
159 |
65 |
mend = mapping.to.getEnd(); |
160 |
|
} |
161 |
124 |
mappedRanges = mapList.getToRanges(); |
162 |
124 |
otherRanges = mapList.getFromRanges(); |
163 |
124 |
ostart = fromSeq.getStart(); |
164 |
124 |
oend = fromSeq.getEnd(); |
165 |
|
} |
166 |
|
else |
167 |
|
{ |
168 |
302 |
return false; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
277 |
int length = countRange(mappedRanges, mstart, mend); |
177 |
|
|
178 |
277 |
if (length != -1) |
179 |
|
{ |
180 |
|
|
181 |
263 |
if (length + 3 >= (mend - mstart + 1)) |
182 |
|
{ |
183 |
230 |
return true; |
184 |
|
} |
185 |
|
} |
186 |
47 |
if (either) |
187 |
|
{ |
188 |
|
|
189 |
25 |
length = countRange(otherRanges, ostart, oend); |
190 |
25 |
if (length != -1) |
191 |
|
{ |
192 |
25 |
if (length + 1 >= (oend - ostart + 1)) |
193 |
|
{ |
194 |
25 |
return true; |
195 |
|
} |
196 |
|
} |
197 |
|
} |
198 |
22 |
return false; |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
201 |
302 |
private int countRange(List<int[]> mappedRanges, int mstart, int mend)... |
202 |
|
{ |
203 |
302 |
int length = 0; |
204 |
302 |
for (int[] range : mappedRanges) |
205 |
|
{ |
206 |
388 |
int from = Math.min(range[0], range[1]); |
207 |
388 |
int to = Math.max(range[0], range[1]); |
208 |
388 |
if (from < mstart || to > mend) |
209 |
|
{ |
210 |
14 |
return -1; |
211 |
|
} |
212 |
374 |
length += (to - from + 1); |
213 |
|
} |
214 |
288 |
return length; |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
@param |
223 |
|
@param |
224 |
|
@param |
225 |
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 8 |
Complexity Density: 0.57 |
|
226 |
142 |
public void markMappedRegion(SequenceI seq, int pos, SearchResultsI sr)... |
227 |
|
{ |
228 |
142 |
int[] codon = null; |
229 |
142 |
SequenceI mappedSeq = null; |
230 |
142 |
SequenceI ds = seq.getDatasetSequence(); |
231 |
142 |
if (ds == null) |
232 |
|
{ |
233 |
142 |
ds = seq; |
234 |
|
} |
235 |
|
|
236 |
142 |
if (this.fromSeq == seq || this.fromSeq == ds) |
237 |
|
{ |
238 |
74 |
codon = this.mapping.map.locateInTo(pos, pos); |
239 |
74 |
mappedSeq = this.mapping.to; |
240 |
|
} |
241 |
68 |
else if (this.mapping.to == seq || this.mapping.to == ds) |
242 |
|
{ |
243 |
68 |
codon = this.mapping.map.locateInFrom(pos, pos); |
244 |
68 |
mappedSeq = this.fromSeq; |
245 |
|
} |
246 |
|
|
247 |
142 |
if (codon != null) |
248 |
|
{ |
249 |
267 |
for (int i = 0; i < codon.length; i += 2) |
250 |
|
{ |
251 |
142 |
sr.addResult(mappedSeq, codon[i], codon[i + 1]); |
252 |
|
} |
253 |
|
} |
254 |
|
} |
255 |
|
} |
256 |
|
|
257 |
|
private List<SequenceToSequenceMapping> mappings; |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
262 |
201 |
public AlignedCodonFrame()... |
263 |
|
{ |
264 |
201 |
mappings = new ArrayList<>(); |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
@param |
272 |
|
@param |
273 |
|
@param |
274 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
275 |
415 |
public void addMap(SequenceI dnaseq, SequenceI aaseq, MapList map)... |
276 |
|
{ |
277 |
415 |
addMap(dnaseq, aaseq, map, null); |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
@param |
285 |
|
@param |
286 |
|
@param |
287 |
|
@param |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
289 |
428 |
public void addMap(SequenceI dnaseq, SequenceI aaseq, MapList map,... |
290 |
|
String mapFromId) |
291 |
|
{ |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
428 |
SequenceI fromSeq = (dnaseq.getDatasetSequence() == null) ? dnaseq |
297 |
|
: dnaseq.getDatasetSequence(); |
298 |
428 |
SequenceI toSeq = (aaseq.getDatasetSequence() == null) ? aaseq |
299 |
|
: aaseq.getDatasetSequence(); |
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
428 |
for (SequenceToSequenceMapping ssm : mappings) |
307 |
|
{ |
308 |
1157 |
if (ssm.fromSeq == fromSeq && ssm.mapping.to == toSeq) |
309 |
|
{ |
310 |
8 |
ssm.mapping.map.addMapList(map); |
311 |
8 |
return; |
312 |
|
} |
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
420 |
Mapping mp = new Mapping(toSeq, map); |
319 |
420 |
mp.setMappedFromId(mapFromId); |
320 |
420 |
mappings.add(new SequenceToSequenceMapping(fromSeq, mp)); |
321 |
|
} |
322 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
323 |
44 |
public SequenceI[] getdnaSeqs()... |
324 |
|
{ |
325 |
|
|
326 |
|
|
327 |
44 |
List<SequenceI> seqs = new ArrayList<>(); |
328 |
44 |
for (SequenceToSequenceMapping ssm : mappings) |
329 |
|
{ |
330 |
52 |
seqs.add(ssm.fromSeq); |
331 |
|
} |
332 |
44 |
return seqs.toArray(new SequenceI[seqs.size()]); |
333 |
|
} |
334 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
335 |
16 |
public SequenceI[] getAaSeqs()... |
336 |
|
{ |
337 |
|
|
338 |
16 |
List<SequenceI> seqs = new ArrayList<>(); |
339 |
16 |
for (SequenceToSequenceMapping ssm : mappings) |
340 |
|
{ |
341 |
16 |
seqs.add(ssm.mapping.to); |
342 |
|
} |
343 |
16 |
return seqs.toArray(new SequenceI[seqs.size()]); |
344 |
|
} |
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
346 |
50 |
public MapList[] getdnaToProt()... |
347 |
|
{ |
348 |
50 |
List<MapList> maps = new ArrayList<>(); |
349 |
50 |
for (SequenceToSequenceMapping ssm : mappings) |
350 |
|
{ |
351 |
90 |
maps.add(ssm.mapping.map); |
352 |
|
} |
353 |
50 |
return maps.toArray(new MapList[maps.size()]); |
354 |
|
} |
355 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
356 |
8 |
public Mapping[] getProtMappings()... |
357 |
|
{ |
358 |
8 |
List<Mapping> maps = new ArrayList<>(); |
359 |
8 |
for (SequenceToSequenceMapping ssm : mappings) |
360 |
|
{ |
361 |
9 |
maps.add(ssm.mapping); |
362 |
|
} |
363 |
8 |
return maps.toArray(new Mapping[maps.size()]); |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
@param |
371 |
|
@return |
372 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
373 |
32 |
public Mapping getMappingForSequence(SequenceI seq)... |
374 |
|
{ |
375 |
32 |
SequenceI seqDs = seq.getDatasetSequence(); |
376 |
32 |
seqDs = seqDs != null ? seqDs : seq; |
377 |
|
|
378 |
32 |
for (SequenceToSequenceMapping ssm : mappings) |
379 |
|
{ |
380 |
40 |
if (ssm.fromSeq == seqDs || ssm.mapping.to == seqDs) |
381 |
|
{ |
382 |
32 |
return ssm.mapping; |
383 |
|
} |
384 |
|
} |
385 |
0 |
return null; |
386 |
|
} |
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
@param |
393 |
|
@return |
394 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
395 |
246741 |
public SequenceI getAaForDnaSeq(SequenceI dnaSeqRef)... |
396 |
|
{ |
397 |
246741 |
SequenceI dnads = dnaSeqRef.getDatasetSequence(); |
398 |
246741 |
for (SequenceToSequenceMapping ssm : mappings) |
399 |
|
{ |
400 |
354059 |
if (ssm.fromSeq == dnaSeqRef || ssm.fromSeq == dnads) |
401 |
|
{ |
402 |
126 |
return ssm.mapping.to; |
403 |
|
} |
404 |
|
} |
405 |
246619 |
return null; |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
@param |
414 |
|
@return |
415 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
416 |
246636 |
public SequenceI getDnaForAaSeq(SequenceI aaSeqRef)... |
417 |
|
{ |
418 |
246635 |
SequenceI aads = aaSeqRef.getDatasetSequence(); |
419 |
246635 |
for (SequenceToSequenceMapping ssm : mappings) |
420 |
|
{ |
421 |
295714 |
if (ssm.mapping.to == aaSeqRef || ssm.mapping.to == aads) |
422 |
|
{ |
423 |
21461 |
return ssm.fromSeq; |
424 |
|
} |
425 |
|
} |
426 |
225174 |
return null; |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
@param |
433 |
|
|
434 |
|
@return |
435 |
|
|
436 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
437 |
246731 |
public boolean involvesSequence(SequenceI seq)... |
438 |
|
{ |
439 |
246729 |
return getAaForDnaSeq(seq) != null || getDnaForAaSeq(seq) != null; |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
@param |
448 |
|
@param |
449 |
|
|
450 |
|
@param |
451 |
|
|
452 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
453 |
133 |
public void markMappedRegion(SequenceI seq, int index,... |
454 |
|
SearchResultsI results) |
455 |
|
{ |
456 |
133 |
SequenceI ds = seq.getDatasetSequence(); |
457 |
133 |
if (ds == null) |
458 |
|
{ |
459 |
3 |
ds = seq; |
460 |
|
} |
461 |
133 |
for (SequenceToSequenceMapping ssm : mappings) |
462 |
|
{ |
463 |
299 |
if (ssm.covers(seq, true, true)) |
464 |
|
{ |
465 |
140 |
ssm.markMappedRegion(ds, index, results); |
466 |
|
} |
467 |
|
} |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
@param |
476 |
|
|
477 |
|
@param |
478 |
|
@return |
479 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 8 |
Complexity Density: 0.73 |
|
480 |
1043 |
public SequenceI findAlignedSequence(SequenceI seq, AlignmentI al)... |
481 |
|
{ |
482 |
|
|
483 |
|
|
484 |
|
|
485 |
1043 |
for (SequenceToSequenceMapping ssm : mappings) |
486 |
|
{ |
487 |
1495 |
if (ssm.fromSeq == seq || ssm.fromSeq == seq.getDatasetSequence()) |
488 |
|
{ |
489 |
65 |
for (SequenceI sourceAligned : al.getSequences()) |
490 |
|
{ |
491 |
644 |
if (ssm.mapping.to == sourceAligned.getDatasetSequence() |
492 |
|
|| ssm.mapping.to == sourceAligned) |
493 |
|
{ |
494 |
39 |
return sourceAligned; |
495 |
|
} |
496 |
|
} |
497 |
|
} |
498 |
|
} |
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
1004 |
for (SequenceToSequenceMapping ssm : mappings) |
504 |
|
{ |
505 |
1445 |
if (ssm.mapping.to == seq |
506 |
|
|| ssm.mapping.to == seq.getDatasetSequence()) |
507 |
|
{ |
508 |
53 |
for (SequenceI sourceAligned : al.getSequences()) |
509 |
|
{ |
510 |
497 |
if (ssm.fromSeq == sourceAligned.getDatasetSequence()) |
511 |
|
{ |
512 |
31 |
return sourceAligned; |
513 |
|
} |
514 |
|
} |
515 |
|
} |
516 |
|
} |
517 |
|
|
518 |
973 |
return null; |
519 |
|
} |
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
@param |
527 |
|
@param |
528 |
|
@param |
529 |
|
@return |
530 |
|
|
|
|
| 85.7% |
Uncovered Elements: 4 (28) |
Complexity: 11 |
Complexity Density: 0.79 |
|
531 |
161 |
public int[] getMappedRegion(SequenceI target, SequenceI query,... |
532 |
|
int queryPos) |
533 |
|
{ |
534 |
161 |
SequenceI targetDs = target.getDatasetSequence() == null ? target |
535 |
|
: target.getDatasetSequence(); |
536 |
161 |
SequenceI queryDs = query.getDatasetSequence() == null ? query |
537 |
|
: query.getDatasetSequence(); |
538 |
161 |
if (targetDs == null || queryDs == null ) |
539 |
|
{ |
540 |
0 |
return null; |
541 |
|
} |
542 |
161 |
for (SequenceToSequenceMapping ssm : mappings) |
543 |
|
{ |
544 |
|
|
545 |
|
|
546 |
|
|
547 |
172 |
if (ssm.fromSeq == targetDs && ssm.mapping.to == queryDs) |
548 |
|
{ |
549 |
40 |
int[] codon = ssm.mapping.map.locateInFrom(queryPos, queryPos); |
550 |
40 |
if (codon != null) |
551 |
|
{ |
552 |
36 |
return codon; |
553 |
|
} |
554 |
|
} |
555 |
|
|
556 |
|
|
557 |
|
|
558 |
132 |
else if (ssm.fromSeq == queryDs && ssm.mapping.to == targetDs) |
559 |
|
{ |
560 |
119 |
int[] codon = ssm.mapping.map.locateInTo(queryPos, queryPos); |
561 |
119 |
if (codon != null) |
562 |
|
{ |
563 |
26 |
return codon; |
564 |
|
} |
565 |
|
} |
566 |
|
} |
567 |
99 |
return null; |
568 |
|
} |
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
@param |
577 |
|
|
578 |
|
@param |
579 |
|
|
580 |
|
@return |
581 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 5 |
Complexity Density: 0.29 |
|
582 |
21367 |
public List<char[]> getMappedCodons(SequenceI protein, int aaPos)... |
583 |
|
{ |
584 |
21367 |
MapList ml = null; |
585 |
21367 |
SequenceI dnaSeq = null; |
586 |
21367 |
List<char[]> result = new ArrayList<>(); |
587 |
|
|
588 |
21367 |
for (SequenceToSequenceMapping ssm : mappings) |
589 |
|
{ |
590 |
127897 |
if (ssm.mapping.to == protein |
591 |
|
&& ssm.mapping.getMap().getFromRatio() == 3) |
592 |
|
{ |
593 |
21343 |
ml = ssm.mapping.map; |
594 |
21343 |
dnaSeq = ssm.fromSeq; |
595 |
|
|
596 |
21343 |
int[] codonPos = ml.locateInFrom(aaPos, aaPos); |
597 |
21343 |
if (codonPos == null) |
598 |
|
{ |
599 |
25 |
return null; |
600 |
|
} |
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
605 |
21318 |
codonPos = MappingUtils.flattenRanges(codonPos); |
606 |
21318 |
int start = dnaSeq.getStart(); |
607 |
21318 |
char c1 = dnaSeq.getCharAt(codonPos[0] - start); |
608 |
21318 |
char c2 = dnaSeq.getCharAt(codonPos[1] - start); |
609 |
21318 |
char c3 = dnaSeq.getCharAt(codonPos[2] - start); |
610 |
21318 |
result.add(new char[] { c1, c2, c3 }); |
611 |
|
} |
612 |
|
} |
613 |
21342 |
return result.isEmpty() ? null : result; |
614 |
|
} |
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
@param |
621 |
|
@return |
622 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
623 |
46 |
public List<Mapping> getMappingsFromSequence(SequenceI seq)... |
624 |
|
{ |
625 |
46 |
List<Mapping> result = new ArrayList<>(); |
626 |
46 |
List<SequenceI> related = new ArrayList<>(); |
627 |
46 |
SequenceI seqDs = seq.getDatasetSequence(); |
628 |
46 |
seqDs = seqDs != null ? seqDs : seq; |
629 |
|
|
630 |
46 |
for (SequenceToSequenceMapping ssm : mappings) |
631 |
|
{ |
632 |
268 |
final Mapping mapping = ssm.mapping; |
633 |
268 |
if (ssm.fromSeq == seqDs) |
634 |
|
{ |
635 |
48 |
if (!related.contains(mapping.to)) |
636 |
|
{ |
637 |
48 |
result.add(mapping); |
638 |
48 |
related.add(mapping.to); |
639 |
|
} |
640 |
|
} |
641 |
|
} |
642 |
46 |
return result; |
643 |
|
} |
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
@param |
650 |
|
@param |
651 |
|
@return |
652 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
653 |
7 |
public boolean isRealisableWith(SequenceI seq)... |
654 |
|
{ |
655 |
7 |
return realiseWith(seq, false) > 0; |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
@param |
663 |
|
@return |
664 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
665 |
2 |
public int realiseWith(SequenceI seq)... |
666 |
|
{ |
667 |
2 |
return realiseWith(seq, true); |
668 |
|
} |
669 |
|
|
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
@param |
675 |
|
|
676 |
|
@param |
677 |
|
|
678 |
|
@return |
679 |
|
|
|
|
| 78.9% |
Uncovered Elements: 8 (38) |
Complexity: 8 |
Complexity Density: 0.31 |
|
680 |
9 |
protected int realiseWith(SequenceI seq, boolean doUpdate)... |
681 |
|
{ |
682 |
9 |
SequenceI ds = seq.getDatasetSequence() != null |
683 |
|
? seq.getDatasetSequence() |
684 |
|
: seq; |
685 |
9 |
int count = 0; |
686 |
|
|
687 |
|
|
688 |
|
|
689 |
|
|
690 |
9 |
for (SequenceToSequenceMapping ssm : mappings) |
691 |
|
{ |
692 |
10 |
SequenceI dna = ssm.fromSeq; |
693 |
10 |
if (dna instanceof SequenceDummy |
694 |
|
&& dna.getName().equals(ds.getName())) |
695 |
|
{ |
696 |
8 |
Mapping mapping = ssm.mapping; |
697 |
8 |
int mapStart = mapping.getMap().getFromLowest(); |
698 |
8 |
int mapEnd = mapping.getMap().getFromHighest(); |
699 |
8 |
boolean mappable = couldRealiseSequence(dna, ds, mapStart, mapEnd); |
700 |
8 |
if (mappable) |
701 |
|
{ |
702 |
6 |
count++; |
703 |
6 |
if (doUpdate) |
704 |
|
{ |
705 |
|
|
706 |
|
|
707 |
3 |
ds.setSequenceFeatures(dna.getSequenceFeatures()); |
708 |
|
|
709 |
3 |
ssm.fromSeq = ds; |
710 |
3 |
jalview.bin.Console |
711 |
|
.outPrintln("Realised mapped sequence " + ds.getName()); |
712 |
|
} |
713 |
|
} |
714 |
|
} |
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
10 |
Mapping mapping = ssm.mapping; |
720 |
10 |
SequenceI prot = mapping.getTo(); |
721 |
10 |
int mapStart = mapping.getMap().getToLowest(); |
722 |
10 |
int mapEnd = mapping.getMap().getToHighest(); |
723 |
10 |
boolean mappable = couldRealiseSequence(prot, ds, mapStart, mapEnd); |
724 |
10 |
if (mappable) |
725 |
|
{ |
726 |
0 |
count++; |
727 |
0 |
if (doUpdate) |
728 |
|
{ |
729 |
|
|
730 |
|
|
731 |
0 |
ds.setSequenceFeatures(dna.getSequenceFeatures()); |
732 |
0 |
ssm.mapping.setTo(ds); |
733 |
|
} |
734 |
|
} |
735 |
|
} |
736 |
9 |
return count; |
737 |
|
} |
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
@param |
745 |
|
@param |
746 |
|
@param |
747 |
|
@param |
748 |
|
@return |
749 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
750 |
28 |
protected static boolean couldRealiseSequence(SequenceI existing,... |
751 |
|
SequenceI replacement, int mapStart, int mapEnd) |
752 |
|
{ |
753 |
28 |
if (existing instanceof SequenceDummy |
754 |
|
&& !(replacement instanceof SequenceDummy) |
755 |
|
&& existing.getName().equals(replacement.getName())) |
756 |
|
{ |
757 |
13 |
int start = replacement.getStart(); |
758 |
13 |
int end = replacement.getEnd(); |
759 |
13 |
boolean mappingOverlapsSequence = (mapStart >= start |
760 |
|
&& mapStart <= end) || (mapEnd >= start && mapEnd <= end); |
761 |
13 |
if (mappingOverlapsSequence) |
762 |
|
{ |
763 |
9 |
return true; |
764 |
|
} |
765 |
|
} |
766 |
19 |
return false; |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
|
774 |
|
@param |
775 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
776 |
8 |
public void updateToDataset(SequenceI seq)... |
777 |
|
{ |
778 |
8 |
if (seq == null || seq.getDatasetSequence() == null) |
779 |
|
{ |
780 |
0 |
return; |
781 |
|
} |
782 |
8 |
SequenceI ds = seq.getDatasetSequence(); |
783 |
|
|
784 |
8 |
for (SequenceToSequenceMapping ssm : mappings) |
785 |
|
|
786 |
|
|
787 |
|
|
788 |
|
{ |
789 |
8 |
if (ssm.fromSeq == seq) |
790 |
|
{ |
791 |
4 |
ssm.fromSeq = ds; |
792 |
|
} |
793 |
|
|
794 |
|
|
795 |
|
|
796 |
|
|
797 |
8 |
if (ssm.mapping.to == seq) |
798 |
|
{ |
799 |
4 |
ssm.mapping.to = ds; |
800 |
|
} |
801 |
|
} |
802 |
|
} |
803 |
|
|
804 |
|
|
805 |
|
|
806 |
|
|
807 |
|
@return |
808 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
809 |
7 |
public boolean isEmpty()... |
810 |
|
{ |
811 |
7 |
return mappings.isEmpty(); |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
817 |
0 |
@Override... |
818 |
|
public String toString() |
819 |
|
{ |
820 |
0 |
return mappings == null ? "null" : mappings.toString(); |
821 |
|
} |
822 |
|
|
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
@param |
828 |
|
|
829 |
|
@param |
830 |
|
|
831 |
|
@return |
832 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 7 |
Complexity Density: 0.88 |
|
833 |
42 |
public Mapping getMappingBetween(SequenceI fromSeq, SequenceI toSeq)... |
834 |
|
{ |
835 |
42 |
SequenceI dssFrom = fromSeq.getDatasetSequence() == null ? fromSeq |
836 |
|
: fromSeq.getDatasetSequence(); |
837 |
42 |
SequenceI dssTo = toSeq.getDatasetSequence() == null ? toSeq |
838 |
|
: toSeq.getDatasetSequence(); |
839 |
|
|
840 |
42 |
for (SequenceToSequenceMapping mapping : mappings) |
841 |
|
{ |
842 |
89 |
SequenceI from = mapping.fromSeq; |
843 |
89 |
SequenceI to = mapping.mapping.to; |
844 |
89 |
if ((from == dssFrom && to == dssTo) |
845 |
|
|| (from == dssTo && to == dssFrom)) |
846 |
|
{ |
847 |
31 |
return mapping.mapping; |
848 |
|
} |
849 |
|
} |
850 |
11 |
return null; |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
|
856 |
|
@see |
857 |
|
@see |
858 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
859 |
0 |
@Override... |
860 |
|
public int hashCode() |
861 |
|
{ |
862 |
0 |
return this.mappings.hashCode(); |
863 |
|
} |
864 |
|
|
865 |
|
|
866 |
|
|
867 |
|
|
868 |
|
|
869 |
|
@see |
870 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
871 |
3217 |
@Override... |
872 |
|
public boolean equals(Object obj) |
873 |
|
{ |
874 |
3217 |
if (!(obj instanceof AlignedCodonFrame)) |
875 |
|
{ |
876 |
0 |
return false; |
877 |
|
} |
878 |
3217 |
return this.mappings.equals(((AlignedCodonFrame) obj).mappings); |
879 |
|
} |
880 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
881 |
140 |
public List<SequenceToSequenceMapping> getMappings()... |
882 |
|
{ |
883 |
140 |
return mappings; |
884 |
|
} |
885 |
|
|
886 |
|
|
887 |
|
|
888 |
|
|
889 |
|
|
890 |
|
@param |
891 |
|
@param |
892 |
|
@return |
893 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
894 |
11 |
public SequenceToSequenceMapping getCoveringMapping(SequenceI seq1,... |
895 |
|
SequenceI seq2) |
896 |
|
{ |
897 |
11 |
for (SequenceToSequenceMapping mapping : mappings) |
898 |
|
{ |
899 |
7 |
if (mapping.covers(seq2) && mapping.covers(seq1)) |
900 |
|
{ |
901 |
2 |
return mapping; |
902 |
|
} |
903 |
|
} |
904 |
9 |
return null; |
905 |
|
} |
906 |
|
|
907 |
|
|
908 |
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
@param |
913 |
|
@return |
914 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 7 |
Complexity Density: 1 |
|
915 |
14 |
public SequenceToSequenceMapping getCoveringCodonMapping(SequenceI seq)... |
916 |
|
{ |
917 |
14 |
for (SequenceToSequenceMapping mapping : mappings) |
918 |
|
{ |
919 |
11 |
if (mapping.getMapping().getMap().isTripletMap() |
920 |
|
&& mapping.covers(seq)) |
921 |
|
{ |
922 |
8 |
if (mapping.fromSeq == seq |
923 |
|
&& mapping.covers(mapping.getMapping().getTo())) |
924 |
|
{ |
925 |
2 |
return mapping; |
926 |
|
} |
927 |
6 |
else if (mapping.getMapping().getTo() == seq |
928 |
|
&& mapping.covers(mapping.fromSeq)) |
929 |
|
{ |
930 |
4 |
return mapping; |
931 |
|
} |
932 |
|
} |
933 |
|
} |
934 |
8 |
return null; |
935 |
|
} |
936 |
|
} |