1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.workers; |
22 |
|
|
23 |
|
import jalview.analysis.AAFrequency; |
24 |
|
import jalview.api.AlignViewportI; |
25 |
|
import jalview.api.AlignmentViewPanel; |
26 |
|
import jalview.datamodel.AlignmentAnnotation; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.Annotation; |
29 |
|
import jalview.datamodel.ProfilesI; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.renderer.ResidueShaderI; |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 84 (84) |
Complexity: 28 |
Complexity Density: 0.53 |
|
33 |
|
public class SecondaryStructureConsensusThread extends AlignCalcWorker |
34 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
35 |
0 |
public SecondaryStructureConsensusThread(AlignViewportI alignViewport,... |
36 |
|
AlignmentViewPanel alignPanel) |
37 |
|
{ |
38 |
0 |
super(alignViewport, alignPanel); |
39 |
|
} |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 12 |
Complexity Density: 0.4 |
|
41 |
0 |
@Override... |
42 |
|
public void run() |
43 |
|
{ |
44 |
0 |
if (calcMan.isPending(this)) |
45 |
|
{ |
46 |
0 |
return; |
47 |
|
} |
48 |
0 |
calcMan.notifyStart(this); |
49 |
|
|
50 |
0 |
try |
51 |
|
{ |
52 |
0 |
AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); |
53 |
0 |
if ((ssConsensus == null) || calcMan.isPending(this)) |
54 |
|
{ |
55 |
0 |
calcMan.workerComplete(this); |
56 |
0 |
return; |
57 |
|
} |
58 |
0 |
while (!calcMan.notifyWorking(this)) |
59 |
|
{ |
60 |
0 |
try |
61 |
|
{ |
62 |
0 |
if (ap != null) |
63 |
|
{ |
64 |
0 |
ap.paintAlignment(false, false); |
65 |
|
} |
66 |
0 |
Thread.sleep(200); |
67 |
|
} catch (Exception ex) |
68 |
|
{ |
69 |
0 |
ex.printStackTrace(); |
70 |
|
} |
71 |
|
} |
72 |
0 |
if (alignViewport.isClosed()) |
73 |
|
{ |
74 |
0 |
abortAndDestroy(); |
75 |
0 |
return; |
76 |
|
} |
77 |
0 |
AlignmentI alignment = alignViewport.getAlignment(); |
78 |
|
|
79 |
0 |
int aWidth = -1; |
80 |
|
|
81 |
0 |
if (alignment == null || (aWidth = alignment.getWidth()) < 0) |
82 |
|
{ |
83 |
0 |
calcMan.workerComplete(this); |
84 |
0 |
return; |
85 |
|
} |
86 |
|
|
87 |
0 |
eraseSSConsensus(aWidth); |
88 |
0 |
computeSSConsensus(alignment); |
89 |
0 |
updateResultAnnotation(true); |
90 |
|
|
91 |
0 |
if (ap != null) |
92 |
|
{ |
93 |
0 |
ap.paintAlignment(true, true); |
94 |
|
} |
95 |
|
} catch (OutOfMemoryError error) |
96 |
|
{ |
97 |
0 |
calcMan.disableWorker(this); |
98 |
0 |
ap.raiseOOMWarning("calculating consensus", error); |
99 |
|
} finally |
100 |
|
{ |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
0 |
calcMan.workerComplete(this); |
106 |
|
} |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
|
114 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
115 |
0 |
protected void eraseSSConsensus(int aWidth)... |
116 |
|
{ |
117 |
0 |
AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); |
118 |
0 |
if (ssConsensus != null) |
119 |
|
{ |
120 |
0 |
ssConsensus.annotations = new Annotation[aWidth]; |
121 |
|
} |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
@param |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
127 |
0 |
protected void computeSSConsensus(AlignmentI alignment)... |
128 |
|
{ |
129 |
|
|
130 |
0 |
SequenceI[] aseqs = getSequences(); |
131 |
0 |
int width = alignment.getWidth(); |
132 |
0 |
ProfilesI hSSConsensus = AAFrequency.calculateSS(aseqs, width, 0, width, |
133 |
|
true); |
134 |
|
|
135 |
0 |
alignViewport.setSequenceSSConsensusHash(hSSConsensus); |
136 |
0 |
setColourSchemeConsensus(hSSConsensus); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
@return |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0 |
protected SequenceI[] getSequences()... |
143 |
|
{ |
144 |
0 |
return alignViewport.getAlignment().getSequencesArray(); |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
@param |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
150 |
0 |
protected void setColourSchemeConsensus(ProfilesI hSSconsensus)... |
151 |
|
{ |
152 |
0 |
ResidueShaderI cs = alignViewport.getResidueShading(); |
153 |
0 |
if (cs != null) |
154 |
|
{ |
155 |
0 |
cs.setSsConsensus(hSSconsensus); |
156 |
|
} |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
@return |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
0 |
protected AlignmentAnnotation getSSConsensusAnnotation()... |
165 |
|
{ |
166 |
0 |
return alignViewport |
167 |
|
.getAlignmentSecondaryStructureConsensusAnnotation(); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
0 |
@Override... |
175 |
|
public void updateAnnotation() |
176 |
|
{ |
177 |
0 |
updateResultAnnotation(false); |
178 |
|
} |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 5 |
Complexity Density: 1 |
|
180 |
0 |
public void updateResultAnnotation(boolean immediate)... |
181 |
|
{ |
182 |
0 |
AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); |
183 |
0 |
ProfilesI hSSConsensus = (ProfilesI) getViewportSSConsensus(); |
184 |
0 |
if (immediate || !calcMan.isWorking(this) && ssConsensus != null |
185 |
|
&& hSSConsensus != null) |
186 |
|
{ |
187 |
0 |
deriveSSConsensus(ssConsensus, hSSConsensus); |
188 |
|
|
189 |
0 |
ssConsensus.hasData=hSSConsensus.getCount()>0; |
190 |
|
} |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
|
199 |
|
@param |
200 |
|
|
201 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
202 |
0 |
protected void deriveSSConsensus(... |
203 |
|
AlignmentAnnotation ssConsensusAnnotation, ProfilesI hSSConsensus) |
204 |
|
{ |
205 |
|
|
206 |
0 |
long nseq = getSequences().length; |
207 |
0 |
AAFrequency.completeSSConsensus(ssConsensusAnnotation, hSSConsensus, |
208 |
|
hSSConsensus.getStartColumn(), hSSConsensus.getEndColumn() + 1, |
209 |
|
alignViewport.isIgnoreGapsConsensus(), |
210 |
|
alignViewport.isShowSequenceLogo(), nseq); |
211 |
|
} |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
@return |
217 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
218 |
0 |
protected Object getViewportSSConsensus()... |
219 |
|
{ |
220 |
|
|
221 |
0 |
return alignViewport.getSequenceSSConsensusHash(); |
222 |
|
} |
223 |
|
} |