| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.jws2; |
| 22 |
|
|
| 23 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 24 |
|
import jalview.datamodel.Annotation; |
| 25 |
|
import jalview.datamodel.SequenceI; |
| 26 |
|
import jalview.gui.AlignFrame; |
| 27 |
|
import jalview.util.MessageManager; |
| 28 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
| 29 |
|
import jalview.ws.params.WsParamSetI; |
| 30 |
|
|
| 31 |
|
import java.util.Iterator; |
| 32 |
|
import java.util.List; |
| 33 |
|
|
| 34 |
|
import compbio.data.msa.SequenceAnnotation; |
| 35 |
|
import compbio.data.sequence.Score; |
| 36 |
|
import compbio.data.sequence.ScoreManager; |
| 37 |
|
import compbio.metadata.Argument; |
| 38 |
|
import compbio.metadata.ChunkHolder; |
| 39 |
|
import compbio.metadata.JobStatus; |
| 40 |
|
import compbio.metadata.JobSubmissionException; |
| 41 |
|
import compbio.metadata.ResultNotAvailableException; |
| 42 |
|
import compbio.metadata.WrongParameterException; |
| 43 |
|
|
| |
|
| 0% |
Uncovered Elements: 101 (101) |
Complexity: 28 |
Complexity Density: 0.43 |
|
| 44 |
|
public abstract class JabawsCalcWorker extends AbstractJabaCalcWorker |
| 45 |
|
{ |
| 46 |
|
|
| 47 |
|
@SuppressWarnings("unchecked") |
| 48 |
|
protected SequenceAnnotation aaservice; |
| 49 |
|
|
| 50 |
|
protected ScoreManager scoremanager; |
| 51 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 52 |
0 |
public JabawsCalcWorker(Jws2Instance service, AlignFrame alignFrame,... |
| 53 |
|
WsParamSetI preset, List<Argument> paramset) |
| 54 |
|
{ |
| 55 |
0 |
super(service, alignFrame, preset, paramset); |
| 56 |
0 |
aaservice = (SequenceAnnotation) service.service; |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
0 |
@Override... |
| 60 |
|
ChunkHolder pullExecStatistics(String rslt, long rpos) |
| 61 |
|
{ |
| 62 |
0 |
return aaservice.pullExecStatistics(rslt, rpos); |
| 63 |
|
} |
| 64 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 65 |
0 |
@Override... |
| 66 |
|
boolean collectAnnotationResultsFor(String rslt) |
| 67 |
|
throws ResultNotAvailableException |
| 68 |
|
{ |
| 69 |
0 |
scoremanager = aaservice.getAnnotation(rslt); |
| 70 |
0 |
if (scoremanager != null) |
| 71 |
|
{ |
| 72 |
0 |
return true; |
| 73 |
|
} |
| 74 |
0 |
return false; |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
0 |
@Override... |
| 78 |
|
boolean cancelJob(String rslt) throws Exception |
| 79 |
|
{ |
| 80 |
0 |
return aaservice.cancelJob(rslt); |
| 81 |
|
} |
| 82 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 83 |
0 |
@Override... |
| 84 |
|
protected JobStatus getJobStatus(String rslt) throws Exception |
| 85 |
|
{ |
| 86 |
0 |
return aaservice.getJobStatus(rslt); |
| 87 |
|
} |
| 88 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 89 |
0 |
@Override... |
| 90 |
|
boolean hasService() |
| 91 |
|
{ |
| 92 |
0 |
return aaservice != null; |
| 93 |
|
} |
| 94 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
0 |
@Override... |
| 96 |
|
protected boolean isInteractiveUpdate() |
| 97 |
|
{ |
| 98 |
0 |
return this instanceof AAConClient; |
| 99 |
|
} |
| 100 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 101 |
0 |
@Override... |
| 102 |
|
protected String submitToService( |
| 103 |
|
List<compbio.data.sequence.FastaSequence> seqs) |
| 104 |
|
throws JobSubmissionException |
| 105 |
|
{ |
| 106 |
0 |
String rslt; |
| 107 |
0 |
if (preset == null && arguments == null) |
| 108 |
|
{ |
| 109 |
0 |
rslt = aaservice.analize(seqs); |
| 110 |
|
} |
| 111 |
|
else |
| 112 |
|
{ |
| 113 |
0 |
try |
| 114 |
|
{ |
| 115 |
0 |
rslt = aaservice.customAnalize(seqs, getJabaArguments()); |
| 116 |
|
} catch (WrongParameterException x) |
| 117 |
|
{ |
| 118 |
0 |
throw new JobSubmissionException(MessageManager.getString( |
| 119 |
|
"exception.jobsubmission_invalid_params_set"), x); |
| 120 |
|
|
| 121 |
|
} |
| 122 |
|
} |
| 123 |
0 |
return rslt; |
| 124 |
|
} |
| 125 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 126 |
0 |
protected void createAnnotationRowsForScores(... |
| 127 |
|
List<AlignmentAnnotation> ourAnnot, String calcId, int alWidth, |
| 128 |
|
Score scr) |
| 129 |
|
{ |
| 130 |
|
|
| 131 |
0 |
AlignmentAnnotation annotation = alignViewport.getAlignment() |
| 132 |
|
.findOrCreateAnnotation(scr.getMethod(), calcId, true, null, |
| 133 |
|
null); |
| 134 |
0 |
if (alWidth == gapMap.length) |
| 135 |
|
{ |
| 136 |
0 |
constructAnnotationFromScore(annotation, 0, alWidth, scr); |
| 137 |
0 |
ourAnnot.add(annotation); |
| 138 |
|
} |
| 139 |
|
} |
| 140 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 141 |
0 |
protected AlignmentAnnotation createAnnotationRowsForScores(... |
| 142 |
|
List<AlignmentAnnotation> ourAnnot, String typeName, |
| 143 |
|
String calcId, SequenceI dseq, int base, Score scr) |
| 144 |
|
{ |
| 145 |
0 |
jalview.bin.Console.outPrintln("Creating annotation on dseq:" |
| 146 |
|
+ dseq.getStart() + " base is " + base + " and length=" |
| 147 |
|
+ dseq.getLength() + " == " + scr.getScores().size()); |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
0 |
AlignmentAnnotation annotation = alignViewport.getAlignment() |
| 153 |
|
.findOrCreateAnnotation(typeName, calcId, false, dseq, null); |
| 154 |
0 |
constructAnnotationFromScore(annotation, 0, dseq.getLength(), scr); |
| 155 |
0 |
annotation.createSequenceMapping(dseq, base, false); |
| 156 |
0 |
annotation.adjustForAlignment(); |
| 157 |
0 |
dseq.addAlignmentAnnotation(annotation); |
| 158 |
0 |
ourAnnot.add(annotation); |
| 159 |
0 |
return annotation; |
| 160 |
|
} |
| 161 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 162 |
0 |
protected void replaceAnnotationOnAlignmentWith(... |
| 163 |
|
AlignmentAnnotation newAnnot, String typeName, String calcId, |
| 164 |
|
SequenceI aSeq) |
| 165 |
|
{ |
| 166 |
0 |
SequenceI dsseq = aSeq.getDatasetSequence(); |
| 167 |
0 |
while (dsseq.getDatasetSequence() != null) |
| 168 |
|
{ |
| 169 |
0 |
dsseq = dsseq.getDatasetSequence(); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
0 |
List<AlignmentAnnotation> dsan = dsseq.getAlignmentAnnotations(calcId, |
| 173 |
|
typeName); |
| 174 |
0 |
if (dsan != null && dsan.size() > 0) |
| 175 |
|
{ |
| 176 |
0 |
for (AlignmentAnnotation dssan : dsan) |
| 177 |
|
{ |
| 178 |
0 |
dsseq.removeAlignmentAnnotation(dssan); |
| 179 |
|
} |
| 180 |
|
} |
| 181 |
0 |
AlignmentAnnotation dssan = new AlignmentAnnotation(newAnnot); |
| 182 |
0 |
dsseq.addAlignmentAnnotation(dssan); |
| 183 |
0 |
dssan.adjustForAlignment(); |
| 184 |
|
} |
| 185 |
|
|
| |
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 9 |
Complexity Density: 0.36 |
|
| 186 |
0 |
private void constructAnnotationFromScore(AlignmentAnnotation annotation,... |
| 187 |
|
int base, int alWidth, Score scr) |
| 188 |
|
{ |
| 189 |
0 |
Annotation[] elm = new Annotation[alWidth]; |
| 190 |
0 |
Iterator<Float> vals = scr.getScores().iterator(); |
| 191 |
0 |
float m = 0f, x = 0f; |
| 192 |
0 |
for (int i = 0; vals.hasNext(); i++) |
| 193 |
|
{ |
| 194 |
0 |
float val = vals.next().floatValue(); |
| 195 |
0 |
if (i == 0) |
| 196 |
|
{ |
| 197 |
0 |
m = val; |
| 198 |
0 |
x = val; |
| 199 |
|
} |
| 200 |
|
else |
| 201 |
|
{ |
| 202 |
0 |
if (m > val) |
| 203 |
|
{ |
| 204 |
0 |
m = val; |
| 205 |
|
} |
| 206 |
0 |
; |
| 207 |
0 |
if (x < val) |
| 208 |
|
{ |
| 209 |
0 |
x = val; |
| 210 |
|
} |
| 211 |
|
} |
| 212 |
|
|
| 213 |
0 |
if (gapMap != null && gapMap.length > 0) |
| 214 |
|
{ |
| 215 |
0 |
while (!gapMap[i]) |
| 216 |
|
{ |
| 217 |
0 |
elm[i++] = new Annotation("", "", ' ', Float.NaN); |
| 218 |
|
} |
| 219 |
|
} |
| 220 |
0 |
elm[i] = new Annotation("", "" + val, ' ', val); |
| 221 |
|
} |
| 222 |
|
|
| 223 |
0 |
annotation.annotations = elm; |
| 224 |
0 |
annotation.belowAlignment = true; |
| 225 |
0 |
if (x < 0) |
| 226 |
|
{ |
| 227 |
0 |
x = 0; |
| 228 |
|
} |
| 229 |
0 |
x += (x - m) * 0.1; |
| 230 |
0 |
annotation.graphMax = x; |
| 231 |
0 |
annotation.graphMin = m; |
| 232 |
0 |
annotation.validateRangeAndDisplay(); |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
} |