| 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.jabaws2; |
| 22 |
|
|
| 23 |
|
import jalview.analysis.AlignmentAnnotationUtils; |
| 24 |
|
import jalview.api.FeatureColourI; |
| 25 |
|
import jalview.bin.Cache; |
| 26 |
|
import jalview.bin.Console; |
| 27 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 28 |
|
import jalview.datamodel.AlignmentI; |
| 29 |
|
import jalview.datamodel.GraphLine; |
| 30 |
|
import jalview.datamodel.SequenceFeature; |
| 31 |
|
import jalview.datamodel.SequenceI; |
| 32 |
|
import jalview.datamodel.features.FeatureMatcherSetI; |
| 33 |
|
import jalview.schemes.FeatureColour; |
| 34 |
|
import jalview.util.ColorUtils; |
| 35 |
|
|
| 36 |
|
import java.awt.Color; |
| 37 |
|
import java.util.ArrayList; |
| 38 |
|
import java.util.HashMap; |
| 39 |
|
import java.util.Hashtable; |
| 40 |
|
import java.util.Iterator; |
| 41 |
|
import java.util.List; |
| 42 |
|
import java.util.Map; |
| 43 |
|
|
| 44 |
|
import compbio.data.sequence.Range; |
| 45 |
|
import compbio.data.sequence.Score; |
| 46 |
|
import compbio.data.sequence.ScoreManager.ScoreHolder; |
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 169 (169) |
Complexity: 30 |
Complexity Density: 0.24 |
|
| 48 |
|
public class AADisorderClient extends JabawsAnnotationInstance |
| 49 |
|
{ |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0 |
public static String getServiceActionText()... |
| 52 |
|
{ |
| 53 |
0 |
return "Submitting amino acid sequences for disorder prediction."; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
0 |
public AADisorderClient(Jws2Instance handle)... |
| 60 |
|
{ |
| 61 |
0 |
super(handle); |
| 62 |
|
|
| 63 |
|
} |
| 64 |
|
|
| |
|
| 0% |
Uncovered Elements: 119 (119) |
Complexity: 27 |
Complexity Density: 0.34 |
|
| 65 |
0 |
@Override... |
| 66 |
|
List<AlignmentAnnotation> annotationFromScoreManager(AlignmentI seqs, |
| 67 |
|
Map<String, FeatureColourI> featureColours, |
| 68 |
|
Map<String, FeatureMatcherSetI> featureFilters) |
| 69 |
|
{ |
| 70 |
|
|
| 71 |
0 |
Map<String, String[]> featureTypeMap = featureMap.get(our.getName()); |
| 72 |
0 |
Map<String, Map<String, Object>> annotTypeMap = annotMap |
| 73 |
|
.get(our.getName()); |
| 74 |
0 |
boolean dispFeatures = false; |
| 75 |
0 |
Map<String, SequenceFeature> fc = new Hashtable<>(), |
| 76 |
|
fex = new Hashtable(); |
| 77 |
0 |
List<AlignmentAnnotation> ourAnnot = new ArrayList<>(); |
| 78 |
0 |
int graphGroup = 1, lastAnnot = 0; |
| 79 |
|
|
| 80 |
0 |
for (SequenceI seq : seqs.getSequences()) |
| 81 |
|
{ |
| 82 |
0 |
String seqId = seq.getName(); |
| 83 |
0 |
boolean sameGroup = false; |
| 84 |
0 |
SequenceI dseq, aseq; |
| 85 |
0 |
int base = seq.findPosition(0) - 1; |
| 86 |
0 |
aseq = seq; |
| 87 |
0 |
while ((dseq = seq).getDatasetSequence() != null) |
| 88 |
|
{ |
| 89 |
0 |
seq = seq.getDatasetSequence(); |
| 90 |
|
} |
| 91 |
0 |
ScoreHolder scores = null; |
| 92 |
0 |
try |
| 93 |
|
{ |
| 94 |
0 |
scores = scoremanager.getAnnotationForSequence(seqId); |
| 95 |
|
} catch (Exception q) |
| 96 |
|
{ |
| 97 |
0 |
Console.info("Couldn't recover disorder prediction for sequence " |
| 98 |
|
+ seq.getName() + "(Prediction name was " + seqId + ")" |
| 99 |
|
+ "\nSee http://issues.jalview.org/browse/JAL-1319 for one possible reason why disorder predictions might fail.", |
| 100 |
|
q); |
| 101 |
|
} |
| 102 |
0 |
float last = Float.NaN, val = Float.NaN; |
| 103 |
0 |
if (scores != null && scores.scores != null) |
| 104 |
|
{ |
| 105 |
0 |
for (Score scr : scores.scores) |
| 106 |
|
{ |
| 107 |
|
|
| 108 |
0 |
if (scr.getRanges() != null && scr.getRanges().size() > 0) |
| 109 |
|
{ |
| 110 |
0 |
Iterator<Float> vals = scr.getScores().iterator(); |
| 111 |
|
|
| 112 |
0 |
for (Range rn : scr.getRanges()) |
| 113 |
|
{ |
| 114 |
|
|
| 115 |
0 |
SequenceFeature sf; |
| 116 |
0 |
String[] type = featureTypeMap.get(scr.getMethod()); |
| 117 |
0 |
if (type == null) |
| 118 |
|
{ |
| 119 |
|
|
| 120 |
0 |
type = new String[] { |
| 121 |
|
typeName + " (" + scr.getMethod() + ")", |
| 122 |
|
our.getActionText() }; |
| 123 |
|
} |
| 124 |
0 |
if (vals.hasNext()) |
| 125 |
|
{ |
| 126 |
0 |
val = vals.next().floatValue(); |
| 127 |
0 |
sf = new SequenceFeature(type[0], type[1], base + rn.from, |
| 128 |
|
base + rn.to, val, methodName); |
| 129 |
|
} |
| 130 |
|
else |
| 131 |
|
{ |
| 132 |
0 |
sf = new SequenceFeature(type[0], type[1], base + rn.from, |
| 133 |
|
base + rn.to, methodName); |
| 134 |
|
} |
| 135 |
0 |
dseq.addSequenceFeature(sf); |
| 136 |
|
|
| 137 |
|
|
| 138 |
0 |
if (!Float.isNaN(last) && !Float.isNaN(val) && last != val) |
| 139 |
|
{ |
| 140 |
0 |
fc.put(sf.getType(), sf); |
| 141 |
|
} else |
| 142 |
|
{ |
| 143 |
0 |
fex.put(sf.getType(), sf); |
| 144 |
|
} |
| 145 |
0 |
last = val; |
| 146 |
0 |
dispFeatures = true; |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
|
else |
| 150 |
|
{ |
| 151 |
0 |
if (scr.getScores().size() == 0) |
| 152 |
|
{ |
| 153 |
0 |
continue; |
| 154 |
|
} |
| 155 |
0 |
String typename, calcName; |
| 156 |
0 |
AlignmentAnnotation annot = createAnnotationRowsForScores( |
| 157 |
|
seqs, null, ourAnnot, |
| 158 |
|
typename = our.getName() + " (" + scr.getMethod() + ")", |
| 159 |
|
calcName = our.getNameURI() + "/" + scr.getMethod(), |
| 160 |
|
aseq, base + 1, scr); |
| 161 |
0 |
annot.graph = AlignmentAnnotation.LINE_GRAPH; |
| 162 |
|
|
| 163 |
0 |
Map<String, Object> styleMap = (annotTypeMap == null) ? null |
| 164 |
|
: annotTypeMap.get(scr.getMethod()); |
| 165 |
|
|
| 166 |
0 |
annot.visible = (styleMap == null |
| 167 |
|
|| styleMap.get(INVISIBLE) == null); |
| 168 |
0 |
double[] thrsh = (styleMap == null) ? null |
| 169 |
|
: (double[]) styleMap.get(THRESHOLD); |
| 170 |
0 |
float[] range = (styleMap == null) ? null |
| 171 |
|
: (float[]) styleMap.get(RANGE); |
| 172 |
0 |
if (range != null) |
| 173 |
|
{ |
| 174 |
0 |
annot.graphMin = range[0]; |
| 175 |
0 |
annot.graphMax = range[1]; |
| 176 |
|
} |
| 177 |
0 |
if (styleMap == null || styleMap.get(DONTCOMBINE) == null) |
| 178 |
|
{ |
| 179 |
|
{ |
| 180 |
0 |
if (!sameGroup) |
| 181 |
|
{ |
| 182 |
0 |
graphGroup++; |
| 183 |
0 |
sameGroup = true; |
| 184 |
|
} |
| 185 |
|
|
| 186 |
0 |
annot.graphGroup = graphGroup; |
| 187 |
|
} |
| 188 |
|
} |
| 189 |
|
|
| 190 |
0 |
annot.description = "<html>" + our.getActionText() |
| 191 |
|
+ " - raw scores"; |
| 192 |
0 |
if (thrsh != null) |
| 193 |
|
{ |
| 194 |
0 |
String threshNote = (thrsh[0] > 0 ? "Above " : "Below ") |
| 195 |
|
+ thrsh[1] + " indicates disorder"; |
| 196 |
0 |
annot.threshold = new GraphLine((float) thrsh[1], threshNote, |
| 197 |
|
Color.red); |
| 198 |
0 |
annot.description += "<br/>" + threshNote; |
| 199 |
|
} |
| 200 |
0 |
annot.description += "</html>"; |
| 201 |
0 |
Color col = ColorUtils |
| 202 |
|
.createColourFromName(typeName + scr.getMethod()); |
| 203 |
0 |
for (int p = 0, ps = annot.annotations.length; p < ps; p++) |
| 204 |
|
{ |
| 205 |
0 |
if (annot.annotations[p] != null) |
| 206 |
|
{ |
| 207 |
0 |
annot.annotations[p].colour = col; |
| 208 |
|
} |
| 209 |
|
} |
| 210 |
0 |
annot._linecolour = col; |
| 211 |
|
|
| 212 |
0 |
AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith(annot, |
| 213 |
|
typename, calcName); |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
} |
| 217 |
0 |
if (lastAnnot + 1 == ourAnnot.size()) |
| 218 |
|
{ |
| 219 |
|
|
| 220 |
0 |
ourAnnot.get(lastAnnot).graphGroup = -1; |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
|
{ |
| 224 |
0 |
if (dispFeatures) |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
0 |
for (String ft : fex.keySet()) |
| 231 |
|
{ |
| 232 |
0 |
Color col = ColorUtils.createColourFromName(ft); |
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
0 |
FeatureColourI ggc; |
| 237 |
0 |
if (fc.get(ft) != null) |
| 238 |
|
{ |
| 239 |
0 |
ggc = new FeatureColour(col, Color.white, col, |
| 240 |
|
|
| 241 |
|
Color.white, Float.MIN_VALUE, Float.MAX_VALUE); |
| 242 |
0 |
ggc.setAutoScaled(true); |
| 243 |
|
} |
| 244 |
|
else |
| 245 |
|
{ |
| 246 |
0 |
ggc = new FeatureColour(col); |
| 247 |
|
} |
| 248 |
0 |
featureColours.put(ft, ggc); |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
} |
| 252 |
0 |
return ourAnnot; |
| 253 |
|
} |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
private static final String THRESHOLD = "THRESHOLD"; |
| 257 |
|
|
| 258 |
|
private static final String RANGE = "RANGE"; |
| 259 |
|
|
| 260 |
|
String typeName; |
| 261 |
|
|
| 262 |
|
String methodName; |
| 263 |
|
|
| 264 |
|
String groupName; |
| 265 |
|
|
| 266 |
|
private static Map<String, Map<String, String[]>> featureMap; |
| 267 |
|
|
| 268 |
|
private static Map<String, Map<String, Map<String, Object>>> annotMap; |
| 269 |
|
|
| 270 |
|
private static String DONTCOMBINE = "DONTCOMBINE"; |
| 271 |
|
|
| 272 |
|
private static String INVISIBLE = "INVISIBLE"; |
| |
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 1 |
Complexity Density: 0.02 |
|
| 273 |
0 |
static... |
| 274 |
|
{ |
| 275 |
|
|
| 276 |
|
|
| 277 |
0 |
featureMap = new HashMap<>(); |
| 278 |
0 |
Map<String, String[]> fmap; |
| 279 |
0 |
featureMap.put(compbio.ws.client.Services.IUPredWS.toString(), |
| 280 |
|
fmap = new HashMap<>()); |
| 281 |
0 |
fmap.put("Glob", |
| 282 |
|
new String[] |
| 283 |
|
{ "Globular Domain", "Predicted globular domain" }); |
| 284 |
0 |
featureMap.put(compbio.ws.client.Services.JronnWS.toString(), |
| 285 |
|
fmap = new HashMap<>()); |
| 286 |
0 |
featureMap.put(compbio.ws.client.Services.DisemblWS.toString(), |
| 287 |
|
fmap = new HashMap<>()); |
| 288 |
0 |
fmap.put("REM465", new String[] { "REM465", "Missing density" }); |
| 289 |
0 |
fmap.put("HOTLOOPS", new String[] { "HOTLOOPS", "Flexible loops" }); |
| 290 |
0 |
fmap.put("COILS", new String[] { "COILS", "Random coil" }); |
| 291 |
0 |
featureMap.put(compbio.ws.client.Services.GlobPlotWS.toString(), |
| 292 |
|
fmap = new HashMap<>()); |
| 293 |
0 |
fmap.put("GlobDoms", |
| 294 |
|
new String[] |
| 295 |
|
{ "Globular Domain", "Predicted globular domain" }); |
| 296 |
0 |
fmap.put("Disorder", |
| 297 |
|
new String[] |
| 298 |
|
{ "Protein Disorder", "Probable unstructured peptide region" }); |
| 299 |
0 |
Map<String, Map<String, Object>> amap; |
| 300 |
0 |
annotMap = new HashMap<>(); |
| 301 |
0 |
annotMap.put(compbio.ws.client.Services.GlobPlotWS.toString(), |
| 302 |
|
amap = new HashMap<>()); |
| 303 |
0 |
amap.put("Dydx", new HashMap<String, Object>()); |
| 304 |
0 |
amap.get("Dydx").put(DONTCOMBINE, DONTCOMBINE); |
| 305 |
0 |
amap.get("Dydx").put(THRESHOLD, new double[] { 1, 0 }); |
| 306 |
0 |
amap.get("Dydx").put(RANGE, new float[] { -1, +1 }); |
| 307 |
|
|
| 308 |
0 |
amap.put("SmoothedScore", new HashMap<String, Object>()); |
| 309 |
0 |
amap.get("SmoothedScore").put(INVISIBLE, INVISIBLE); |
| 310 |
0 |
amap.put("RawScore", new HashMap<String, Object>()); |
| 311 |
0 |
amap.get("RawScore").put(INVISIBLE, INVISIBLE); |
| 312 |
0 |
annotMap.put(compbio.ws.client.Services.DisemblWS.toString(), |
| 313 |
|
amap = new HashMap<>()); |
| 314 |
0 |
amap.put("COILS", new HashMap<String, Object>()); |
| 315 |
0 |
amap.put("HOTLOOPS", new HashMap<String, Object>()); |
| 316 |
0 |
amap.put("REM465", new HashMap<String, Object>()); |
| 317 |
0 |
amap.get("COILS").put(THRESHOLD, new double[] { 1, 0.516 }); |
| 318 |
0 |
amap.get("COILS").put(RANGE, new float[] { 0, 1 }); |
| 319 |
|
|
| 320 |
0 |
amap.get("HOTLOOPS").put(THRESHOLD, new double[] { 1, 0.6 }); |
| 321 |
0 |
amap.get("HOTLOOPS").put(RANGE, new float[] { 0, 1 }); |
| 322 |
0 |
amap.get("REM465").put(THRESHOLD, new double[] { 1, 0.1204 }); |
| 323 |
0 |
amap.get("REM465").put(RANGE, new float[] { 0, 1 }); |
| 324 |
|
|
| 325 |
0 |
annotMap.put(compbio.ws.client.Services.IUPredWS.toString(), |
| 326 |
|
amap = new HashMap<>()); |
| 327 |
0 |
amap.put("Long", new HashMap<String, Object>()); |
| 328 |
0 |
amap.put("Short", new HashMap<String, Object>()); |
| 329 |
0 |
amap.get("Long").put(THRESHOLD, new double[] { 1, 0.5 }); |
| 330 |
0 |
amap.get("Long").put(RANGE, new float[] { 0, 1 }); |
| 331 |
0 |
amap.get("Short").put(THRESHOLD, new double[] { 1, 0.5 }); |
| 332 |
0 |
amap.get("Short").put(RANGE, new float[] { 0, 1 }); |
| 333 |
0 |
annotMap.put(compbio.ws.client.Services.JronnWS.toString(), |
| 334 |
|
amap = new HashMap<>()); |
| 335 |
0 |
amap.put("JRonn", new HashMap<String, Object>()); |
| 336 |
0 |
amap.get("JRonn").put(THRESHOLD, new double[] { 1, 0.5 }); |
| 337 |
0 |
amap.get("JRonn").put(RANGE, new float[] { 0, 1 }); |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
} |