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