| 1 |
|
package jalview.ws.jws2.jabaws2; |
| 2 |
|
|
| 3 |
|
import jalview.api.FeatureColourI; |
| 4 |
|
import jalview.datamodel.Alignment; |
| 5 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 6 |
|
import jalview.datamodel.AlignmentI; |
| 7 |
|
import jalview.datamodel.Annotation; |
| 8 |
|
import jalview.datamodel.SequenceI; |
| 9 |
|
import jalview.datamodel.features.FeatureMatcherSetI; |
| 10 |
|
import jalview.util.MessageManager; |
| 11 |
|
import jalview.ws.api.JobId; |
| 12 |
|
import jalview.ws.api.SequenceAnnotationServiceI; |
| 13 |
|
import jalview.ws.jws2.JabaParamStore; |
| 14 |
|
import jalview.ws.jws2.JabaPreset; |
| 15 |
|
import jalview.ws.params.ArgumentI; |
| 16 |
|
import jalview.ws.params.WsParamSetI; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.Iterator; |
| 20 |
|
import java.util.List; |
| 21 |
|
import java.util.Map; |
| 22 |
|
|
| 23 |
|
import compbio.data.msa.SequenceAnnotation; |
| 24 |
|
import compbio.data.sequence.FastaSequence; |
| 25 |
|
import compbio.data.sequence.Score; |
| 26 |
|
import compbio.data.sequence.ScoreManager; |
| 27 |
|
import compbio.metadata.JobSubmissionException; |
| 28 |
|
import compbio.metadata.WrongParameterException; |
| 29 |
|
|
| |
|
| 0% |
Uncovered Elements: 103 (103) |
Complexity: 29 |
Complexity Density: 0.45 |
|
| 30 |
|
public abstract class JabawsAnnotationInstance |
| 31 |
|
extends JabawsServiceInstance<SequenceAnnotation> |
| 32 |
|
implements SequenceAnnotationServiceI |
| 33 |
|
{ |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
protected ScoreManager scoremanager = null; |
| 39 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
0 |
public JabawsAnnotationInstance(Jws2Instance handle)... |
| 41 |
|
{ |
| 42 |
0 |
super(handle); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
@return |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 53 |
0 |
public String getCalcId()... |
| 54 |
|
{ |
| 55 |
0 |
return our.getAlignAnalysisUI() == null ? null |
| 56 |
|
: our.getAlignAnalysisUI().getCalcId(); |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 59 |
0 |
@Override... |
| 60 |
|
public JobId submitToService(List<SequenceI> seqs, WsParamSetI preset, |
| 61 |
|
List<ArgumentI> arguments) throws Throwable |
| 62 |
|
{ |
| 63 |
0 |
String rslt = null; |
| 64 |
0 |
scoremanager = null; |
| 65 |
0 |
List<FastaSequence> jabaseqs = new ArrayList(seqs.size()); |
| 66 |
0 |
for (SequenceI seq : seqs) |
| 67 |
|
{ |
| 68 |
0 |
jabaseqs.add( |
| 69 |
|
new FastaSequence(seq.getName(), seq.getSequenceAsString())); |
| 70 |
|
} |
| 71 |
0 |
if (preset == null && arguments == null) |
| 72 |
|
{ |
| 73 |
0 |
rslt = service.analize(jabaseqs); |
| 74 |
|
} |
| 75 |
0 |
if (preset != null) |
| 76 |
|
{ |
| 77 |
0 |
if (preset instanceof JabaPreset) |
| 78 |
|
{ |
| 79 |
|
|
| 80 |
|
|
| 81 |
0 |
rslt = service.presetAnalize(jabaseqs, |
| 82 |
|
((JabaPreset) preset).getJabaPreset()); |
| 83 |
|
} |
| 84 |
|
else |
| 85 |
|
{ |
| 86 |
0 |
rslt = service.customAnalize(jabaseqs, |
| 87 |
|
JabaParamStore.getJabafromJwsArgs(preset.getArguments())); |
| 88 |
|
} |
| 89 |
|
} |
| 90 |
0 |
else if (arguments != null && arguments.size() > 0) |
| 91 |
|
{ |
| 92 |
0 |
try |
| 93 |
|
{ |
| 94 |
0 |
rslt = service.customAnalize(jabaseqs, |
| 95 |
|
JabaParamStore.getJabafromJwsArgs(arguments)); |
| 96 |
|
} catch (WrongParameterException x) |
| 97 |
|
{ |
| 98 |
0 |
throw new JobSubmissionException(MessageManager.getString( |
| 99 |
|
"exception.jobsubmission_invalid_params_set"), x); |
| 100 |
|
|
| 101 |
|
} |
| 102 |
|
} |
| 103 |
|
|
| 104 |
0 |
if (rslt == null) |
| 105 |
|
{ |
| 106 |
0 |
return null; |
| 107 |
|
} |
| 108 |
0 |
return new JobId(our.getServiceType(), our.getName(), rslt); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 112 |
0 |
@Override... |
| 113 |
|
public |
| 114 |
|
List<AlignmentAnnotation> getAnnotationResult(JobId job, |
| 115 |
|
List<SequenceI> seqs, Map<String, FeatureColourI> featureColours, |
| 116 |
|
Map<String, FeatureMatcherSetI> featureFilters) throws Throwable |
| 117 |
|
{ |
| 118 |
0 |
if (scoremanager == null) |
| 119 |
|
{ |
| 120 |
|
|
| 121 |
0 |
scoremanager = service.getAnnotation(job.getJobId()); |
| 122 |
|
} |
| 123 |
0 |
if (scoremanager == null) |
| 124 |
|
{ |
| 125 |
0 |
return List.of(); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
0 |
AlignmentI newal = new Alignment(seqs.toArray(new SequenceI[0])); |
| 131 |
0 |
List<AlignmentAnnotation> ourAnnot = annotationFromScoreManager(newal, |
| 132 |
|
featureColours, featureFilters); |
| 133 |
0 |
return ourAnnot; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
@param |
| 140 |
|
|
| 141 |
|
@param |
| 142 |
|
|
| 143 |
|
@param |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
@return |
| 147 |
|
|
| 148 |
|
abstract List<AlignmentAnnotation> annotationFromScoreManager( |
| 149 |
|
AlignmentI seqs, Map<String, FeatureColourI> featureColours, |
| 150 |
|
Map<String, FeatureMatcherSetI> featureFilters); |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
@param |
| 157 |
|
@param |
| 158 |
|
@param |
| 159 |
|
@param |
| 160 |
|
@param |
| 161 |
|
@param |
| 162 |
|
|
| 163 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 164 |
0 |
protected void createAnnotationRowsForScores(AlignmentI al_result,... |
| 165 |
|
boolean[] gapMap, List<AlignmentAnnotation> ourAnnot, |
| 166 |
|
String calcId, |
| 167 |
|
int alWidth, Score scr) |
| 168 |
|
{ |
| 169 |
|
|
| 170 |
0 |
AlignmentAnnotation annotation = al_result |
| 171 |
|
.findOrCreateAnnotation(scr.getMethod(), calcId, true, null, |
| 172 |
|
null); |
| 173 |
0 |
if (gapMap == null || alWidth == gapMap.length) |
| 174 |
|
{ |
| 175 |
0 |
constructAnnotationFromScore(gapMap, annotation, 0, |
| 176 |
|
alWidth, scr); |
| 177 |
0 |
ourAnnot.add(annotation); |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
@param |
| 185 |
|
@param |
| 186 |
|
@param |
| 187 |
|
@param |
| 188 |
|
@param |
| 189 |
|
@param |
| 190 |
|
@param |
| 191 |
|
@param |
| 192 |
|
@return |
| 193 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 194 |
0 |
protected AlignmentAnnotation createAnnotationRowsForScores(... |
| 195 |
|
AlignmentI alignment, boolean[] gapMap, |
| 196 |
|
List<AlignmentAnnotation> ourAnnot, String typeName, |
| 197 |
|
String calcId, SequenceI dseq, int base, Score scr) |
| 198 |
|
{ |
| 199 |
0 |
System.out.println("Creating annotation on dseq:" + dseq.getStart() |
| 200 |
|
+ " base is " + base + " and length=" + dseq.getLength() |
| 201 |
|
+ " == " + scr.getScores().size()); |
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
0 |
AlignmentAnnotation annotation = alignment |
| 207 |
|
.findOrCreateAnnotation(typeName, calcId, false, dseq, null); |
| 208 |
0 |
constructAnnotationFromScore(gapMap, annotation, 0, dseq.getLength(), |
| 209 |
|
scr); |
| 210 |
0 |
annotation.createSequenceMapping(dseq, base, false); |
| 211 |
0 |
annotation.adjustForAlignment(); |
| 212 |
0 |
dseq.addAlignmentAnnotation(annotation); |
| 213 |
0 |
ourAnnot.add(annotation); |
| 214 |
0 |
return annotation; |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
@param |
| 221 |
|
@param |
| 222 |
|
@param |
| 223 |
|
@param |
| 224 |
|
@param |
| 225 |
|
|
| 226 |
|
|
| |
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 10 |
Complexity Density: 0.4 |
|
| 227 |
0 |
protected void constructAnnotationFromScore(boolean[] gapMap,... |
| 228 |
|
AlignmentAnnotation annotation, |
| 229 |
|
int base, int alWidth, Score scr) |
| 230 |
|
{ |
| 231 |
0 |
Annotation[] elm = new Annotation[alWidth]; |
| 232 |
0 |
Iterator<Float> vals = scr.getScores().iterator(); |
| 233 |
0 |
float m = 0f, x = 0f; |
| 234 |
0 |
for (int i = 0; vals.hasNext(); i++) |
| 235 |
|
{ |
| 236 |
0 |
float val = vals.next().floatValue(); |
| 237 |
0 |
if (i == 0) |
| 238 |
|
{ |
| 239 |
0 |
m = val; |
| 240 |
0 |
x = val; |
| 241 |
|
} |
| 242 |
|
else |
| 243 |
|
{ |
| 244 |
0 |
if (m > val) |
| 245 |
|
{ |
| 246 |
0 |
m = val; |
| 247 |
|
} |
| 248 |
0 |
; |
| 249 |
0 |
if (x < val) |
| 250 |
|
{ |
| 251 |
0 |
x = val; |
| 252 |
|
} |
| 253 |
|
} |
| 254 |
|
|
| 255 |
0 |
if (gapMap != null && gapMap.length > 0) |
| 256 |
|
{ |
| 257 |
|
|
| 258 |
|
|
| 259 |
0 |
while (i < gapMap.length && !gapMap[i]) |
| 260 |
|
{ |
| 261 |
0 |
elm[i++] = new Annotation("", "", ' ', Float.NaN); |
| 262 |
|
} |
| 263 |
|
} |
| 264 |
0 |
elm[i] = new Annotation("", "" + val, ' ', val); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
0 |
annotation.annotations = elm; |
| 268 |
0 |
annotation.belowAlignment = true; |
| 269 |
0 |
if (x < 0) |
| 270 |
|
{ |
| 271 |
0 |
x = 0; |
| 272 |
|
} |
| 273 |
0 |
x += (x - m) * 0.1; |
| 274 |
0 |
annotation.graphMax = x; |
| 275 |
0 |
annotation.graphMin = m; |
| 276 |
0 |
annotation.validateRangeAndDisplay(); |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
} |