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.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.BitSet; |
26 |
|
import java.util.Collection; |
27 |
|
import java.util.Collections; |
28 |
|
import java.util.Enumeration; |
29 |
|
import java.util.HashSet; |
30 |
|
import java.util.Hashtable; |
31 |
|
import java.util.Iterator; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
import java.util.Set; |
35 |
|
import java.util.Vector; |
36 |
|
|
37 |
|
import jalview.analysis.AlignmentUtils; |
38 |
|
import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; |
39 |
|
import jalview.io.FastaFile; |
40 |
|
import jalview.util.Comparison; |
41 |
|
import jalview.util.LinkedIdentityHashSet; |
42 |
|
import jalview.util.MessageManager; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@author |
49 |
|
|
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1,074 (1,074) |
Complexity: 318 |
Complexity Density: 0.51 |
|
51 |
|
public class Alignment implements AlignmentI, AutoCloseable |
52 |
|
{ |
53 |
|
private Alignment dataset; |
54 |
|
|
55 |
|
private List<SequenceI> sequences; |
56 |
|
|
57 |
|
protected List<SequenceGroup> groups; |
58 |
|
|
59 |
|
protected char gapCharacter = '-'; |
60 |
|
|
61 |
|
private boolean nucleotide = true; |
62 |
|
|
63 |
|
public boolean hasRNAStructure = false; |
64 |
|
|
65 |
|
public AlignmentAnnotation[] annotations; |
66 |
|
|
67 |
|
HiddenSequences hiddenSequences; |
68 |
|
|
69 |
|
HiddenColumns hiddenCols; |
70 |
|
|
71 |
|
public Hashtable alignmentProperties; |
72 |
|
|
73 |
|
private List<AlignedCodonFrame> codonFrameList; |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
75 |
0 |
private void initAlignment(SequenceI[] seqs)... |
76 |
|
{ |
77 |
0 |
groups = Collections.synchronizedList(new ArrayList<SequenceGroup>()); |
78 |
0 |
hiddenSequences = new HiddenSequences(this); |
79 |
0 |
hiddenCols = new HiddenColumns(); |
80 |
0 |
codonFrameList = new ArrayList<>(); |
81 |
|
|
82 |
0 |
nucleotide = Comparison.isNucleotide(seqs); |
83 |
|
|
84 |
0 |
sequences = Collections.synchronizedList(new ArrayList<SequenceI>()); |
85 |
|
|
86 |
0 |
for (int i = 0; i < seqs.length; i++) |
87 |
|
{ |
88 |
0 |
sequences.add(seqs[i]); |
89 |
|
} |
90 |
|
|
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
97 |
0 |
public Alignment(AlignmentI al)... |
98 |
|
{ |
99 |
0 |
SequenceI[] seqs = al.getSequencesArray(); |
100 |
0 |
for (int i = 0; i < seqs.length; i++) |
101 |
|
{ |
102 |
0 |
seqs[i] = new Sequence(seqs[i]); |
103 |
|
} |
104 |
|
|
105 |
0 |
initAlignment(seqs); |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
0 |
if (dataset == null && al.getDataset() == null) |
111 |
|
{ |
112 |
0 |
this.setCodonFrames(al.getCodonFrames()); |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
public Alignment(SequenceI[] seqs)... |
122 |
|
{ |
123 |
0 |
initAlignment(seqs); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
|
131 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
132 |
0 |
public Alignment(SeqCigar[] alseqs)... |
133 |
|
{ |
134 |
0 |
SequenceI[] seqs = SeqCigar.createAlignmentSequences(alseqs, |
135 |
|
gapCharacter, new HiddenColumns(), null); |
136 |
0 |
initAlignment(seqs); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@param |
146 |
|
|
147 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
148 |
0 |
public static AlignmentI createAlignment(CigarArray compactAlignment)... |
149 |
|
{ |
150 |
0 |
throw new Error(MessageManager |
151 |
|
.getString("error.alignment_cigararray_not_implemented")); |
152 |
|
|
153 |
|
} |
154 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
0 |
@Override... |
156 |
|
public List<SequenceI> getSequences() |
157 |
|
{ |
158 |
0 |
return sequences; |
159 |
|
} |
160 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
161 |
0 |
@Override... |
162 |
|
public List<SequenceI> getSequences( |
163 |
|
Map<SequenceI, SequenceCollectionI> hiddenReps) |
164 |
|
{ |
165 |
|
|
166 |
|
|
167 |
0 |
return sequences; |
168 |
|
} |
169 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
170 |
0 |
@Override... |
171 |
|
public SequenceI[] getSequencesArray() |
172 |
|
{ |
173 |
0 |
if (sequences == null) |
174 |
|
{ |
175 |
0 |
return null; |
176 |
|
} |
177 |
0 |
synchronized (sequences) |
178 |
|
{ |
179 |
0 |
return sequences.toArray(new SequenceI[sequences.size()]); |
180 |
|
} |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
@return |
187 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
0 |
@Override... |
189 |
|
public Map<String, List<SequenceI>> getSequencesByName() |
190 |
|
{ |
191 |
0 |
return AlignmentUtils.getSequencesByName(this); |
192 |
|
} |
193 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
194 |
0 |
@Override... |
195 |
|
public SequenceI getSequenceAt(int i) |
196 |
|
{ |
197 |
0 |
synchronized (sequences) |
198 |
|
{ |
199 |
|
|
200 |
0 |
if (i > -1 && i < sequences.size()) |
201 |
|
{ |
202 |
0 |
return sequences.get(i); |
203 |
|
} |
204 |
|
} |
205 |
|
|
206 |
0 |
return null; |
207 |
|
} |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
209 |
0 |
@Override... |
210 |
|
public SequenceI getSequenceAtAbsoluteIndex(int i) |
211 |
|
{ |
212 |
0 |
SequenceI seq = null; |
213 |
0 |
if (getHiddenSequences().getSize() > 0) |
214 |
|
{ |
215 |
0 |
seq = getHiddenSequences().getHiddenSequence(i); |
216 |
0 |
if (seq == null) |
217 |
|
{ |
218 |
|
|
219 |
|
|
220 |
0 |
int index = getHiddenSequences().findIndexWithoutHiddenSeqs(i); |
221 |
0 |
seq = getSequenceAt(index); |
222 |
|
} |
223 |
|
} |
224 |
|
else |
225 |
|
{ |
226 |
0 |
seq = getSequenceAt(i); |
227 |
|
} |
228 |
0 |
return seq; |
229 |
|
} |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
@param |
237 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.43 |
|
238 |
0 |
@Override... |
239 |
|
public void addSequence(SequenceI snew) |
240 |
|
{ |
241 |
0 |
if (dataset != null) |
242 |
|
{ |
243 |
|
|
244 |
|
|
245 |
0 |
SequenceI dsseq = snew.getDatasetSequence(); |
246 |
0 |
if (dsseq == null) |
247 |
|
{ |
248 |
|
|
249 |
0 |
SequenceI adding = snew.deriveSequence(); |
250 |
0 |
snew = adding; |
251 |
0 |
dsseq = snew.getDatasetSequence(); |
252 |
|
} |
253 |
0 |
if (getDataset().findIndex(dsseq) == -1) |
254 |
|
{ |
255 |
0 |
getDataset().addSequence(dsseq); |
256 |
|
} |
257 |
|
|
258 |
|
} |
259 |
0 |
if (sequences == null) |
260 |
|
{ |
261 |
0 |
initAlignment(new SequenceI[] { snew }); |
262 |
|
} |
263 |
|
else |
264 |
|
{ |
265 |
0 |
synchronized (sequences) |
266 |
|
{ |
267 |
0 |
sequences.add(snew); |
268 |
|
} |
269 |
|
} |
270 |
0 |
if (hiddenSequences != null) |
271 |
|
{ |
272 |
0 |
hiddenSequences.adjustHeightSequenceAdded(); |
273 |
|
} |
274 |
|
} |
275 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
276 |
0 |
@Override... |
277 |
|
public SequenceI replaceSequenceAt(int i, SequenceI snew) |
278 |
|
{ |
279 |
0 |
synchronized (sequences) |
280 |
|
{ |
281 |
0 |
if (sequences.size() > i) |
282 |
|
{ |
283 |
0 |
return sequences.set(i, snew); |
284 |
|
|
285 |
|
} |
286 |
|
else |
287 |
|
{ |
288 |
0 |
sequences.add(snew); |
289 |
0 |
hiddenSequences.adjustHeightSequenceAdded(); |
290 |
|
} |
291 |
0 |
return null; |
292 |
|
} |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
@return |
299 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
300 |
0 |
@Override... |
301 |
|
public List<SequenceGroup> getGroups() |
302 |
|
{ |
303 |
0 |
return groups; |
304 |
|
} |
305 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
306 |
0 |
@Override... |
307 |
|
public void close() |
308 |
|
{ |
309 |
0 |
if (getDataset() != null) |
310 |
|
{ |
311 |
0 |
try |
312 |
|
{ |
313 |
0 |
getDataset().removeAlignmentRef(); |
314 |
|
} catch (Throwable e) |
315 |
|
{ |
316 |
0 |
e.printStackTrace(); |
317 |
|
} |
318 |
|
} |
319 |
|
|
320 |
0 |
nullReferences(); |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
327 |
0 |
void nullReferences()... |
328 |
|
{ |
329 |
0 |
dataset = null; |
330 |
0 |
sequences = null; |
331 |
0 |
groups = null; |
332 |
0 |
annotations = null; |
333 |
0 |
hiddenSequences = null; |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
@throws |
341 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
342 |
0 |
private void removeAlignmentRef() throws Throwable... |
343 |
|
{ |
344 |
0 |
if (--alignmentRefs == 0) |
345 |
|
{ |
346 |
0 |
nullReferences(); |
347 |
|
} |
348 |
|
} |
349 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
350 |
0 |
@Override... |
351 |
|
public void deleteSequence(SequenceI s) |
352 |
|
{ |
353 |
0 |
synchronized (sequences) |
354 |
|
{ |
355 |
0 |
deleteSequence(findIndex(s)); |
356 |
|
} |
357 |
|
} |
358 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
359 |
0 |
@Override... |
360 |
|
public void deleteSequence(int i) |
361 |
|
{ |
362 |
0 |
synchronized (sequences) |
363 |
|
{ |
364 |
0 |
if (i > -1 && i < getHeight()) |
365 |
|
{ |
366 |
0 |
sequences.remove(i); |
367 |
0 |
hiddenSequences.adjustHeightSequenceDeleted(i); |
368 |
|
} |
369 |
|
} |
370 |
|
} |
371 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
372 |
0 |
@Override... |
373 |
|
public void deleteHiddenSequence(int i) |
374 |
|
{ |
375 |
0 |
synchronized (sequences) |
376 |
|
{ |
377 |
0 |
if (i > -1 && i < getHeight()) |
378 |
|
{ |
379 |
0 |
sequences.remove(i); |
380 |
|
} |
381 |
|
} |
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
@see |
388 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
389 |
0 |
@Override... |
390 |
|
public SequenceGroup findGroup(SequenceI seq, int position) |
391 |
|
{ |
392 |
0 |
synchronized (groups) |
393 |
|
{ |
394 |
0 |
for (SequenceGroup sg : groups) |
395 |
|
{ |
396 |
0 |
if (sg.getSequences(null).contains(seq)) |
397 |
|
{ |
398 |
0 |
if (position >= sg.getStartRes() && position <= sg.getEndRes()) |
399 |
|
{ |
400 |
0 |
return sg; |
401 |
|
} |
402 |
|
} |
403 |
|
} |
404 |
|
} |
405 |
0 |
return null; |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
@see |
412 |
|
|
413 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
414 |
0 |
@Override... |
415 |
|
public SequenceGroup[] findAllGroups(SequenceI s) |
416 |
|
{ |
417 |
0 |
ArrayList<SequenceGroup> temp = new ArrayList<>(); |
418 |
|
|
419 |
0 |
synchronized (groups) |
420 |
|
{ |
421 |
0 |
int gSize = groups.size(); |
422 |
0 |
for (int i = 0; i < gSize; i++) |
423 |
|
{ |
424 |
0 |
SequenceGroup sg = groups.get(i); |
425 |
0 |
if (sg == null || sg.getSequences() == null) |
426 |
|
{ |
427 |
0 |
this.deleteGroup(sg); |
428 |
0 |
gSize--; |
429 |
0 |
continue; |
430 |
|
} |
431 |
|
|
432 |
0 |
if (sg.getSequences().contains(s)) |
433 |
|
{ |
434 |
0 |
temp.add(sg); |
435 |
|
} |
436 |
|
} |
437 |
|
} |
438 |
0 |
SequenceGroup[] ret = new SequenceGroup[temp.size()]; |
439 |
0 |
return temp.toArray(ret); |
440 |
|
} |
441 |
|
|
442 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
443 |
0 |
@Override... |
444 |
|
public void addGroup(SequenceGroup sg) |
445 |
|
{ |
446 |
0 |
synchronized (groups) |
447 |
|
{ |
448 |
0 |
if (!groups.contains(sg)) |
449 |
|
{ |
450 |
0 |
if (hiddenSequences.getSize() > 0) |
451 |
|
{ |
452 |
0 |
int i, iSize = sg.getSize(); |
453 |
0 |
for (i = 0; i < iSize; i++) |
454 |
|
{ |
455 |
0 |
if (!sequences.contains(sg.getSequenceAt(i))) |
456 |
|
{ |
457 |
0 |
sg.deleteSequence(sg.getSequenceAt(i), false); |
458 |
0 |
iSize--; |
459 |
0 |
i--; |
460 |
|
} |
461 |
|
} |
462 |
|
|
463 |
0 |
if (sg.getSize() < 1) |
464 |
|
{ |
465 |
0 |
return; |
466 |
|
} |
467 |
|
} |
468 |
0 |
sg.setContext(this, true); |
469 |
0 |
groups.add(sg); |
470 |
|
} |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
@param |
478 |
|
|
479 |
|
|
|
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 11 |
Complexity Density: 0.52 |
|
480 |
0 |
private void removeAnnotationForGroup(SequenceGroup gp)... |
481 |
|
{ |
482 |
0 |
if (annotations == null || annotations.length == 0) |
483 |
|
{ |
484 |
0 |
return; |
485 |
|
} |
486 |
|
|
487 |
0 |
AlignmentAnnotation[] t, |
488 |
|
todelete = new AlignmentAnnotation[annotations.length], |
489 |
|
tokeep = new AlignmentAnnotation[annotations.length]; |
490 |
0 |
int i, p, k; |
491 |
0 |
if (gp == null) |
492 |
|
{ |
493 |
0 |
for (i = 0, p = 0, k = 0; i < annotations.length; i++) |
494 |
|
{ |
495 |
0 |
if (annotations[i].groupRef != null) |
496 |
|
{ |
497 |
0 |
todelete[p++] = annotations[i]; |
498 |
|
} |
499 |
|
else |
500 |
|
{ |
501 |
0 |
tokeep[k++] = annotations[i]; |
502 |
|
} |
503 |
|
} |
504 |
|
} |
505 |
|
else |
506 |
|
{ |
507 |
0 |
for (i = 0, p = 0, k = 0; i < annotations.length; i++) |
508 |
|
{ |
509 |
0 |
if (annotations[i].groupRef == gp) |
510 |
|
{ |
511 |
0 |
todelete[p++] = annotations[i]; |
512 |
|
} |
513 |
|
else |
514 |
|
{ |
515 |
0 |
tokeep[k++] = annotations[i]; |
516 |
|
} |
517 |
|
} |
518 |
|
} |
519 |
0 |
if (p > 0) |
520 |
|
{ |
521 |
|
|
522 |
0 |
for (i = 0; i < p; i++) |
523 |
|
{ |
524 |
0 |
unhookAnnotation(todelete[i]); |
525 |
0 |
todelete[i] = null; |
526 |
|
} |
527 |
0 |
t = new AlignmentAnnotation[k]; |
528 |
0 |
for (i = 0; i < k; i++) |
529 |
|
{ |
530 |
0 |
t[i] = tokeep[i]; |
531 |
|
} |
532 |
0 |
annotations = t; |
533 |
|
} |
534 |
|
} |
535 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
536 |
0 |
@Override... |
537 |
|
public void deleteAllGroups() |
538 |
|
{ |
539 |
0 |
synchronized (groups) |
540 |
|
{ |
541 |
0 |
if (annotations != null) |
542 |
|
{ |
543 |
0 |
removeAnnotationForGroup(null); |
544 |
|
} |
545 |
0 |
for (SequenceGroup sg : groups) |
546 |
|
{ |
547 |
0 |
sg.setContext(null, false); |
548 |
|
} |
549 |
0 |
groups.clear(); |
550 |
|
} |
551 |
|
} |
552 |
|
|
553 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
554 |
0 |
@Override... |
555 |
|
public void deleteGroup(SequenceGroup g) |
556 |
|
{ |
557 |
0 |
synchronized (groups) |
558 |
|
{ |
559 |
0 |
if (groups.contains(g)) |
560 |
|
{ |
561 |
0 |
removeAnnotationForGroup(g); |
562 |
0 |
groups.remove(g); |
563 |
0 |
g.setContext(null, false); |
564 |
|
} |
565 |
|
} |
566 |
|
} |
567 |
|
|
568 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
569 |
0 |
@Override... |
570 |
|
public SequenceI findName(String name) |
571 |
|
{ |
572 |
0 |
return findName(name, false); |
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
@see |
579 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
580 |
0 |
@Override... |
581 |
|
public SequenceI findName(String token, boolean b) |
582 |
|
{ |
583 |
0 |
return findName(null, token, b); |
584 |
|
} |
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
@see |
590 |
|
|
591 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 9 |
Complexity Density: 0.47 |
|
592 |
0 |
@Override... |
593 |
|
public SequenceI findName(SequenceI startAfter, String token, boolean b) |
594 |
|
{ |
595 |
|
|
596 |
0 |
int i = 0; |
597 |
0 |
SequenceI sq = null; |
598 |
0 |
String sqname = null; |
599 |
0 |
int nseq = sequences.size(); |
600 |
0 |
if (startAfter != null) |
601 |
|
{ |
602 |
|
|
603 |
0 |
boolean matched = false; |
604 |
0 |
while (i < nseq) |
605 |
|
{ |
606 |
0 |
if (getSequenceAt(i++) == startAfter) |
607 |
|
{ |
608 |
0 |
matched = true; |
609 |
0 |
break; |
610 |
|
} |
611 |
|
} |
612 |
0 |
if (!matched) |
613 |
|
{ |
614 |
0 |
i = 0; |
615 |
|
} |
616 |
|
} |
617 |
0 |
while (i < nseq) |
618 |
|
{ |
619 |
0 |
sq = getSequenceAt(i); |
620 |
0 |
sqname = sq.getName(); |
621 |
0 |
if (sqname.equals(token) |
622 |
|
|| (b && |
623 |
|
(sqname.equalsIgnoreCase(token)))) |
624 |
|
{ |
625 |
0 |
return getSequenceAt(i); |
626 |
|
} |
627 |
|
|
628 |
0 |
i++; |
629 |
|
} |
630 |
|
|
631 |
0 |
return null; |
632 |
|
} |
633 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
634 |
0 |
@Override... |
635 |
|
public SequenceI[] findSequenceMatch(String name) |
636 |
|
{ |
637 |
0 |
Vector matches = new Vector(); |
638 |
0 |
int i = 0; |
639 |
|
|
640 |
0 |
while (i < sequences.size()) |
641 |
|
{ |
642 |
0 |
if (getSequenceAt(i).getName().equals(name)) |
643 |
|
{ |
644 |
0 |
matches.addElement(getSequenceAt(i)); |
645 |
|
} |
646 |
0 |
i++; |
647 |
|
} |
648 |
|
|
649 |
0 |
SequenceI[] result = new SequenceI[matches.size()]; |
650 |
0 |
for (i = 0; i < result.length; i++) |
651 |
|
{ |
652 |
0 |
result[i] = (SequenceI) matches.elementAt(i); |
653 |
|
} |
654 |
|
|
655 |
0 |
return result; |
656 |
|
|
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
@see |
663 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
664 |
0 |
@Override... |
665 |
|
public int findIndex(SequenceI s) |
666 |
|
{ |
667 |
0 |
int i = 0; |
668 |
|
|
669 |
0 |
while (i < sequences.size()) |
670 |
|
{ |
671 |
0 |
if (s == getSequenceAt(i)) |
672 |
|
{ |
673 |
0 |
return i; |
674 |
|
} |
675 |
|
|
676 |
0 |
i++; |
677 |
|
} |
678 |
|
|
679 |
0 |
return -1; |
680 |
|
} |
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
@see |
686 |
|
|
687 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
688 |
0 |
@Override... |
689 |
|
public int findIndex(SearchResultsI results) |
690 |
|
{ |
691 |
0 |
int i = 0; |
692 |
|
|
693 |
0 |
while (i < sequences.size()) |
694 |
|
{ |
695 |
0 |
if (results.involvesSequence(getSequenceAt(i))) |
696 |
|
{ |
697 |
0 |
return i; |
698 |
|
} |
699 |
0 |
i++; |
700 |
|
} |
701 |
0 |
return -1; |
702 |
|
} |
703 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
704 |
0 |
@Override... |
705 |
|
public int getHeight() |
706 |
|
{ |
707 |
0 |
return sequences.size(); |
708 |
|
} |
709 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
710 |
0 |
@Override... |
711 |
|
public int getAbsoluteHeight() |
712 |
|
{ |
713 |
0 |
return sequences.size() + getHiddenSequences().getSize(); |
714 |
|
} |
715 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
716 |
0 |
@Override... |
717 |
|
public int getWidth() |
718 |
|
{ |
719 |
0 |
int maxLength = -1; |
720 |
|
|
721 |
0 |
for (int i = 0; i < sequences.size(); i++) |
722 |
|
{ |
723 |
0 |
maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); |
724 |
|
} |
725 |
0 |
return maxLength; |
726 |
|
} |
727 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
728 |
0 |
@Override... |
729 |
|
public int getVisibleWidth() |
730 |
|
{ |
731 |
0 |
int w = getWidth(); |
732 |
0 |
if (hiddenCols != null) |
733 |
|
{ |
734 |
0 |
w -= hiddenCols.getSize(); |
735 |
|
} |
736 |
0 |
return w; |
737 |
|
} |
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
@param |
743 |
|
|
744 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
745 |
0 |
@Override... |
746 |
|
public void setGapCharacter(char gc) |
747 |
|
{ |
748 |
0 |
gapCharacter = gc; |
749 |
0 |
synchronized (sequences) |
750 |
|
{ |
751 |
0 |
for (SequenceI seq : sequences) |
752 |
|
{ |
753 |
0 |
seq.setSequence(seq.getSequenceAsString().replace('.', gc) |
754 |
|
.replace('-', gc).replace(' ', gc)); |
755 |
|
} |
756 |
|
} |
757 |
|
} |
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
@return |
763 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
764 |
0 |
@Override... |
765 |
|
public char getGapCharacter() |
766 |
|
{ |
767 |
0 |
return gapCharacter; |
768 |
|
} |
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
@see |
774 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
775 |
0 |
@Override... |
776 |
|
public boolean isAligned() |
777 |
|
{ |
778 |
0 |
return isAligned(false); |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
@see |
785 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 7 |
Complexity Density: 0.88 |
|
786 |
0 |
@Override... |
787 |
|
public boolean isAligned(boolean includeHidden) |
788 |
|
{ |
789 |
0 |
int width = getWidth(); |
790 |
0 |
if (hiddenSequences == null || hiddenSequences.getSize() == 0) |
791 |
|
{ |
792 |
0 |
includeHidden = true; |
793 |
|
} |
794 |
0 |
for (int i = 0; i < sequences.size(); i++) |
795 |
|
{ |
796 |
0 |
if (includeHidden || !hiddenSequences.isHidden(getSequenceAt(i))) |
797 |
|
{ |
798 |
0 |
if (getSequenceAt(i).getLength() != width) |
799 |
|
{ |
800 |
0 |
return false; |
801 |
|
} |
802 |
|
} |
803 |
|
} |
804 |
|
|
805 |
0 |
return true; |
806 |
|
} |
807 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
808 |
0 |
@Override... |
809 |
|
public boolean isHidden(int alignmentIndex) |
810 |
|
{ |
811 |
0 |
return (getHiddenSequences().getHiddenSequence(alignmentIndex) != null); |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
@param |
819 |
|
@return |
820 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
821 |
0 |
@Override... |
822 |
|
public boolean deleteAllAnnotations(boolean includingAutoCalculated) |
823 |
|
{ |
824 |
0 |
boolean result = false; |
825 |
0 |
for (AlignmentAnnotation alan : getAlignmentAnnotation()) |
826 |
|
{ |
827 |
0 |
if (!alan.autoCalculated || includingAutoCalculated) |
828 |
|
{ |
829 |
0 |
deleteAnnotation(alan); |
830 |
0 |
result = true; |
831 |
|
} |
832 |
|
} |
833 |
0 |
return result; |
834 |
|
} |
835 |
|
|
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
842 |
0 |
@Override... |
843 |
|
public boolean deleteAnnotation(AlignmentAnnotation aa) |
844 |
|
{ |
845 |
0 |
return deleteAnnotation(aa, true); |
846 |
|
} |
847 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 8 |
Complexity Density: 0.42 |
|
848 |
0 |
@Override... |
849 |
|
public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook) |
850 |
|
{ |
851 |
0 |
int aSize = 1; |
852 |
|
|
853 |
0 |
if (annotations != null) |
854 |
|
{ |
855 |
0 |
aSize = annotations.length; |
856 |
|
} |
857 |
|
|
858 |
0 |
if (aSize < 1) |
859 |
|
{ |
860 |
0 |
return false; |
861 |
|
} |
862 |
|
|
863 |
0 |
AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1]; |
864 |
|
|
865 |
0 |
boolean swap = false; |
866 |
0 |
int tIndex = 0; |
867 |
|
|
868 |
0 |
for (int i = 0; i < aSize; i++) |
869 |
|
{ |
870 |
0 |
if (annotations[i] == aa) |
871 |
|
{ |
872 |
0 |
swap = true; |
873 |
0 |
continue; |
874 |
|
} |
875 |
0 |
if (tIndex < temp.length) |
876 |
|
{ |
877 |
0 |
temp[tIndex++] = annotations[i]; |
878 |
|
} |
879 |
|
} |
880 |
|
|
881 |
0 |
if (swap) |
882 |
|
{ |
883 |
0 |
annotations = temp; |
884 |
0 |
if (unhook) |
885 |
|
{ |
886 |
0 |
unhookAnnotation(aa); |
887 |
|
} |
888 |
|
} |
889 |
0 |
return swap; |
890 |
|
} |
891 |
|
|
892 |
|
|
893 |
|
|
894 |
|
|
895 |
|
@param |
896 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
897 |
0 |
private void unhookAnnotation(AlignmentAnnotation aa)... |
898 |
|
{ |
899 |
0 |
if (aa.sequenceRef != null) |
900 |
|
{ |
901 |
0 |
aa.sequenceRef.removeAlignmentAnnotation(aa); |
902 |
|
} |
903 |
0 |
if (aa.groupRef != null) |
904 |
|
{ |
905 |
|
|
906 |
0 |
aa.groupRef = null; |
907 |
|
} |
908 |
|
} |
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
|
|
915 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
916 |
0 |
@Override... |
917 |
|
public void addAnnotation(AlignmentAnnotation aa) |
918 |
|
{ |
919 |
0 |
addAnnotation(aa, -1); |
920 |
|
} |
921 |
|
|
922 |
|
|
923 |
|
|
924 |
|
|
925 |
|
|
926 |
|
|
927 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 9 |
Complexity Density: 0.5 |
|
928 |
0 |
@Override... |
929 |
|
public void addAnnotation(AlignmentAnnotation aa, int pos) |
930 |
|
{ |
931 |
0 |
if (aa.getRNAStruc() != null) |
932 |
|
{ |
933 |
0 |
hasRNAStructure = true; |
934 |
|
} |
935 |
|
|
936 |
0 |
int aSize = 1; |
937 |
0 |
if (annotations != null) |
938 |
|
{ |
939 |
0 |
aSize = annotations.length + 1; |
940 |
|
} |
941 |
|
|
942 |
0 |
AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize]; |
943 |
0 |
int i = 0; |
944 |
0 |
if (pos == -1 || pos >= aSize) |
945 |
|
{ |
946 |
0 |
temp[aSize - 1] = aa; |
947 |
|
} |
948 |
|
else |
949 |
|
{ |
950 |
0 |
temp[pos] = aa; |
951 |
|
} |
952 |
0 |
if (aSize > 1) |
953 |
|
{ |
954 |
0 |
int p = 0; |
955 |
0 |
for (i = 0; i < (aSize - 1); i++, p++) |
956 |
|
{ |
957 |
0 |
if (p == pos) |
958 |
|
{ |
959 |
0 |
p++; |
960 |
|
} |
961 |
0 |
if (p < temp.length) |
962 |
|
{ |
963 |
0 |
temp[p] = annotations[i]; |
964 |
|
} |
965 |
|
} |
966 |
|
} |
967 |
|
|
968 |
0 |
annotations = temp; |
969 |
|
} |
970 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 7 |
Complexity Density: 0.58 |
|
971 |
0 |
@Override... |
972 |
|
public void setAnnotationIndex(AlignmentAnnotation aa, int index) |
973 |
|
{ |
974 |
0 |
if (aa == null || annotations == null || annotations.length - 1 < index) |
975 |
|
{ |
976 |
0 |
return; |
977 |
|
} |
978 |
|
|
979 |
0 |
int aSize = annotations.length; |
980 |
0 |
AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize]; |
981 |
|
|
982 |
0 |
temp[index] = aa; |
983 |
|
|
984 |
0 |
for (int i = 0; i < aSize; i++) |
985 |
|
{ |
986 |
0 |
if (i == index) |
987 |
|
{ |
988 |
0 |
continue; |
989 |
|
} |
990 |
|
|
991 |
0 |
if (i < index) |
992 |
|
{ |
993 |
0 |
temp[i] = annotations[i]; |
994 |
|
} |
995 |
|
else |
996 |
|
{ |
997 |
0 |
temp[i] = annotations[i - 1]; |
998 |
|
} |
999 |
|
} |
1000 |
|
|
1001 |
0 |
annotations = temp; |
1002 |
|
} |
1003 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1004 |
0 |
@Override... |
1005 |
|
|
1006 |
|
|
1007 |
|
|
1008 |
|
public AlignmentAnnotation[] getAlignmentAnnotation() |
1009 |
|
{ |
1010 |
0 |
return annotations; |
1011 |
|
} |
1012 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1013 |
0 |
@Override... |
1014 |
|
public boolean isNucleotide() |
1015 |
|
{ |
1016 |
0 |
return nucleotide; |
1017 |
|
} |
1018 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1019 |
0 |
@Override... |
1020 |
|
public boolean hasRNAStructure() |
1021 |
|
{ |
1022 |
|
|
1023 |
0 |
return hasRNAStructure; |
1024 |
|
} |
1025 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 11 |
Complexity Density: 0.58 |
|
1026 |
0 |
@Override... |
1027 |
|
public void setDataset(AlignmentI data) |
1028 |
|
{ |
1029 |
0 |
if (dataset == null && data == null) |
1030 |
|
{ |
1031 |
0 |
createDatasetAlignment(); |
1032 |
|
} |
1033 |
0 |
else if (dataset == null && data != null) |
1034 |
|
{ |
1035 |
0 |
if (data == this) |
1036 |
|
{ |
1037 |
0 |
throw new IllegalArgumentException("Circular dataset reference"); |
1038 |
|
} |
1039 |
0 |
if (!(data instanceof Alignment)) |
1040 |
|
{ |
1041 |
0 |
throw new Error( |
1042 |
|
"Implementation Error: jalview.datamodel.Alignment does not yet support other implementations of AlignmentI as its dataset reference"); |
1043 |
|
} |
1044 |
0 |
dataset = (Alignment) data; |
1045 |
0 |
for (int i = 0; i < getHeight(); i++) |
1046 |
|
{ |
1047 |
0 |
SequenceI currentSeq = getSequenceAt(i); |
1048 |
0 |
SequenceI dsq = currentSeq.getDatasetSequence(); |
1049 |
0 |
if (dsq == null) |
1050 |
|
{ |
1051 |
0 |
dsq = currentSeq.createDatasetSequence(); |
1052 |
0 |
dataset.addSequence(dsq); |
1053 |
|
} |
1054 |
|
else |
1055 |
|
{ |
1056 |
0 |
while (dsq.getDatasetSequence() != null) |
1057 |
|
{ |
1058 |
0 |
dsq = dsq.getDatasetSequence(); |
1059 |
|
} |
1060 |
0 |
if (dataset.findIndex(dsq) == -1) |
1061 |
|
{ |
1062 |
0 |
dataset.addSequence(dsq); |
1063 |
|
} |
1064 |
|
} |
1065 |
|
} |
1066 |
|
} |
1067 |
0 |
dataset.addAlignmentRef(); |
1068 |
|
} |
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 10 |
Complexity Density: 0.53 |
|
1073 |
0 |
private void resolveAndAddDatasetSeq(SequenceI currentSeq,... |
1074 |
|
Set<SequenceI> seqs, boolean createDatasetSequence) |
1075 |
|
{ |
1076 |
0 |
SequenceI alignedSeq = currentSeq; |
1077 |
0 |
if (currentSeq.getDatasetSequence() != null) |
1078 |
|
{ |
1079 |
0 |
currentSeq = currentSeq.getDatasetSequence(); |
1080 |
|
} |
1081 |
|
else |
1082 |
|
{ |
1083 |
0 |
if (createDatasetSequence) |
1084 |
|
{ |
1085 |
0 |
currentSeq = currentSeq.createDatasetSequence(); |
1086 |
|
} |
1087 |
|
} |
1088 |
|
|
1089 |
0 |
List<SequenceI> toProcess = new ArrayList<>(); |
1090 |
0 |
toProcess.add(currentSeq); |
1091 |
0 |
while (toProcess.size() > 0) |
1092 |
|
{ |
1093 |
|
|
1094 |
0 |
SequenceI curDs = toProcess.remove(0); |
1095 |
|
|
1096 |
0 |
if (!seqs.add(curDs)) |
1097 |
|
{ |
1098 |
0 |
continue; |
1099 |
|
} |
1100 |
|
|
1101 |
|
|
1102 |
0 |
if (curDs.getDBRefs() != null) |
1103 |
|
{ |
1104 |
0 |
for (DBRefEntry dbr : curDs.getDBRefs()) |
1105 |
|
{ |
1106 |
0 |
if (dbr.getMap() != null && dbr.getMap().getTo() != null) |
1107 |
|
{ |
1108 |
0 |
if (dbr.getMap().getTo() == alignedSeq) |
1109 |
|
{ |
1110 |
|
|
1111 |
|
|
1112 |
|
|
1113 |
0 |
dbr.getMap().setTo(currentSeq); |
1114 |
|
} |
1115 |
0 |
if (dbr.getMap().getTo().getDatasetSequence() != null) |
1116 |
|
{ |
1117 |
0 |
throw new Error("Implementation error: Map.getTo() for dbref " |
1118 |
|
+ dbr + " from " + curDs.getName() |
1119 |
|
+ " is not a dataset sequence."); |
1120 |
|
} |
1121 |
|
|
1122 |
|
|
1123 |
0 |
toProcess.add(dbr.getMap().getTo()); |
1124 |
|
} |
1125 |
|
} |
1126 |
|
} |
1127 |
|
} |
1128 |
|
} |
1129 |
|
|
1130 |
|
|
1131 |
|
|
1132 |
|
|
1133 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
1134 |
0 |
public void createDatasetAlignment()... |
1135 |
|
{ |
1136 |
0 |
if (dataset != null) |
1137 |
|
{ |
1138 |
0 |
return; |
1139 |
|
} |
1140 |
|
|
1141 |
0 |
Set<SequenceI> seqs = new LinkedIdentityHashSet<>(); |
1142 |
|
|
1143 |
0 |
for (int i = 0; i < getHeight(); i++) |
1144 |
|
{ |
1145 |
0 |
SequenceI currentSeq = getSequenceAt(i); |
1146 |
0 |
resolveAndAddDatasetSeq(currentSeq, seqs, true); |
1147 |
|
} |
1148 |
|
|
1149 |
|
|
1150 |
0 |
for (AlignedCodonFrame cf : codonFrameList) |
1151 |
|
{ |
1152 |
0 |
for (SequenceToSequenceMapping ssm : cf.getMappings()) |
1153 |
|
{ |
1154 |
0 |
if (!seqs.contains(ssm.getFromSeq())) |
1155 |
|
{ |
1156 |
0 |
resolveAndAddDatasetSeq(ssm.getFromSeq(), seqs, false); |
1157 |
|
} |
1158 |
0 |
if (!seqs.contains(ssm.getMapping().getTo())) |
1159 |
|
{ |
1160 |
0 |
resolveAndAddDatasetSeq(ssm.getMapping().getTo(), seqs, false); |
1161 |
|
} |
1162 |
|
} |
1163 |
|
} |
1164 |
|
|
1165 |
0 |
dataset = new Alignment(seqs.toArray(new SequenceI[seqs.size()])); |
1166 |
|
|
1167 |
0 |
dataset.codonFrameList = this.codonFrameList; |
1168 |
0 |
this.codonFrameList = null; |
1169 |
|
} |
1170 |
|
|
1171 |
|
|
1172 |
|
|
1173 |
|
|
1174 |
|
int alignmentRefs = 0; |
1175 |
|
|
1176 |
|
|
1177 |
|
|
1178 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1179 |
0 |
private void addAlignmentRef()... |
1180 |
|
{ |
1181 |
0 |
alignmentRefs++; |
1182 |
|
} |
1183 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1184 |
0 |
@Override... |
1185 |
|
public Alignment getDataset() |
1186 |
|
{ |
1187 |
0 |
return dataset; |
1188 |
|
} |
1189 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 8 |
Complexity Density: 0.38 |
|
1190 |
0 |
@Override... |
1191 |
|
public boolean padGaps() |
1192 |
|
{ |
1193 |
0 |
boolean modified = false; |
1194 |
|
|
1195 |
|
|
1196 |
0 |
int maxLength = -1; |
1197 |
|
|
1198 |
0 |
SequenceI current; |
1199 |
0 |
int nseq = sequences.size(); |
1200 |
0 |
for (int i = 0; i < nseq; i++) |
1201 |
|
{ |
1202 |
0 |
current = getSequenceAt(i); |
1203 |
0 |
for (int j = current.getLength(); j > maxLength; j--) |
1204 |
|
{ |
1205 |
0 |
if (j > maxLength |
1206 |
|
&& !jalview.util.Comparison.isGap(current.getCharAt(j))) |
1207 |
|
{ |
1208 |
0 |
maxLength = j; |
1209 |
0 |
break; |
1210 |
|
} |
1211 |
|
} |
1212 |
|
} |
1213 |
|
|
1214 |
0 |
maxLength++; |
1215 |
|
|
1216 |
0 |
int cLength; |
1217 |
0 |
for (int i = 0; i < nseq; i++) |
1218 |
|
{ |
1219 |
0 |
current = getSequenceAt(i); |
1220 |
0 |
cLength = current.getLength(); |
1221 |
|
|
1222 |
0 |
if (cLength < maxLength) |
1223 |
|
{ |
1224 |
0 |
current.insertCharAt(cLength, maxLength - cLength, gapCharacter); |
1225 |
0 |
modified = true; |
1226 |
|
} |
1227 |
0 |
else if (current.getLength() > maxLength) |
1228 |
|
{ |
1229 |
0 |
current.deleteChars(maxLength, current.getLength()); |
1230 |
|
} |
1231 |
|
} |
1232 |
0 |
return modified; |
1233 |
|
} |
1234 |
|
|
1235 |
|
|
1236 |
|
|
1237 |
|
|
1238 |
|
|
1239 |
|
@param |
1240 |
|
|
1241 |
|
@return |
1242 |
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 14 |
Complexity Density: 0.3 |
|
1243 |
0 |
@Override... |
1244 |
|
public boolean justify(boolean right) |
1245 |
|
{ |
1246 |
0 |
boolean modified = false; |
1247 |
|
|
1248 |
|
|
1249 |
0 |
int maxLength = -1; |
1250 |
0 |
int ends[] = new int[sequences.size() * 2]; |
1251 |
0 |
SequenceI current; |
1252 |
0 |
for (int i = 0; i < sequences.size(); i++) |
1253 |
|
{ |
1254 |
0 |
current = getSequenceAt(i); |
1255 |
|
|
1256 |
0 |
ends[i * 2] = current.findIndex(current.getStart()); |
1257 |
0 |
ends[i * 2 + 1] = current |
1258 |
|
.findIndex(current.getStart() + current.getLength()); |
1259 |
0 |
boolean hitres = false; |
1260 |
0 |
for (int j = 0, rs = 0, ssiz = current.getLength(); j < ssiz; j++) |
1261 |
|
{ |
1262 |
0 |
if (!jalview.util.Comparison.isGap(current.getCharAt(j))) |
1263 |
|
{ |
1264 |
0 |
if (!hitres) |
1265 |
|
{ |
1266 |
0 |
ends[i * 2] = j; |
1267 |
0 |
hitres = true; |
1268 |
|
} |
1269 |
|
else |
1270 |
|
{ |
1271 |
0 |
ends[i * 2 + 1] = j; |
1272 |
0 |
if (j - ends[i * 2] > maxLength) |
1273 |
|
{ |
1274 |
0 |
maxLength = j - ends[i * 2]; |
1275 |
|
} |
1276 |
|
} |
1277 |
|
} |
1278 |
|
} |
1279 |
|
} |
1280 |
|
|
1281 |
0 |
maxLength++; |
1282 |
|
|
1283 |
0 |
int cLength, extent, diff; |
1284 |
0 |
for (int i = 0; i < sequences.size(); i++) |
1285 |
|
{ |
1286 |
0 |
current = getSequenceAt(i); |
1287 |
|
|
1288 |
0 |
cLength = 1 + ends[i * 2 + 1] - ends[i * 2]; |
1289 |
0 |
diff = maxLength - cLength; |
1290 |
0 |
extent = current.getLength(); |
1291 |
0 |
if (right) |
1292 |
|
{ |
1293 |
|
|
1294 |
0 |
if (extent > ends[i * 2 + 1]) |
1295 |
|
{ |
1296 |
0 |
current.deleteChars(ends[i * 2 + 1] + 1, extent); |
1297 |
0 |
modified = true; |
1298 |
|
} |
1299 |
0 |
if (ends[i * 2] > diff) |
1300 |
|
{ |
1301 |
0 |
current.deleteChars(0, ends[i * 2] - diff); |
1302 |
0 |
modified = true; |
1303 |
|
} |
1304 |
|
else |
1305 |
|
{ |
1306 |
0 |
if (ends[i * 2] < diff) |
1307 |
|
{ |
1308 |
0 |
current.insertCharAt(0, diff - ends[i * 2], gapCharacter); |
1309 |
0 |
modified = true; |
1310 |
|
} |
1311 |
|
} |
1312 |
|
} |
1313 |
|
else |
1314 |
|
{ |
1315 |
|
|
1316 |
0 |
if (ends[i * 2] > 0) |
1317 |
|
{ |
1318 |
0 |
current.deleteChars(0, ends[i * 2]); |
1319 |
0 |
modified = true; |
1320 |
0 |
ends[i * 2 + 1] -= ends[i * 2]; |
1321 |
0 |
extent -= ends[i * 2]; |
1322 |
|
} |
1323 |
0 |
if (extent > maxLength) |
1324 |
|
{ |
1325 |
0 |
current.deleteChars(maxLength + 1, extent); |
1326 |
0 |
modified = true; |
1327 |
|
} |
1328 |
|
else |
1329 |
|
{ |
1330 |
0 |
if (extent < maxLength) |
1331 |
|
{ |
1332 |
0 |
current.insertCharAt(extent, maxLength - extent, gapCharacter); |
1333 |
0 |
modified = true; |
1334 |
|
} |
1335 |
|
} |
1336 |
|
} |
1337 |
|
} |
1338 |
0 |
return modified; |
1339 |
|
} |
1340 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1341 |
0 |
@Override... |
1342 |
|
public HiddenSequences getHiddenSequences() |
1343 |
|
{ |
1344 |
0 |
return hiddenSequences; |
1345 |
|
} |
1346 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1347 |
0 |
@Override... |
1348 |
|
public HiddenColumns getHiddenColumns() |
1349 |
|
{ |
1350 |
0 |
return hiddenCols; |
1351 |
|
} |
1352 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
1353 |
0 |
@Override... |
1354 |
|
public CigarArray getCompactAlignment() |
1355 |
|
{ |
1356 |
0 |
synchronized (sequences) |
1357 |
|
{ |
1358 |
0 |
SeqCigar alseqs[] = new SeqCigar[sequences.size()]; |
1359 |
0 |
int i = 0; |
1360 |
0 |
for (SequenceI seq : sequences) |
1361 |
|
{ |
1362 |
0 |
alseqs[i++] = new SeqCigar(seq); |
1363 |
|
} |
1364 |
0 |
CigarArray cal = new CigarArray(alseqs); |
1365 |
0 |
cal.addOperation(CigarArray.M, getWidth()); |
1366 |
0 |
return cal; |
1367 |
|
} |
1368 |
|
} |
1369 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1370 |
0 |
@Override... |
1371 |
|
public void setProperty(Object key, Object value) |
1372 |
|
{ |
1373 |
0 |
if (alignmentProperties == null) |
1374 |
|
{ |
1375 |
0 |
alignmentProperties = new Hashtable(); |
1376 |
|
} |
1377 |
|
|
1378 |
0 |
alignmentProperties.put(key, value); |
1379 |
|
} |
1380 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1381 |
0 |
@Override... |
1382 |
|
public Object getProperty(Object key) |
1383 |
|
{ |
1384 |
0 |
if (alignmentProperties != null) |
1385 |
|
{ |
1386 |
0 |
return alignmentProperties.get(key); |
1387 |
|
} |
1388 |
|
else |
1389 |
|
{ |
1390 |
0 |
return null; |
1391 |
|
} |
1392 |
|
} |
1393 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1394 |
0 |
@Override... |
1395 |
|
public Hashtable getProperties() |
1396 |
|
{ |
1397 |
0 |
return alignmentProperties; |
1398 |
|
} |
1399 |
|
|
1400 |
|
|
1401 |
|
|
1402 |
|
|
1403 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
1404 |
0 |
@Override... |
1405 |
|
public void addCodonFrame(AlignedCodonFrame codons) |
1406 |
|
{ |
1407 |
0 |
List<AlignedCodonFrame> acfs = getCodonFrames(); |
1408 |
0 |
if (codons != null && acfs != null && !acfs.contains(codons)) |
1409 |
|
{ |
1410 |
0 |
acfs.add(codons); |
1411 |
|
} |
1412 |
|
} |
1413 |
|
|
1414 |
|
|
1415 |
|
|
1416 |
|
|
1417 |
|
@see |
1418 |
|
|
1419 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
1420 |
0 |
@Override... |
1421 |
|
public List<AlignedCodonFrame> getCodonFrame(SequenceI seq) |
1422 |
|
{ |
1423 |
0 |
if (seq == null) |
1424 |
|
{ |
1425 |
0 |
return null; |
1426 |
|
} |
1427 |
0 |
List<AlignedCodonFrame> cframes = new ArrayList<>(); |
1428 |
0 |
for (AlignedCodonFrame acf : getCodonFrames()) |
1429 |
|
{ |
1430 |
0 |
if (acf.involvesSequence(seq)) |
1431 |
|
{ |
1432 |
0 |
cframes.add(acf); |
1433 |
|
} |
1434 |
|
} |
1435 |
0 |
return cframes; |
1436 |
|
} |
1437 |
|
|
1438 |
|
|
1439 |
|
|
1440 |
|
|
1441 |
|
|
1442 |
|
@see |
1443 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1444 |
0 |
@Override... |
1445 |
|
public void setCodonFrames(List<AlignedCodonFrame> acfs) |
1446 |
|
{ |
1447 |
0 |
if (dataset != null) |
1448 |
|
{ |
1449 |
0 |
dataset.setCodonFrames(acfs); |
1450 |
|
} |
1451 |
|
else |
1452 |
|
{ |
1453 |
0 |
this.codonFrameList = acfs; |
1454 |
|
} |
1455 |
|
} |
1456 |
|
|
1457 |
|
|
1458 |
|
|
1459 |
|
|
1460 |
|
|
1461 |
|
|
1462 |
|
@see |
1463 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1464 |
0 |
@Override... |
1465 |
|
public List<AlignedCodonFrame> getCodonFrames() |
1466 |
|
{ |
1467 |
|
|
1468 |
|
|
1469 |
|
|
1470 |
|
|
1471 |
0 |
return dataset != null ? dataset.getCodonFrames() : codonFrameList; |
1472 |
|
} |
1473 |
|
|
1474 |
|
|
1475 |
|
|
1476 |
|
|
1477 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
1478 |
0 |
@Override... |
1479 |
|
public boolean removeCodonFrame(AlignedCodonFrame codons) |
1480 |
|
{ |
1481 |
0 |
List<AlignedCodonFrame> acfs = getCodonFrames(); |
1482 |
0 |
if (codons == null || acfs == null) |
1483 |
|
{ |
1484 |
0 |
return false; |
1485 |
|
} |
1486 |
0 |
return acfs.remove(codons); |
1487 |
|
} |
1488 |
|
|
|
|
| 0% |
Uncovered Elements: 78 (78) |
Complexity: 20 |
Complexity Density: 0.45 |
|
1489 |
0 |
@Override... |
1490 |
|
public void append(AlignmentI toappend) |
1491 |
|
{ |
1492 |
|
|
1493 |
|
|
1494 |
0 |
char oldc = toappend.getGapCharacter(); |
1495 |
0 |
boolean samegap = oldc == getGapCharacter(); |
1496 |
0 |
boolean hashidden = toappend.getHiddenSequences() != null |
1497 |
|
&& toappend.getHiddenSequences().hiddenSequences != null; |
1498 |
|
|
1499 |
0 |
List<SequenceI> sqs = (hashidden) |
1500 |
|
? toappend.getHiddenSequences().getFullAlignment() |
1501 |
|
.getSequences() |
1502 |
|
: toappend.getSequences(); |
1503 |
0 |
if (sqs != null) |
1504 |
|
{ |
1505 |
|
|
1506 |
0 |
List<SequenceI> toappendsq = new ArrayList<>(); |
1507 |
0 |
synchronized (sqs) |
1508 |
|
{ |
1509 |
0 |
for (SequenceI addedsq : sqs) |
1510 |
|
{ |
1511 |
0 |
if (!samegap) |
1512 |
|
{ |
1513 |
0 |
addedsq.replace(oldc, gapCharacter); |
1514 |
|
} |
1515 |
0 |
toappendsq.add(addedsq); |
1516 |
|
} |
1517 |
|
} |
1518 |
0 |
for (SequenceI addedsq : toappendsq) |
1519 |
|
{ |
1520 |
0 |
addSequence(addedsq); |
1521 |
|
} |
1522 |
|
} |
1523 |
0 |
AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation(); |
1524 |
0 |
for (int a = 0; alan != null && a < alan.length; a++) |
1525 |
|
{ |
1526 |
0 |
addAnnotation(alan[a]); |
1527 |
|
} |
1528 |
|
|
1529 |
|
|
1530 |
0 |
getCodonFrames().addAll(toappend.getCodonFrames()); |
1531 |
|
|
1532 |
0 |
List<SequenceGroup> sg = toappend.getGroups(); |
1533 |
0 |
if (sg != null) |
1534 |
|
{ |
1535 |
0 |
for (SequenceGroup _sg : sg) |
1536 |
|
{ |
1537 |
0 |
addGroup(_sg); |
1538 |
|
} |
1539 |
|
} |
1540 |
0 |
if (toappend.getHiddenSequences() != null) |
1541 |
|
{ |
1542 |
0 |
HiddenSequences hs = toappend.getHiddenSequences(); |
1543 |
0 |
if (hiddenSequences == null) |
1544 |
|
{ |
1545 |
0 |
hiddenSequences = new HiddenSequences(this); |
1546 |
|
} |
1547 |
0 |
if (hs.hiddenSequences != null) |
1548 |
|
{ |
1549 |
0 |
for (int s = 0; s < hs.hiddenSequences.length; s++) |
1550 |
|
{ |
1551 |
|
|
1552 |
0 |
if (hs.hiddenSequences[s] != null) |
1553 |
|
{ |
1554 |
0 |
hiddenSequences.hideSequence(hs.hiddenSequences[s]); |
1555 |
|
} |
1556 |
|
} |
1557 |
|
} |
1558 |
|
} |
1559 |
0 |
if (toappend.getProperties() != null) |
1560 |
|
{ |
1561 |
|
|
1562 |
|
|
1563 |
0 |
Enumeration key = toappend.getProperties().keys(); |
1564 |
0 |
while (key.hasMoreElements()) |
1565 |
|
{ |
1566 |
0 |
Object k = key.nextElement(); |
1567 |
0 |
Object ourval = this.getProperty(k); |
1568 |
0 |
Object toapprop = toappend.getProperty(k); |
1569 |
0 |
if (ourval != null) |
1570 |
|
{ |
1571 |
0 |
if (ourval.getClass().equals(toapprop.getClass()) |
1572 |
|
&& !ourval.equals(toapprop)) |
1573 |
|
{ |
1574 |
0 |
if (ourval instanceof String) |
1575 |
|
{ |
1576 |
|
|
1577 |
0 |
this.setProperty(k, |
1578 |
|
((String) ourval) + "; " + ((String) toapprop)); |
1579 |
|
} |
1580 |
|
else |
1581 |
|
{ |
1582 |
0 |
if (ourval instanceof Vector) |
1583 |
|
{ |
1584 |
|
|
1585 |
0 |
Enumeration theirv = ((Vector) toapprop).elements(); |
1586 |
0 |
while (theirv.hasMoreElements()) |
1587 |
|
{ |
1588 |
0 |
((Vector) ourval).addElement(theirv); |
1589 |
|
} |
1590 |
|
} |
1591 |
|
} |
1592 |
|
} |
1593 |
|
} |
1594 |
|
else |
1595 |
|
{ |
1596 |
|
|
1597 |
0 |
setProperty(k, toapprop); |
1598 |
|
} |
1599 |
|
|
1600 |
|
} |
1601 |
|
} |
1602 |
|
} |
1603 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 10 |
Complexity Density: 0.71 |
|
1604 |
0 |
@Override... |
1605 |
|
public AlignmentAnnotation findOrCreateAnnotation(String name, |
1606 |
|
String calcId, boolean autoCalc, SequenceI seqRef, |
1607 |
|
SequenceGroup groupRef) |
1608 |
|
{ |
1609 |
0 |
if (annotations != null) |
1610 |
|
{ |
1611 |
0 |
for (AlignmentAnnotation annot : getAlignmentAnnotation()) |
1612 |
|
{ |
1613 |
0 |
if (annot.autoCalculated == autoCalc && (name.equals(annot.label)) |
1614 |
|
&& (calcId == null || annot.getCalcId().equals(calcId)) |
1615 |
|
&& annot.sequenceRef == seqRef |
1616 |
|
&& annot.groupRef == groupRef) |
1617 |
|
{ |
1618 |
0 |
return annot; |
1619 |
|
} |
1620 |
|
} |
1621 |
|
} |
1622 |
0 |
AlignmentAnnotation annot = new AlignmentAnnotation(name, name, |
1623 |
|
new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH); |
1624 |
0 |
annot.hasText = false; |
1625 |
0 |
if (calcId != null) |
1626 |
|
{ |
1627 |
0 |
annot.setCalcId(new String(calcId)); |
1628 |
|
} |
1629 |
0 |
annot.autoCalculated = autoCalc; |
1630 |
0 |
if (seqRef != null) |
1631 |
|
{ |
1632 |
0 |
annot.setSequenceRef(seqRef); |
1633 |
|
} |
1634 |
0 |
annot.groupRef = groupRef; |
1635 |
0 |
addAnnotation(annot); |
1636 |
|
|
1637 |
0 |
return annot; |
1638 |
|
} |
1639 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1640 |
0 |
@Override... |
1641 |
|
public Iterable<AlignmentAnnotation> findAnnotation(String calcId) |
1642 |
|
{ |
1643 |
0 |
AlignmentAnnotation[] alignmentAnnotation = getAlignmentAnnotation(); |
1644 |
0 |
if (alignmentAnnotation != null) |
1645 |
|
{ |
1646 |
0 |
return AlignmentAnnotation.findAnnotation( |
1647 |
|
Arrays.asList(getAlignmentAnnotation()), calcId); |
1648 |
|
} |
1649 |
0 |
return Arrays.asList(new AlignmentAnnotation[] {}); |
1650 |
|
} |
1651 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1652 |
0 |
@Override... |
1653 |
|
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq, |
1654 |
|
String calcId, String label) |
1655 |
|
{ |
1656 |
0 |
return annotations == null ? null |
1657 |
|
: AlignmentAnnotation.findAnnotations( |
1658 |
|
Arrays.asList(getAlignmentAnnotation()), seq, calcId, |
1659 |
|
label); |
1660 |
|
} |
1661 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 8 |
Complexity Density: 0.4 |
|
1662 |
0 |
@Override... |
1663 |
|
public void moveSelectedSequencesByOne(SequenceGroup sg, |
1664 |
|
Map<SequenceI, SequenceCollectionI> map, boolean up) |
1665 |
|
{ |
1666 |
0 |
synchronized (sequences) |
1667 |
|
{ |
1668 |
0 |
if (up) |
1669 |
|
{ |
1670 |
|
|
1671 |
0 |
for (int i = 1, iSize = sequences.size(); i < iSize; i++) |
1672 |
|
{ |
1673 |
0 |
SequenceI seq = sequences.get(i); |
1674 |
0 |
if (!sg.getSequences(map).contains(seq)) |
1675 |
|
{ |
1676 |
0 |
continue; |
1677 |
|
} |
1678 |
|
|
1679 |
0 |
SequenceI temp = sequences.get(i - 1); |
1680 |
0 |
if (sg.getSequences(null).contains(temp)) |
1681 |
|
{ |
1682 |
0 |
continue; |
1683 |
|
} |
1684 |
|
|
1685 |
0 |
sequences.set(i, temp); |
1686 |
0 |
sequences.set(i - 1, seq); |
1687 |
|
} |
1688 |
|
} |
1689 |
|
else |
1690 |
|
{ |
1691 |
0 |
for (int i = sequences.size() - 2; i > -1; i--) |
1692 |
|
{ |
1693 |
0 |
SequenceI seq = sequences.get(i); |
1694 |
0 |
if (!sg.getSequences(map).contains(seq)) |
1695 |
|
{ |
1696 |
0 |
continue; |
1697 |
|
} |
1698 |
|
|
1699 |
0 |
SequenceI temp = sequences.get(i + 1); |
1700 |
0 |
if (sg.getSequences(map).contains(temp)) |
1701 |
|
{ |
1702 |
0 |
continue; |
1703 |
|
} |
1704 |
|
|
1705 |
0 |
sequences.set(i, temp); |
1706 |
0 |
sequences.set(i + 1, seq); |
1707 |
|
} |
1708 |
|
} |
1709 |
|
|
1710 |
|
} |
1711 |
|
} |
1712 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
1713 |
0 |
@Override... |
1714 |
|
public void validateAnnotation(AlignmentAnnotation alignmentAnnotation) |
1715 |
|
{ |
1716 |
0 |
alignmentAnnotation.validateRangeAndDisplay(); |
1717 |
0 |
if (isNucleotide() && alignmentAnnotation.isValidStruc()) |
1718 |
|
{ |
1719 |
0 |
hasRNAStructure = true; |
1720 |
|
} |
1721 |
|
} |
1722 |
|
|
1723 |
|
private SequenceI seqrep = null; |
1724 |
|
|
1725 |
|
|
1726 |
|
|
1727 |
|
@return |
1728 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1729 |
0 |
@Override... |
1730 |
|
public SequenceI getSeqrep() |
1731 |
|
{ |
1732 |
0 |
return seqrep; |
1733 |
|
} |
1734 |
|
|
1735 |
|
|
1736 |
|
|
1737 |
|
|
1738 |
|
|
1739 |
|
@param |
1740 |
|
|
1741 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1742 |
0 |
@Override... |
1743 |
|
public void setSeqrep(SequenceI seqrep) |
1744 |
|
{ |
1745 |
0 |
this.seqrep = seqrep; |
1746 |
|
} |
1747 |
|
|
1748 |
|
|
1749 |
|
|
1750 |
|
@return |
1751 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1752 |
0 |
@Override... |
1753 |
|
public boolean hasSeqrep() |
1754 |
|
{ |
1755 |
0 |
return seqrep != null; |
1756 |
|
} |
1757 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1758 |
0 |
@Override... |
1759 |
|
public int getEndRes() |
1760 |
|
{ |
1761 |
0 |
return getWidth() - 1; |
1762 |
|
} |
1763 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1764 |
0 |
@Override... |
1765 |
|
public int getStartRes() |
1766 |
|
{ |
1767 |
0 |
return 0; |
1768 |
|
} |
1769 |
|
|
1770 |
|
|
1771 |
|
|
1772 |
|
|
1773 |
|
|
1774 |
|
@see |
1775 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1776 |
0 |
@Override... |
1777 |
|
public AnnotatedCollectionI getContext() |
1778 |
|
{ |
1779 |
0 |
return dataset; |
1780 |
|
} |
1781 |
|
|
1782 |
|
|
1783 |
|
|
1784 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1785 |
0 |
@Override... |
1786 |
|
public int alignAs(AlignmentI al) |
1787 |
|
{ |
1788 |
|
|
1789 |
|
|
1790 |
|
|
1791 |
|
|
1792 |
0 |
return alignAs(al, false, true); |
1793 |
|
} |
1794 |
|
|
1795 |
|
|
1796 |
|
|
1797 |
|
|
1798 |
|
|
1799 |
|
|
1800 |
|
|
1801 |
|
|
1802 |
|
|
1803 |
|
|
1804 |
|
|
1805 |
|
|
1806 |
|
|
1807 |
|
|
1808 |
|
|
1809 |
|
@param |
1810 |
|
|
1811 |
|
|
1812 |
|
@param |
1813 |
|
|
1814 |
|
@param |
1815 |
|
|
1816 |
|
|
1817 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
1818 |
0 |
public int alignAs(AlignmentI al, boolean preserveMappedGaps,... |
1819 |
|
boolean preserveUnmappedGaps) |
1820 |
|
{ |
1821 |
|
|
1822 |
|
|
1823 |
0 |
boolean thisIsNucleotide = this.isNucleotide(); |
1824 |
0 |
boolean thatIsProtein = !al.isNucleotide(); |
1825 |
0 |
if (!thatIsProtein && !thisIsNucleotide) |
1826 |
|
{ |
1827 |
0 |
return AlignmentUtils.alignProteinAsDna(this, al); |
1828 |
|
} |
1829 |
0 |
else if (thatIsProtein && thisIsNucleotide) |
1830 |
|
{ |
1831 |
0 |
return AlignmentUtils.alignCdsAsProtein(this, al); |
1832 |
|
} |
1833 |
0 |
return AlignmentUtils.alignAs(this, al); |
1834 |
|
} |
1835 |
|
|
1836 |
|
|
1837 |
|
|
1838 |
|
|
1839 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1840 |
0 |
@Override... |
1841 |
|
public String toString() |
1842 |
|
{ |
1843 |
0 |
return new FastaFile().print(getSequencesArray(), true); |
1844 |
|
} |
1845 |
|
|
1846 |
|
|
1847 |
|
|
1848 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1849 |
0 |
@Override... |
1850 |
|
public Set<String> getSequenceNames() |
1851 |
|
{ |
1852 |
0 |
Set<String> names = new HashSet<>(); |
1853 |
0 |
for (SequenceI seq : getSequences()) |
1854 |
|
{ |
1855 |
0 |
names.add(seq.getName()); |
1856 |
|
} |
1857 |
0 |
return names; |
1858 |
|
} |
1859 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
1860 |
0 |
@Override... |
1861 |
|
public boolean hasValidSequence() |
1862 |
|
{ |
1863 |
0 |
boolean hasValidSeq = false; |
1864 |
0 |
for (SequenceI seq : getSequences()) |
1865 |
|
{ |
1866 |
0 |
if ((seq.getEnd() - seq.getStart()) > 0) |
1867 |
|
{ |
1868 |
0 |
hasValidSeq = true; |
1869 |
0 |
break; |
1870 |
|
} |
1871 |
|
} |
1872 |
0 |
return hasValidSeq; |
1873 |
|
} |
1874 |
|
|
1875 |
|
|
1876 |
|
|
1877 |
|
|
1878 |
|
|
1879 |
|
@param |
1880 |
|
@return |
1881 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1882 |
0 |
@Override... |
1883 |
|
public int realiseMappings(List<SequenceI> seqs) |
1884 |
|
{ |
1885 |
0 |
int count = 0; |
1886 |
0 |
for (SequenceI seq : seqs) |
1887 |
|
{ |
1888 |
0 |
for (AlignedCodonFrame mapping : getCodonFrames()) |
1889 |
|
{ |
1890 |
0 |
count += mapping.realiseWith(seq); |
1891 |
|
} |
1892 |
|
} |
1893 |
0 |
return count; |
1894 |
|
} |
1895 |
|
|
1896 |
|
|
1897 |
|
|
1898 |
|
|
1899 |
|
|
1900 |
|
@param |
1901 |
|
@param |
1902 |
|
@return |
1903 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1904 |
0 |
@Override... |
1905 |
|
public AlignedCodonFrame getMapping(SequenceI mapFrom, SequenceI mapTo) |
1906 |
|
{ |
1907 |
0 |
for (AlignedCodonFrame acf : getCodonFrames()) |
1908 |
|
{ |
1909 |
0 |
if (acf.getAaForDnaSeq(mapFrom) == mapTo) |
1910 |
|
{ |
1911 |
0 |
return acf; |
1912 |
|
} |
1913 |
|
} |
1914 |
0 |
return null; |
1915 |
|
} |
1916 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1917 |
0 |
@Override... |
1918 |
|
public boolean setHiddenColumns(HiddenColumns cols) |
1919 |
|
{ |
1920 |
0 |
boolean changed = cols == null ? hiddenCols != null |
1921 |
|
: !cols.equals(hiddenCols); |
1922 |
0 |
hiddenCols = cols; |
1923 |
0 |
return changed; |
1924 |
|
} |
1925 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1926 |
0 |
@Override... |
1927 |
|
public void setupJPredAlignment() |
1928 |
|
{ |
1929 |
0 |
SequenceI repseq = getSequenceAt(0); |
1930 |
0 |
setSeqrep(repseq); |
1931 |
0 |
HiddenColumns cs = new HiddenColumns(); |
1932 |
0 |
cs.hideList(repseq.getInsertions()); |
1933 |
0 |
setHiddenColumns(cs); |
1934 |
|
} |
1935 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
1936 |
0 |
@Override... |
1937 |
|
public HiddenColumns propagateInsertions(SequenceI profileseq, |
1938 |
|
AlignmentView input) |
1939 |
|
{ |
1940 |
0 |
int profsqpos = 0; |
1941 |
|
|
1942 |
0 |
char gc = getGapCharacter(); |
1943 |
0 |
Object[] alandhidden = input.getAlignmentAndHiddenColumns(gc); |
1944 |
0 |
HiddenColumns nview = (HiddenColumns) alandhidden[1]; |
1945 |
0 |
SequenceI origseq = ((SequenceI[]) alandhidden[0])[profsqpos]; |
1946 |
0 |
return propagateInsertions(profileseq, origseq, nview); |
1947 |
|
} |
1948 |
|
|
1949 |
|
|
1950 |
|
|
1951 |
|
@param |
1952 |
|
|
1953 |
|
@param |
1954 |
|
|
1955 |
|
@param |
1956 |
|
|
1957 |
|
|
1958 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 4 |
Complexity Density: 0.24 |
|
1959 |
0 |
private HiddenColumns propagateInsertions(SequenceI profileseq,... |
1960 |
|
SequenceI origseq, HiddenColumns hc) |
1961 |
|
{ |
1962 |
|
|
1963 |
|
|
1964 |
|
|
1965 |
|
|
1966 |
|
|
1967 |
0 |
BitSet gaps = origseq.gapBitset(); |
1968 |
0 |
hc.andNot(gaps); |
1969 |
|
|
1970 |
|
|
1971 |
|
|
1972 |
|
|
1973 |
|
|
1974 |
0 |
HiddenColumns newhidden = new HiddenColumns(); |
1975 |
|
|
1976 |
0 |
int numGapsBefore = 0; |
1977 |
0 |
int gapPosition = 0; |
1978 |
0 |
Iterator<int[]> it = hc.iterator(); |
1979 |
0 |
while (it.hasNext()) |
1980 |
|
{ |
1981 |
0 |
int[] region = it.next(); |
1982 |
|
|
1983 |
|
|
1984 |
|
|
1985 |
|
|
1986 |
0 |
while (gapPosition < region[0]) |
1987 |
|
{ |
1988 |
0 |
gapPosition++; |
1989 |
0 |
if (gaps.get(gapPosition)) |
1990 |
|
{ |
1991 |
0 |
numGapsBefore++; |
1992 |
|
} |
1993 |
|
} |
1994 |
|
|
1995 |
0 |
int left = region[0] - numGapsBefore; |
1996 |
0 |
int right = region[1] - numGapsBefore; |
1997 |
|
|
1998 |
0 |
newhidden.hideColumns(left, right); |
1999 |
0 |
padGaps(left, right, profileseq); |
2000 |
|
} |
2001 |
0 |
return newhidden; |
2002 |
|
} |
2003 |
|
|
2004 |
|
|
2005 |
|
|
2006 |
|
|
2007 |
|
@param |
2008 |
|
|
2009 |
|
@param |
2010 |
|
|
2011 |
|
@param |
2012 |
|
|
2013 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
2014 |
0 |
private void padGaps(int left, int right, SequenceI profileseq)... |
2015 |
|
{ |
2016 |
0 |
char gc = getGapCharacter(); |
2017 |
|
|
2018 |
|
|
2019 |
0 |
StringBuilder sb = new StringBuilder(); |
2020 |
0 |
for (int g = 0; g < right - left + 1; g++) |
2021 |
|
{ |
2022 |
0 |
sb.append(gc); |
2023 |
|
} |
2024 |
|
|
2025 |
|
|
2026 |
0 |
for (int s = 0, ns = getHeight(); s < ns; s++) |
2027 |
|
{ |
2028 |
0 |
SequenceI sqobj = getSequenceAt(s); |
2029 |
0 |
if ((sqobj != profileseq) && (sqobj.getLength() >= left)) |
2030 |
|
{ |
2031 |
0 |
String sq = sqobj.getSequenceAsString(); |
2032 |
0 |
sqobj.setSequence( |
2033 |
|
sq.substring(0, left) + sb.toString() + sq.substring(left)); |
2034 |
|
} |
2035 |
|
} |
2036 |
|
} |
2037 |
|
|
2038 |
|
|
2039 |
|
|
2040 |
|
|
2041 |
|
ContactMapHolder cmholder = new ContactMapHolder(); |
2042 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2043 |
0 |
@Override... |
2044 |
|
public Collection<ContactMatrixI> getContactMaps() |
2045 |
|
{ |
2046 |
0 |
return cmholder.getContactMaps(); |
2047 |
|
} |
2048 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 7 |
Complexity Density: 0.88 |
|
2049 |
0 |
@Override... |
2050 |
|
public ContactMatrixI getContactMatrixFor(AlignmentAnnotation _aa) |
2051 |
|
{ |
2052 |
0 |
ContactMatrixI cm = cmholder.getContactMatrixFor(_aa); |
2053 |
0 |
if (cm == null && _aa.groupRef != null) |
2054 |
|
{ |
2055 |
0 |
cm = _aa.groupRef.getContactMatrixFor(_aa); |
2056 |
|
} |
2057 |
0 |
if (cm == null && _aa.sequenceRef != null) |
2058 |
|
{ |
2059 |
0 |
cm = _aa.sequenceRef.getContactMatrixFor(_aa); |
2060 |
0 |
if (cm == null && _aa.sequenceRef.getDatasetSequence() != null) |
2061 |
|
{ |
2062 |
|
|
2063 |
0 |
cm = _aa.sequenceRef.getDatasetSequence().getContactMatrixFor(_aa); |
2064 |
|
} |
2065 |
|
} |
2066 |
0 |
return cm; |
2067 |
|
} |
2068 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 13 |
Complexity Density: 1 |
|
2069 |
0 |
@Override... |
2070 |
|
public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) |
2071 |
|
{ |
2072 |
0 |
if (_aa.annotations == null || column >= _aa.annotations.length |
2073 |
|
|| column < 0) |
2074 |
|
{ |
2075 |
0 |
return null; |
2076 |
|
} |
2077 |
0 |
ContactListI cl = cmholder.getContactListFor(_aa, column); |
2078 |
0 |
if (cl == null && _aa.groupRef != null) |
2079 |
|
{ |
2080 |
0 |
cl = _aa.groupRef.getContactListFor(_aa, column); |
2081 |
|
} |
2082 |
0 |
if (cl == null && _aa.sequenceRef != null) |
2083 |
|
{ |
2084 |
0 |
if (_aa.annotations[column] != null) |
2085 |
|
{ |
2086 |
|
|
2087 |
0 |
cl = _aa.sequenceRef.getContactListFor(_aa, column); |
2088 |
0 |
if (cl == null && _aa.sequenceRef.getDatasetSequence() != null) |
2089 |
|
{ |
2090 |
0 |
int spos = _aa.sequenceRef.findPosition(column); |
2091 |
0 |
if (spos >= _aa.sequenceRef.getStart() |
2092 |
|
&& spos <= 1 + _aa.sequenceRef.getEnd()) |
2093 |
|
{ |
2094 |
0 |
cl = _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, |
2095 |
|
spos - _aa.sequenceRef.getStart()); |
2096 |
|
} |
2097 |
|
} |
2098 |
|
} |
2099 |
|
} |
2100 |
0 |
return cl; |
2101 |
|
} |
2102 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
2103 |
0 |
@Override... |
2104 |
|
public AlignmentAnnotation addContactList(ContactMatrixI cm) |
2105 |
|
{ |
2106 |
0 |
AlignmentAnnotation aa = cmholder.addContactList(cm); |
2107 |
|
|
2108 |
0 |
Annotation _aa[] = new Annotation[getWidth()]; |
2109 |
0 |
for (int i = 0; i < _aa.length; _aa[i++] = new Annotation(0.0f)) |
2110 |
|
{ |
2111 |
0 |
; |
2112 |
|
} |
2113 |
0 |
aa.annotations = _aa; |
2114 |
0 |
addAnnotation(aa); |
2115 |
0 |
return aa; |
2116 |
|
} |
2117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2118 |
0 |
@Override... |
2119 |
|
public void addContactListFor(AlignmentAnnotation annotation, |
2120 |
|
ContactMatrixI cm) |
2121 |
|
{ |
2122 |
0 |
cmholder.addContactListFor(annotation, cm); |
2123 |
|
|
2124 |
|
} |
2125 |
|
} |