1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.commands; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentI; |
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 57 (57) |
Complexity: 15 |
Complexity Density: 0.42 |
|
26 |
|
public class RemoveGapsCommand extends EditCommand |
27 |
|
{ |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
28 |
0 |
public RemoveGapsCommand(String description, SequenceI[] seqs,... |
29 |
|
AlignmentI al) |
30 |
|
{ |
31 |
0 |
this.description = description; |
32 |
0 |
int width = 0; |
33 |
0 |
for (int i = 0; i < seqs.length; i++) |
34 |
|
{ |
35 |
0 |
if (seqs[i].getLength() > width) |
36 |
|
{ |
37 |
0 |
width = seqs[i].getLength(); |
38 |
|
} |
39 |
|
} |
40 |
|
|
41 |
0 |
findGaps(seqs, 0, width, al); |
42 |
|
} |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
0 |
public RemoveGapsCommand(String description, SequenceI[] seqs, int start,... |
45 |
|
int end, AlignmentI al) |
46 |
|
{ |
47 |
0 |
this.description = description; |
48 |
0 |
findGaps(seqs, start, end, al); |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 11 |
Complexity Density: 0.39 |
|
51 |
0 |
void findGaps(SequenceI[] seqs, int start, int end, AlignmentI al)... |
52 |
|
{ |
53 |
|
|
54 |
0 |
int startCol = -1, endCol = -1; |
55 |
0 |
int deletedCols = 0; |
56 |
|
|
57 |
0 |
int j, jSize; |
58 |
|
|
59 |
0 |
clearEdits(); |
60 |
|
|
61 |
0 |
boolean delete = true; |
62 |
0 |
char[] sequence; |
63 |
|
|
64 |
0 |
for (int s = 0; s < seqs.length; s++) |
65 |
|
{ |
66 |
0 |
deletedCols = 0; |
67 |
0 |
startCol = -1; |
68 |
0 |
endCol = -1; |
69 |
0 |
sequence = seqs[s].getSequence(start, end + 1); |
70 |
|
|
71 |
0 |
jSize = sequence.length; |
72 |
0 |
for (j = 0; j < jSize; j++) |
73 |
|
{ |
74 |
0 |
delete = true; |
75 |
|
|
76 |
0 |
if (!jalview.util.Comparison.isGap(sequence[j])) |
77 |
|
{ |
78 |
0 |
if (delete) |
79 |
|
{ |
80 |
0 |
endCol = j; |
81 |
|
} |
82 |
|
|
83 |
0 |
delete = false; |
84 |
|
} |
85 |
|
|
86 |
0 |
if (delete && startCol == -1) |
87 |
|
{ |
88 |
0 |
startCol = j; |
89 |
|
} |
90 |
|
|
91 |
0 |
if (!delete && startCol > -1) |
92 |
|
{ |
93 |
0 |
this.appendEdit( |
94 |
|
Action.DELETE_GAP, new SequenceI[] |
95 |
|
{ seqs[s] }, start + startCol - deletedCols, |
96 |
|
endCol - startCol, al, false, null); |
97 |
|
|
98 |
0 |
deletedCols += (endCol - startCol); |
99 |
0 |
startCol = -1; |
100 |
0 |
endCol = -1; |
101 |
|
} |
102 |
|
} |
103 |
0 |
if (delete && startCol > -1) |
104 |
|
{ |
105 |
0 |
this.appendEdit( |
106 |
|
Action.DELETE_GAP, new SequenceI[] |
107 |
|
{ seqs[s] }, start + startCol - deletedCols, |
108 |
|
jSize - startCol, al, false, null); |
109 |
|
} |
110 |
|
|
111 |
|
} |
112 |
|
|
113 |
0 |
performEdit(0, null); |
114 |
|
} |
115 |
|
|
116 |
|
} |