| 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 java.util.Collections; |
| 24 |
|
import java.util.HashMap; |
| 25 |
|
import java.util.List; |
| 26 |
|
import java.util.Map; |
| 27 |
|
|
| 28 |
|
import jalview.analysis.AAFrequency; |
| 29 |
|
import jalview.api.AlignViewportI; |
| 30 |
|
import jalview.api.AlignmentViewPanel; |
| 31 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 32 |
|
import jalview.datamodel.AlignmentI; |
| 33 |
|
import jalview.datamodel.Annotation; |
| 34 |
|
import jalview.datamodel.ProfilesI; |
| 35 |
|
import jalview.datamodel.SequenceI; |
| 36 |
|
import jalview.renderer.ResidueShaderI; |
| 37 |
|
import jalview.util.Constants; |
| 38 |
|
import jalview.util.MessageManager; |
| 39 |
|
|
| |
|
| 0% |
Uncovered Elements: 106 (106) |
Complexity: 34 |
Complexity Density: 0.52 |
|
| 40 |
|
public class SecondaryStructureConsensusThread extends AlignCalcWorker |
| 41 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0 |
public SecondaryStructureConsensusThread(AlignViewportI alignViewport,... |
| 43 |
|
AlignmentViewPanel alignPanel) |
| 44 |
|
{ |
| 45 |
0 |
super(alignViewport, alignPanel); |
| 46 |
|
} |
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 48 |
0 |
@Override... |
| 49 |
|
public void run() |
| 50 |
|
{ |
| 51 |
0 |
List<AlignmentAnnotation> ssConsensus = getSSConsensusAnnotation(); |
| 52 |
0 |
if (ssConsensus == null) |
| 53 |
|
{ |
| 54 |
0 |
return; |
| 55 |
|
} |
| 56 |
0 |
if (alignViewport.isClosed()) |
| 57 |
|
{ |
| 58 |
0 |
abortAndDestroy(); |
| 59 |
0 |
return; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
0 |
AlignmentI alignment = alignViewport.getAlignment(); |
| 63 |
|
|
| 64 |
0 |
int aWidth = -1; |
| 65 |
|
|
| 66 |
0 |
if (alignment == null || (aWidth = alignment.getWidth()) < 0) |
| 67 |
|
{ |
| 68 |
0 |
return; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
0 |
alignViewport.setSecondaryStructureSources(); |
| 72 |
0 |
eraseSSConsensus(aWidth); |
| 73 |
0 |
computeSSConsensus(alignment); |
| 74 |
0 |
updateResultAnnotation(true); |
| 75 |
|
|
| 76 |
0 |
if (ap != null) |
| 77 |
|
{ |
| 78 |
0 |
ap.adjustAnnotationHeight(); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@param |
| 86 |
|
|
| 87 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 88 |
0 |
protected void eraseSSConsensus(int aWidth)... |
| 89 |
|
{ |
| 90 |
0 |
List<AlignmentAnnotation> ssConsensuses = getSSConsensusAnnotation(); |
| 91 |
0 |
for (AlignmentAnnotation ssConsensus : ssConsensuses) |
| 92 |
|
{ |
| 93 |
0 |
if (ssConsensus != null) |
| 94 |
|
{ |
| 95 |
0 |
ssConsensus.annotations = new Annotation[aWidth]; |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
@param |
| 102 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 103 |
0 |
protected void computeSSConsensus(AlignmentI alignment)... |
| 104 |
|
{ |
| 105 |
|
|
| 106 |
0 |
SequenceI[] aseqs = getSequences(); |
| 107 |
0 |
int width = alignment.getWidth(); |
| 108 |
0 |
Map<String, ProfilesI> hSSConsensusProfileMap = new HashMap<String, ProfilesI>(); |
| 109 |
0 |
List<String> ssSources = getSecondaryStructureSources(); |
| 110 |
0 |
for (String ssSource : ssSources) |
| 111 |
|
{ |
| 112 |
0 |
ProfilesI hSSConsensus = AAFrequency.calculateSS(aseqs, width, 0, |
| 113 |
|
width, true, ssSource, null); |
| 114 |
0 |
hSSConsensusProfileMap.put(ssSource, hSSConsensus); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
0 |
alignViewport.setSequenceSSConsensusHash(hSSConsensusProfileMap); |
| 118 |
0 |
setColourSchemeConsensus(hSSConsensusProfileMap); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@return |
| 123 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 124 |
0 |
protected SequenceI[] getSequences()... |
| 125 |
|
{ |
| 126 |
0 |
return alignViewport.getAlignment().getSequencesArray(); |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
@param |
| 131 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 132 |
0 |
protected void setColourSchemeConsensus(... |
| 133 |
|
Map<String, ProfilesI> ssConsensusProfileMap) |
| 134 |
|
{ |
| 135 |
0 |
ResidueShaderI cs = alignViewport.getResidueShading(); |
| 136 |
0 |
if (cs != null) |
| 137 |
|
{ |
| 138 |
0 |
cs.setSSConsensusProfileMap(ssConsensusProfileMap); |
| 139 |
|
} |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
@return |
| 146 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 147 |
0 |
protected List<AlignmentAnnotation> getSSConsensusAnnotation()... |
| 148 |
|
{ |
| 149 |
0 |
return alignViewport |
| 150 |
|
.getAlignmentSecondaryStructureConsensusAnnotation(); |
| 151 |
|
} |
| 152 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 153 |
0 |
protected List<String> getSecondaryStructureSources()... |
| 154 |
|
{ |
| 155 |
0 |
return alignViewport.getSecondaryStructureSources(); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
@return |
| 162 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 163 |
0 |
protected AlignmentAnnotation getGapAnnotation()... |
| 164 |
|
{ |
| 165 |
0 |
return alignViewport.getAlignmentGapAnnotation(); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 172 |
0 |
@Override... |
| 173 |
|
public void updateAnnotation() |
| 174 |
|
{ |
| 175 |
0 |
updateResultAnnotation(false); |
| 176 |
|
} |
| 177 |
|
|
| |
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 15 |
Complexity Density: 0.62 |
|
| 178 |
0 |
public void updateResultAnnotation(boolean immediate)... |
| 179 |
|
{ |
| 180 |
0 |
List<AlignmentAnnotation> ssConsensuses = getSSConsensusAnnotation(); |
| 181 |
0 |
Map<String, ProfilesI> ssConsensusProfileMap = getViewportSSConsensus(); |
| 182 |
|
|
| 183 |
|
|
| 184 |
0 |
if (ssConsensuses==null || ssConsensusProfileMap==null) |
| 185 |
|
{ |
| 186 |
0 |
return; |
| 187 |
|
} |
| 188 |
0 |
boolean singleProvider = false; |
| 189 |
|
|
| 190 |
0 |
if(ssConsensusProfileMap.keySet() != null && ssConsensusProfileMap.keySet().size() == 2) |
| 191 |
|
{ |
| 192 |
0 |
singleProvider = true; |
| 193 |
|
} |
| 194 |
|
|
| 195 |
0 |
for (AlignmentAnnotation ssConsensus : ssConsensuses) |
| 196 |
|
{ |
| 197 |
0 |
ProfilesI ssConsensusProfile = null; |
| 198 |
0 |
for (String source : ssConsensusProfileMap.keySet()) |
| 199 |
|
{ |
| 200 |
0 |
if (ssConsensus.description.startsWith(source)) |
| 201 |
|
{ |
| 202 |
0 |
ssConsensusProfile = ssConsensusProfileMap.get(source); |
| 203 |
0 |
ssConsensus.visible = source.equals(Constants.SS_ALL_PROVIDERS) && singleProvider ? false : true; |
| 204 |
|
|
| 205 |
0 |
break; |
| 206 |
|
} |
| 207 |
|
} |
| 208 |
0 |
if (ssConsensusProfile == null) |
| 209 |
|
{ |
| 210 |
0 |
continue; |
| 211 |
|
} |
| 212 |
0 |
if (immediate || !calcMan.isWorking(this) && ssConsensus != null |
| 213 |
|
&& ssConsensusProfile != null) |
| 214 |
|
{ |
| 215 |
0 |
deriveSSConsensus(ssConsensus, ssConsensusProfile); |
| 216 |
|
|
| 217 |
0 |
if (ssConsensusProfile.get(1) != null) |
| 218 |
|
{ |
| 219 |
0 |
ssConsensus.setNoOfSequencesIncluded( |
| 220 |
|
ssConsensusProfile.get(1).getSeqWithSSCount()); |
| 221 |
|
} |
| 222 |
0 |
ssConsensus.setNoOfTracksIncluded(ssConsensusProfile.getCount()); |
| 223 |
0 |
ssConsensus.hasData=ssConsensusProfile.getCount()>0; |
| 224 |
0 |
if (!ssConsensus.hasData) { |
| 225 |
0 |
ssConsensus.visible = false; |
| 226 |
|
} |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
} |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
@param |
| 238 |
|
|
| 239 |
|
@param |
| 240 |
|
|
| 241 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 242 |
0 |
protected void deriveSSConsensus(AlignmentAnnotation ssConsensus,... |
| 243 |
|
ProfilesI hSSConsensus) |
| 244 |
|
{ |
| 245 |
|
|
| 246 |
0 |
long nseq = getSequences().length; |
| 247 |
0 |
AAFrequency.completeSSConsensus(ssConsensus, hSSConsensus, |
| 248 |
|
hSSConsensus.getStartColumn(), hSSConsensus.getEndColumn() + 1, |
| 249 |
|
alignViewport.isIgnoreGapsConsensus(), |
| 250 |
|
alignViewport.isShowSequenceLogo(), nseq); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
@return |
| 257 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 258 |
0 |
protected Map<String, ProfilesI> getViewportSSConsensus()... |
| 259 |
|
{ |
| 260 |
|
|
| 261 |
0 |
return alignViewport.getSequenceSSConsensusHash(); |
| 262 |
|
} |
| 263 |
|
} |