| 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.StructureFrequency; |
| 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.SequenceI; |
| 30 |
|
|
| 31 |
|
import java.util.Hashtable; |
| 32 |
|
|
| |
|
| 60% |
Uncovered Elements: 30 (75) |
Complexity: 25 |
Complexity Density: 0.51 |
|
| 33 |
|
public class StrucConsensusThread extends AlignCalcWorker |
| 34 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
4 |
public StrucConsensusThread(AlignViewportI alignViewport,... |
| 36 |
|
AlignmentViewPanel alignPanel) |
| 37 |
|
{ |
| 38 |
4 |
super(alignViewport, alignPanel); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
AlignmentAnnotation strucConsensus; |
| 42 |
|
|
| 43 |
|
Hashtable[] hStrucConsensus; |
| 44 |
|
|
| 45 |
|
private long nseq = -1; |
| 46 |
|
|
| |
|
| 58.5% |
Uncovered Elements: 27 (65) |
Complexity: 18 |
Complexity Density: 0.4 |
|
| 47 |
8 |
@Override... |
| 48 |
|
public void run() |
| 49 |
|
{ |
| 50 |
8 |
try |
| 51 |
|
{ |
| 52 |
8 |
if (calcMan.isPending(this)) |
| 53 |
|
{ |
| 54 |
0 |
return; |
| 55 |
|
} |
| 56 |
8 |
calcMan.notifyStart(this); |
| 57 |
8 |
while (!calcMan.notifyWorking(this)) |
| 58 |
|
{ |
| 59 |
0 |
try |
| 60 |
|
{ |
| 61 |
0 |
if (ap != null) |
| 62 |
|
{ |
| 63 |
|
|
| 64 |
|
} |
| 65 |
|
|
| 66 |
0 |
Thread.sleep(200); |
| 67 |
|
} catch (Exception ex) |
| 68 |
|
{ |
| 69 |
0 |
ex.printStackTrace(); |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
8 |
if (alignViewport.isClosed()) |
| 73 |
|
{ |
| 74 |
0 |
abortAndDestroy(); |
| 75 |
0 |
return; |
| 76 |
|
} |
| 77 |
8 |
AlignmentI alignment = alignViewport.getAlignment(); |
| 78 |
|
|
| 79 |
8 |
int aWidth = -1; |
| 80 |
|
|
| 81 |
? |
if (alignment == null || (aWidth = alignment.getWidth()) < 0) |
| 82 |
|
{ |
| 83 |
0 |
calcMan.workerComplete(this); |
| 84 |
0 |
return; |
| 85 |
|
} |
| 86 |
8 |
strucConsensus = alignViewport.getAlignmentStrucConsensusAnnotation(); |
| 87 |
8 |
hStrucConsensus = alignViewport.getRnaStructureConsensusHash(); |
| 88 |
8 |
strucConsensus.annotations = null; |
| 89 |
8 |
strucConsensus.annotations = new Annotation[aWidth]; |
| 90 |
|
|
| 91 |
8 |
hStrucConsensus = new Hashtable[aWidth]; |
| 92 |
|
|
| 93 |
8 |
AlignmentAnnotation[] aa = alignViewport.getAlignment() |
| 94 |
|
.getAlignmentAnnotation(); |
| 95 |
8 |
AlignmentAnnotation rnaStruc = null; |
| 96 |
|
|
| 97 |
8 |
if (aa != null) |
| 98 |
|
{ |
| 99 |
8 |
for (int i = 0; i < aa.length; i++) |
| 100 |
|
{ |
| 101 |
8 |
if (aa[i].isForDisplay() && aa[i].isRNA() && aa[i].isValidStruc()) |
| 102 |
|
{ |
| 103 |
8 |
rnaStruc = aa[i]; |
| 104 |
8 |
break; |
| 105 |
|
} |
| 106 |
|
} |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
8 |
if (rnaStruc == null || !rnaStruc.isValidStruc()) |
| 111 |
|
{ |
| 112 |
0 |
calcMan.workerComplete(this); |
| 113 |
0 |
return; |
| 114 |
|
} |
| 115 |
|
|
| 116 |
8 |
try |
| 117 |
|
{ |
| 118 |
8 |
final SequenceI[] arr = alignment.getSequencesArray(); |
| 119 |
8 |
nseq = arr.length; |
| 120 |
8 |
jalview.analysis.StructureFrequency.calculate(arr, 0, |
| 121 |
|
alignment.getWidth(), hStrucConsensus, true, rnaStruc); |
| 122 |
|
} catch (ArrayIndexOutOfBoundsException x) |
| 123 |
|
{ |
| 124 |
0 |
calcMan.workerComplete(this); |
| 125 |
0 |
return; |
| 126 |
|
} |
| 127 |
8 |
alignViewport.setRnaStructureConsensusHash(hStrucConsensus); |
| 128 |
|
|
| 129 |
8 |
updateResultAnnotation(true); |
| 130 |
|
} catch (OutOfMemoryError error) |
| 131 |
|
{ |
| 132 |
0 |
calcMan.disableWorker(this); |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
0 |
ap.raiseOOMWarning("calculating RNA structure consensus", error); |
| 137 |
|
} finally |
| 138 |
|
{ |
| 139 |
8 |
calcMan.workerComplete(this); |
| 140 |
8 |
if (ap != null) |
| 141 |
|
{ |
| 142 |
8 |
ap.paintAlignment(true, true); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0 |
@Override... |
| 153 |
|
public void updateAnnotation() |
| 154 |
|
{ |
| 155 |
0 |
updateResultAnnotation(false); |
| 156 |
|
} |
| 157 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 5 |
Complexity Density: 2.5 |
|
| 158 |
8 |
public void updateResultAnnotation(boolean immediate)... |
| 159 |
|
{ |
| 160 |
8 |
if (immediate || !calcMan.isWorking(this) && strucConsensus != null |
| 161 |
|
&& hStrucConsensus != null) |
| 162 |
|
{ |
| 163 |
8 |
StructureFrequency.completeConsensus(strucConsensus, hStrucConsensus, |
| 164 |
|
0, hStrucConsensus.length, |
| 165 |
|
alignViewport.isIgnoreGapsConsensus(), |
| 166 |
|
alignViewport.isShowSequenceLogo(), nseq); |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
} |