| 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: 80 (80) |
Complexity: 27 |
Complexity Density: 0.55 |
|
| 33 |
|
public class ConsensusThread extends AlignCalcWorker |
| 34 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
0 |
public ConsensusThread(AlignViewportI alignViewport,... |
| 36 |
|
AlignmentViewPanel alignPanel) |
| 37 |
|
{ |
| 38 |
0 |
super(alignViewport, alignPanel); |
| 39 |
|
} |
| 40 |
|
|
| |
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0.44 |
|
| 41 |
0 |
@Override... |
| 42 |
|
public void run() |
| 43 |
|
{ |
| 44 |
0 |
AlignmentAnnotation consensus = getConsensusAnnotation(); |
| 45 |
0 |
AlignmentAnnotation gap = getGapAnnotation(); |
| 46 |
0 |
if ((consensus == null && gap == null)) |
| 47 |
|
{ |
| 48 |
0 |
return; |
| 49 |
|
} |
| 50 |
0 |
if (alignViewport.isClosed()) |
| 51 |
|
{ |
| 52 |
0 |
abortAndDestroy(); |
| 53 |
0 |
return; |
| 54 |
|
} |
| 55 |
0 |
AlignmentI alignment = alignViewport.getAlignment(); |
| 56 |
|
|
| 57 |
0 |
int aWidth = -1; |
| 58 |
|
|
| 59 |
0 |
if (alignment == null || (aWidth = alignment.getWidth()) < 0) |
| 60 |
|
{ |
| 61 |
0 |
return; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
0 |
eraseConsensus(aWidth); |
| 65 |
0 |
computeConsensus(alignment); |
| 66 |
0 |
updateResultAnnotation(true); |
| 67 |
|
|
| 68 |
0 |
if (ap != null) |
| 69 |
|
{ |
| 70 |
0 |
ap.paintAlignment(true, true); |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
@param |
| 78 |
|
|
| 79 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 80 |
0 |
protected void eraseConsensus(int aWidth)... |
| 81 |
|
{ |
| 82 |
0 |
AlignmentAnnotation consensus = getConsensusAnnotation(); |
| 83 |
0 |
if (consensus != null) |
| 84 |
|
{ |
| 85 |
0 |
consensus.annotations = new Annotation[aWidth]; |
| 86 |
|
} |
| 87 |
0 |
AlignmentAnnotation gap = getGapAnnotation(); |
| 88 |
0 |
if (gap != null) |
| 89 |
|
{ |
| 90 |
0 |
gap.annotations = new Annotation[aWidth]; |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
|
| 95 |
|
@param |
| 96 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 97 |
0 |
protected void computeConsensus(AlignmentI alignment)... |
| 98 |
|
{ |
| 99 |
|
|
| 100 |
0 |
SequenceI[] aseqs = getSequences(); |
| 101 |
0 |
int width = alignment.getWidth(); |
| 102 |
0 |
ProfilesI hconsensus = AAFrequency.calculate(aseqs, width, 0, width, |
| 103 |
|
true); |
| 104 |
|
|
| 105 |
0 |
alignViewport.setSequenceConsensusHash(hconsensus); |
| 106 |
0 |
setColourSchemeConsensus(hconsensus); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
@return |
| 111 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 112 |
0 |
protected SequenceI[] getSequences()... |
| 113 |
|
{ |
| 114 |
0 |
return alignViewport.getAlignment().getSequencesArray(); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
@param |
| 119 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 120 |
0 |
protected void setColourSchemeConsensus(ProfilesI hconsensus)... |
| 121 |
|
{ |
| 122 |
0 |
ResidueShaderI cs = alignViewport.getResidueShading(); |
| 123 |
0 |
if (cs != null) |
| 124 |
|
{ |
| 125 |
0 |
cs.setConsensus(hconsensus); |
| 126 |
|
} |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
@return |
| 133 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 134 |
0 |
protected AlignmentAnnotation getConsensusAnnotation()... |
| 135 |
|
{ |
| 136 |
0 |
return alignViewport.getAlignmentConsensusAnnotation(); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
@return |
| 143 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
0 |
protected AlignmentAnnotation getGapAnnotation()... |
| 145 |
|
{ |
| 146 |
0 |
return alignViewport.getAlignmentGapAnnotation(); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 153 |
0 |
@Override... |
| 154 |
|
public void updateAnnotation() |
| 155 |
|
{ |
| 156 |
0 |
updateResultAnnotation(false); |
| 157 |
|
} |
| 158 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 6 |
Complexity Density: 0.86 |
|
| 159 |
0 |
public void updateResultAnnotation(boolean immediate)... |
| 160 |
|
{ |
| 161 |
0 |
AlignmentAnnotation consensus = getConsensusAnnotation(); |
| 162 |
0 |
ProfilesI hconsensus = (ProfilesI) getViewportConsensus(); |
| 163 |
0 |
if (immediate || !calcMan.isWorking(this) && consensus != null |
| 164 |
|
&& hconsensus != null) |
| 165 |
|
{ |
| 166 |
0 |
deriveConsensus(consensus, hconsensus); |
| 167 |
0 |
AlignmentAnnotation gap = getGapAnnotation(); |
| 168 |
0 |
if (gap != null) |
| 169 |
|
{ |
| 170 |
0 |
deriveGap(gap, hconsensus); |
| 171 |
|
} |
| 172 |
|
} |
| 173 |
|
} |
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
@param |
| 180 |
|
|
| 181 |
|
@param |
| 182 |
|
|
| 183 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 184 |
0 |
protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,... |
| 185 |
|
ProfilesI hconsensus) |
| 186 |
|
{ |
| 187 |
0 |
long nseq = getSequences().length; |
| 188 |
0 |
consensusAnnotation.setNoOfSequencesIncluded(nseq); |
| 189 |
0 |
AAFrequency.completeConsensus(consensusAnnotation, hconsensus, |
| 190 |
|
hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1, |
| 191 |
|
alignViewport.isIgnoreGapsConsensus(), |
| 192 |
|
alignViewport.isShowSequenceLogo(), nseq); |
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
@param |
| 202 |
|
|
| 203 |
|
@param |
| 204 |
|
|
| 205 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 206 |
0 |
protected void deriveGap(AlignmentAnnotation gapAnnotation,... |
| 207 |
|
ProfilesI hconsensus) |
| 208 |
|
{ |
| 209 |
0 |
long nseq = getSequences().length; |
| 210 |
0 |
gapAnnotation.setNoOfSequencesIncluded(nseq); |
| 211 |
0 |
AAFrequency.completeGapAnnot(gapAnnotation, hconsensus, |
| 212 |
|
hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1, |
| 213 |
|
nseq); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
@return |
| 220 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 221 |
0 |
protected Object getViewportConsensus()... |
| 222 |
|
{ |
| 223 |
|
|
| 224 |
0 |
return alignViewport.getSequenceConsensusHash(); |
| 225 |
|
} |
| 226 |
|
} |