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 java.util.List; |
24 |
|
|
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.ContiguousI; |
27 |
|
import jalview.datamodel.SequenceI; |
28 |
|
import jalview.util.Comparison; |
29 |
|
|
|
|
| 89.7% |
Uncovered Elements: 4 (39) |
Complexity: 10 |
Complexity Density: 0.42 |
|
30 |
|
public class JustifyLeftOrRightCommand extends EditCommand |
31 |
|
{ |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@param |
36 |
|
|
37 |
|
@param |
38 |
|
|
39 |
|
@param |
40 |
|
|
41 |
|
@param |
42 |
|
|
43 |
|
|
44 |
|
@param |
45 |
|
|
46 |
|
|
47 |
|
@param |
48 |
|
|
|
|
| 89.5% |
Uncovered Elements: 4 (38) |
Complexity: 10 |
Complexity Density: 0.42 |
|
49 |
2 |
public JustifyLeftOrRightCommand(String description, boolean left,... |
50 |
|
List<SequenceI> seqs, int from, int to, AlignmentI al) |
51 |
|
{ |
52 |
2 |
this.description = description; |
53 |
|
|
54 |
2 |
for (SequenceI seq : seqs) |
55 |
|
{ |
56 |
6 |
ContiguousI cont = seq.findPositions(from + 1, to + 1); |
57 |
6 |
if (cont == null) |
58 |
|
{ |
59 |
0 |
continue; |
60 |
|
} |
61 |
6 |
char[] range = seq.getSequence(from, to + 1); |
62 |
6 |
if (range == null || range.length == 0) |
63 |
|
{ |
64 |
0 |
continue; |
65 |
|
} |
66 |
6 |
int dsstart = seq.getDatasetSequence().getStart(); |
67 |
6 |
char[] sqchar = seq.getDatasetSequence().getSequence( |
68 |
|
-dsstart + cont.getBegin(), -dsstart + cont.getEnd() + 1); |
69 |
|
|
70 |
|
|
71 |
6 |
char[] alseq = new char[to - from + 1]; |
72 |
6 |
int sqstart = left ? 0 : alseq.length - sqchar.length; |
73 |
6 |
int gaps = alseq.length - sqchar.length; |
74 |
6 |
int gapstart = left ? sqchar.length : 0; |
75 |
6 |
char gc = al.getGapCharacter(); |
76 |
23 |
for (int gp = 0; gp < gaps; gp++) |
77 |
|
{ |
78 |
17 |
alseq[gapstart + gp] = gc; |
79 |
|
} |
80 |
|
|
81 |
45 |
for (int sqp = 0, insp = 0; sqp < alseq.length; sqp++) |
82 |
|
{ |
83 |
39 |
if (sqp < range.length && !Comparison.isGap(range[sqp])) |
84 |
|
{ |
85 |
22 |
alseq[insp++ + sqstart] = range[sqp]; |
86 |
|
} |
87 |
|
} |
88 |
6 |
SequenceI[] sqa = new SequenceI[1]; |
89 |
6 |
sqa[0] = seq; |
90 |
|
|
91 |
6 |
addEdit(new jalview.commands.EditCommand.Edit( |
92 |
|
jalview.commands.EditCommand.Action.REPLACE, sqa, from, |
93 |
|
to + 1, al, new String(alseq))); |
94 |
|
} |
95 |
|
|
96 |
2 |
performEdit(0, null); |
97 |
|
} |
98 |
|
} |