1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.viewmodel; |
22 |
|
|
23 |
|
import jalview.analysis.PaSiMap; |
24 |
|
import jalview.api.RotatableCanvasI; |
25 |
|
import jalview.api.analysis.ScoreModelI; |
26 |
|
import jalview.api.analysis.SimilarityParamsI; |
27 |
|
import jalview.datamodel.AlignmentView; |
28 |
|
import jalview.datamodel.Point; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.datamodel.SequencePoint; |
31 |
|
import jalview.gui.PairwiseAlignPanel; |
32 |
|
import jalview.viewmodel.AlignmentViewport; |
33 |
|
|
34 |
|
import java.util.List; |
35 |
|
import java.util.Vector; |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 111 (111) |
Complexity: 35 |
Complexity Density: 0.52 |
|
37 |
|
public class PaSiMapModel |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
private AlignmentViewport inputData; |
43 |
|
|
44 |
|
private final SequenceI[] seqs; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
private ScoreModelI scoreModel; |
50 |
|
|
51 |
|
private boolean nucleotide = false; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private PaSiMap pasimap; |
57 |
|
|
58 |
|
int top; |
59 |
|
|
60 |
|
private List<SequencePoint> points; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
@param |
68 |
|
@param |
69 |
|
@param |
70 |
|
@param |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
72 |
0 |
public PaSiMapModel(AlignmentViewport seqData, SequenceI[] sqs,... |
73 |
|
boolean nuc, ScoreModelI modelName) |
74 |
|
{ |
75 |
0 |
inputData = seqData; |
76 |
0 |
seqs = sqs; |
77 |
0 |
nucleotide = nuc; |
78 |
0 |
scoreModel = modelName; |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.33 |
|
85 |
0 |
public void calculate(PairwiseAlignPanel pap)... |
86 |
|
{ |
87 |
0 |
pasimap = new PaSiMap(inputData, scoreModel, pap); |
88 |
0 |
pasimap.run(); |
89 |
0 |
if (pasimap.isCancelled()) |
90 |
|
{ |
91 |
|
|
92 |
0 |
return; |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
0 |
int ii = 0; |
97 |
|
|
98 |
0 |
while ((ii < seqs.length) && (seqs[ii] != null)) |
99 |
|
{ |
100 |
0 |
ii++; |
101 |
|
} |
102 |
|
|
103 |
0 |
int width = pasimap.getWidth(); |
104 |
0 |
int height = pasimap.getHeight(); |
105 |
0 |
top = width; |
106 |
|
|
107 |
0 |
points = new Vector<>(); |
108 |
0 |
Point[] scores = pasimap.getComponents(width - 1, width - 2, width - 3, |
109 |
|
1); |
110 |
|
|
111 |
0 |
for (int i = 0; i < height; i++) |
112 |
|
{ |
113 |
0 |
SequencePoint sp = new SequencePoint(seqs[i], scores[i]); |
114 |
0 |
points.add(sp); |
115 |
|
} |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
0 |
public void updateRc(RotatableCanvasI rc)... |
119 |
|
{ |
120 |
0 |
rc.setPoints(points, pasimap.getHeight()); |
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
public boolean isNucleotide()... |
124 |
|
{ |
125 |
0 |
return nucleotide; |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
0 |
public void setNucleotide(boolean nucleotide)... |
129 |
|
{ |
130 |
0 |
this.nucleotide = nucleotide; |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
@return |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
138 |
0 |
public int getTop()... |
139 |
|
{ |
140 |
0 |
return top; |
141 |
|
} |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
0 |
public void setTop(int t)... |
144 |
|
{ |
145 |
0 |
top = t; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
@param |
156 |
|
@param |
157 |
|
@param |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
159 |
0 |
public void updateRcView(int dim1, int dim2, int dim3)... |
160 |
|
{ |
161 |
|
|
162 |
0 |
Point[] scores = pasimap.getComponents(dim1 - 1, dim2 - 1, dim3 - 1, 1); |
163 |
|
|
164 |
0 |
for (int i = 0; i < pasimap.getHeight(); i++) |
165 |
|
{ |
166 |
0 |
points.get(i).coord = scores[i]; |
167 |
|
} |
168 |
|
} |
169 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
0 |
public String getDetails()... |
171 |
|
{ |
172 |
0 |
return pasimap.getDetails(); |
173 |
|
} |
174 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
0 |
public String getAlignmentOutput()... |
176 |
|
{ |
177 |
0 |
return pasimap.getAlignmentOutput(); |
178 |
|
} |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
180 |
0 |
public AlignmentViewport getInputData()... |
181 |
|
{ |
182 |
0 |
return inputData; |
183 |
|
} |
184 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
0 |
public void setInputData(AlignmentViewport data)... |
186 |
|
{ |
187 |
0 |
inputData = data; |
188 |
|
} |
189 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 6 |
Complexity Density: 0.24 |
|
190 |
0 |
public String getPointsasCsv(boolean transformed, int xdim, int ydim,... |
191 |
|
int zdim) |
192 |
|
{ |
193 |
0 |
StringBuffer csv = new StringBuffer(); |
194 |
0 |
csv.append("\"Sequence\""); |
195 |
0 |
if (transformed) |
196 |
|
{ |
197 |
0 |
csv.append(","); |
198 |
0 |
csv.append(xdim); |
199 |
0 |
csv.append(","); |
200 |
0 |
csv.append(ydim); |
201 |
0 |
csv.append(","); |
202 |
0 |
csv.append(zdim); |
203 |
|
} |
204 |
|
else |
205 |
|
{ |
206 |
0 |
for (int d = 1, dmax = (int) pasimap.getDim(); d <= dmax; d++) |
207 |
|
{ |
208 |
0 |
csv.append("," + d); |
209 |
|
} |
210 |
|
} |
211 |
0 |
csv.append("\n"); |
212 |
0 |
for (int s = 0; s < seqs.length; s++) |
213 |
|
{ |
214 |
0 |
csv.append("\"" + seqs[s].getName() + "\""); |
215 |
0 |
if (!transformed) |
216 |
|
{ |
217 |
0 |
double[] fl = pasimap.component(s); |
218 |
0 |
for (int d = fl.length - 1; d >= 0; d--) |
219 |
|
{ |
220 |
0 |
csv.append(","); |
221 |
0 |
csv.append(fl[d]); |
222 |
|
} |
223 |
|
} |
224 |
|
else |
225 |
|
{ |
226 |
0 |
Point p = points.get(s).coord; |
227 |
0 |
csv.append(",").append(p.x); |
228 |
0 |
csv.append(",").append(p.y); |
229 |
0 |
csv.append(",").append(p.z); |
230 |
|
} |
231 |
0 |
csv.append("\n"); |
232 |
|
} |
233 |
0 |
return csv.toString(); |
234 |
|
} |
235 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
236 |
0 |
public String getScoreModelName()... |
237 |
|
{ |
238 |
0 |
return scoreModel == null ? "" : scoreModel.getName(); |
239 |
|
} |
240 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
241 |
0 |
public void setScoreModel(ScoreModelI sm)... |
242 |
|
{ |
243 |
0 |
this.scoreModel = sm; |
244 |
|
} |
245 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
246 |
0 |
public List<SequencePoint> getSequencePoints()... |
247 |
|
{ |
248 |
0 |
return points; |
249 |
|
} |
250 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
251 |
0 |
public void setSequencePoints(List<SequencePoint> sp)... |
252 |
|
{ |
253 |
0 |
points = sp; |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
@return |
260 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
261 |
0 |
public PaSiMap getPasimapData()... |
262 |
|
{ |
263 |
0 |
return pasimap; |
264 |
|
} |
265 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
266 |
0 |
public void setPaSiMap(PaSiMap data)... |
267 |
|
{ |
268 |
0 |
pasimap = data; |
269 |
|
} |
270 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
271 |
0 |
public boolean isCancelled()... |
272 |
|
{ |
273 |
0 |
if (pasimap==null || pasimap.isCancelled()) |
274 |
|
{ |
275 |
0 |
return true; |
276 |
|
} |
277 |
0 |
return false; |
278 |
|
} |
279 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
280 |
0 |
public void cancel()... |
281 |
|
{ |
282 |
0 |
pasimap.cancel(); |
283 |
|
} |
284 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
285 |
0 |
public boolean canCancel()... |
286 |
|
{ |
287 |
0 |
return (!isCancelled() && pasimap.isCancellable()); |
288 |
|
} |
289 |
|
} |