1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import jalview.api.analysis.ScoreModelI; |
24 |
|
import jalview.api.analysis.SimilarityParamsI; |
25 |
|
import jalview.datamodel.AlignmentView; |
26 |
|
import jalview.datamodel.BinaryNode; |
27 |
|
import jalview.datamodel.CigarArray; |
28 |
|
import jalview.datamodel.SeqCigar; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.datamodel.SequenceNode; |
31 |
|
import jalview.util.MessageManager; |
32 |
|
import jalview.viewmodel.AlignmentViewport; |
33 |
|
|
34 |
|
|
35 |
|
import java.util.ArrayList; |
36 |
|
import java.util.BitSet; |
37 |
|
import java.util.List; |
38 |
|
import java.util.Vector; |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 16 |
Complexity Density: 0.32 |
|
40 |
|
public abstract class TreeBuilder extends TreeEngine |
41 |
|
{ |
42 |
|
public static final String AVERAGE_DISTANCE = "AV"; |
43 |
|
|
44 |
|
public static final String NEIGHBOUR_JOINING = "NJ"; |
45 |
|
|
46 |
|
protected SequenceI[] sequences; |
47 |
|
|
48 |
|
protected List<String> labels; |
49 |
|
|
50 |
|
public AlignmentView seqData; |
51 |
|
|
52 |
|
private AlignmentView seqStrings; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@param |
58 |
|
@param |
59 |
|
@param |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
61 |
0 |
public TreeBuilder(AlignmentViewport av, ScoreModelI sm,... |
62 |
|
SimilarityParamsI scoreParameters) |
63 |
|
{ |
64 |
0 |
int start, end; |
65 |
0 |
boolean selview = av.getSelectionGroup() != null |
66 |
|
&& av.getSelectionGroup().getSize() > 1; |
67 |
0 |
seqStrings = av.getAlignmentView(selview); |
68 |
0 |
if (!selview) |
69 |
|
{ |
70 |
0 |
start = 0; |
71 |
0 |
end = av.getAlignment().getWidth(); |
72 |
0 |
this.sequences = av.getAlignment().getSequencesArray(); |
73 |
|
} |
74 |
|
else |
75 |
|
{ |
76 |
0 |
start = av.getSelectionGroup().getStartRes(); |
77 |
0 |
end = av.getSelectionGroup().getEndRes() + 1; |
78 |
0 |
this.sequences = av.getSelectionGroup() |
79 |
|
.getSequencesInOrder(av.getAlignment()); |
80 |
|
} |
81 |
|
|
82 |
0 |
init(seqStrings, start, end); |
83 |
|
|
84 |
0 |
computeTree(sm, scoreParameters); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
0 |
public SequenceI[] getSequences()... |
88 |
|
{ |
89 |
0 |
return sequences; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
@return |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
0 |
public boolean hasDistances()... |
97 |
|
{ |
98 |
0 |
return true; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
@return |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0 |
public boolean hasBootstrap()... |
106 |
|
{ |
107 |
0 |
return false; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0 |
public boolean hasRootDistance()... |
111 |
|
{ |
112 |
0 |
return true; |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0 |
public List<String> getLabels(){... |
116 |
0 |
return this.labels; |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
@param |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
132 |
0 |
protected void computeTree(ScoreModelI sm, SimilarityParamsI scoreOptions)... |
133 |
|
{ |
134 |
0 |
labels = new ArrayList<String>(); |
135 |
0 |
sequences = sm.expandSeqData(sequences, seqData, scoreOptions, labels); |
136 |
0 |
noseqs = sequences.length; |
137 |
|
|
138 |
0 |
distances = sm.findDistances(seqData, scoreOptions); |
139 |
|
|
140 |
0 |
makeLeaves(); |
141 |
|
|
142 |
0 |
noClus = clusters.size(); |
143 |
|
|
144 |
0 |
cluster(); |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
147 |
0 |
protected void init(AlignmentView seqView, int start, int end)... |
148 |
|
{ |
149 |
0 |
this.node = new Vector<BinaryNode>(); |
150 |
0 |
if (seqView != null) |
151 |
|
{ |
152 |
0 |
this.seqData = seqView; |
153 |
|
} |
154 |
|
else |
155 |
|
{ |
156 |
0 |
SeqCigar[] seqs = new SeqCigar[sequences.length]; |
157 |
0 |
for (int i = 0; i < sequences.length; i++) |
158 |
|
{ |
159 |
0 |
seqs[i] = new SeqCigar(sequences[i], start, end); |
160 |
|
} |
161 |
0 |
CigarArray sdata = new CigarArray(seqs); |
162 |
0 |
sdata.addOperation(CigarArray.M, end - start + 1); |
163 |
0 |
this.seqData = new AlignmentView(sdata, start); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
0 |
noseqs = 0; |
170 |
|
|
171 |
0 |
done = new BitSet(); |
172 |
|
|
173 |
0 |
for (SequenceI seq : sequences) |
174 |
|
{ |
175 |
0 |
if (seq != null) |
176 |
|
{ |
177 |
0 |
noseqs++; |
178 |
|
} |
179 |
|
} |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
185 |
0 |
void makeLeaves()... |
186 |
|
{ |
187 |
0 |
clusters = new Vector<BitSet>(); |
188 |
|
|
189 |
0 |
for (int i = 0; i < noseqs; i++) |
190 |
|
{ |
191 |
0 |
SequenceNode sn = new SequenceNode(); |
192 |
|
|
193 |
0 |
sn.setElement(sequences[i]); |
194 |
|
|
195 |
0 |
if (labels.size() == noseqs) |
196 |
|
{ |
197 |
0 |
sn.setLabel(labels.get(i)); |
198 |
|
} |
199 |
|
|
200 |
0 |
sn.setName(sequences[i].getName()); |
201 |
|
|
202 |
0 |
node.addElement(sn); |
203 |
0 |
BitSet bs = new BitSet(); |
204 |
0 |
bs.set(i); |
205 |
0 |
clusters.addElement(bs); |
206 |
|
} |
207 |
|
} |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
209 |
0 |
public AlignmentView getOriginalData()... |
210 |
|
{ |
211 |
0 |
return seqStrings; |
212 |
|
} |
213 |
|
|
214 |
|
} |