1 package jalview.ws.jws2;
3 import jalview.api.AlignCalcWorkerI;
4 import jalview.bin.Cache;
5 import jalview.datamodel.AlignmentAnnotation;
7 import jalview.datamodel.SequenceFeature;
8 import jalview.datamodel.SequenceI;
9 import jalview.gui.AlignFrame;
10 import jalview.schemes.GraduatedColor;
11 import jalview.schemes.UserColourScheme;
12 import jalview.ws.jws2.jabaws2.Jws2Instance;
13 import jalview.ws.params.WsParamSetI;
15 import java.awt.Color;
16 import java.util.ArrayList;
17 import java.util.HashMap;
18 import java.util.Hashtable;
19 import java.util.Iterator;
20 import java.util.List;
22 import compbio.data.sequence.Range;
23 import compbio.data.sequence.Score;
24 import compbio.data.sequence.ScoreManager.ScoreHolder;
25 import compbio.metadata.Argument;
26 import compbio.ws.client.Services;
28 public class AADisorderClient extends JabawsAlignCalcWorker implements
40 public AADisorderClient(Jws2Instance sh, AlignFrame alignFrame,
41 WsParamSetI preset, List<Argument> paramset)
43 super(sh, alignFrame, preset, paramset);
46 methodName = sh.serviceType;
50 nucleotidesAllowed = false;
51 proteinAllowed = true;
56 public String getServiceActionText()
58 return "Submitting amino acid sequences for disorder prediction.";
61 private static Map<String, Map<String, String[]>> featureMap;
63 private static Map<String, Map<String, Map<String, Object>>> annotMap;
65 private static String DONTCOMBINE = "DONTCOMBINE";
66 private static String INVISIBLE = "INVISIBLE";
69 featureMap = new HashMap<String, Map<String, String[]>>();
70 Map<String, String[]> fmap;
71 featureMap.put(compbio.ws.client.Services.IUPredWS.toString(),
72 fmap = new HashMap<String, String[]>());
73 fmap.put("Glob", new String[]
74 { "Globular Domain", "Predicted globular domain" });
75 featureMap.put(compbio.ws.client.Services.JronnWS.toString(),
76 fmap = new HashMap<String, String[]>());
77 featureMap.put(compbio.ws.client.Services.DisemblWS.toString(),
78 fmap = new HashMap<String, String[]>());
79 fmap.put("REM465", new String[]
80 { "REM465", "Missing density" });
81 fmap.put("HOTLOOPS", new String[]
82 { "HOTLOOPS", "Flexible loops" });
83 fmap.put("COILS", new String[]
84 { "COILS", "Random coil" });
85 featureMap.put(compbio.ws.client.Services.GlobPlotWS.toString(),
86 fmap = new HashMap<String, String[]>());
87 fmap.put("GlobDoms", new String[]
88 { "Globular Domain", "Predicted globular domain" });
89 fmap.put("Disorder", new String[]
90 { "Protein Disorder", "Probable unstructured peptide region" });
91 Map<String, Map<String, Object>> amap;
92 annotMap = new HashMap<String, Map<String, Map<String, Object>>>();
93 annotMap.put(compbio.ws.client.Services.GlobPlotWS.toString(),
94 amap = new HashMap<String, Map<String, Object>>());
95 amap.put("Dydx", new HashMap<String, Object>());
96 amap.get("Dydx").put(DONTCOMBINE, DONTCOMBINE);
97 amap.put("SmoothedScore", new HashMap<String, Object>());
98 amap.get("SmoothedScore").put(INVISIBLE,INVISIBLE);
99 amap.put("RawScore", new HashMap<String, Object>());
100 amap.get("RawScore").put(INVISIBLE,INVISIBLE);
101 annotMap.put(compbio.ws.client.Services.DisemblWS.toString(),
102 amap = new HashMap<String, Map<String, Object>>());
107 public void updateResultAnnotation(boolean immediate)
110 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
112 Map<String, String[]> featureTypeMap = featureMap
113 .get(service.serviceType);
114 Map<String, Map<String, Object>> annotTypeMap = annotMap
115 .get(service.serviceType);
116 boolean dispFeatures = false;
117 Map<String, Object> fc = new Hashtable<String, Object>();
118 List<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
120 * grouping for any annotation rows created
122 int graphGroup = 1, iGraphGroup = 1;
123 if (alignViewport.getAlignment().getAlignmentAnnotation() != null)
125 for (AlignmentAnnotation ala : alignViewport.getAlignment()
126 .getAlignmentAnnotation())
128 if (ala.graphGroup > graphGroup)
130 graphGroup = ala.graphGroup;
135 for (String seqId : seqNames.keySet())
137 boolean sameGroup = false;
138 SequenceI dseq, aseq, seq = seqNames.get(seqId);
139 int base = seq.getStart() - 1;
141 while ((dseq = seq).getDatasetSequence() != null)
143 seq = seq.getDatasetSequence();
146 ScoreHolder scores = scoremanager.getAnnotationForSequence(seqId);
147 float last = Float.NaN, val = Float.NaN;
148 int lastAnnot = ourAnnot.size();
149 for (Score scr : scores.scores)
152 if (scr.getRanges() != null && scr.getRanges().size() > 0)
154 Iterator<Float> vals = scr.getScores().iterator();
155 // make features on sequence
156 for (Range rn : scr.getRanges())
160 String[] type = featureTypeMap.get(scr.getMethod());
163 // create a default type for this feature
165 { typeName + " (" + scr.getMethod() + ")",
166 service.getActionText() };
170 sf = new SequenceFeature(type[0], type[1], base + rn.from,
171 base + rn.to, val = vals.next().floatValue(),
176 sf = new SequenceFeature(type[0], type[1], null, base
177 + rn.from, base + rn.to, methodName);
179 dseq.addSequenceFeature(sf);
180 if (last != val && last != Float.NaN)
182 fc.put(sf.getType(), sf);
190 if (scr.getScores().size()==0)
194 AlignmentAnnotation annot = createAnnotationRowsForScores(
195 ourAnnot, service.serviceType + " (" + scr.getMethod()
196 + ")", service.getServiceTypeURI()+"/"+ scr.getMethod(), aseq,
198 annot.graph = AlignmentAnnotation.LINE_GRAPH;
199 annot.visible = (annotTypeMap==null || annotTypeMap.get(scr.getMethod())==null || annotTypeMap.get(scr.getMethod()).get(INVISIBLE) == null);
201 if (annotTypeMap==null || annotTypeMap.get(scr.getMethod())==null || annotTypeMap.get(scr.getMethod()).get(DONTCOMBINE) == null)
210 annot.graphGroup = graphGroup;
214 annot.description = service.getActionText() + " - raw scores";
215 Color col = new UserColourScheme(typeName)
216 .createColourFromName(typeName + scr.getMethod());
217 for (int p = 0, ps = annot.annotations.length; p < ps; p++)
219 if (annot.annotations[p] != null)
221 annot.annotations[p].colour = col;
224 annot._linecolour=col;
227 if (lastAnnot + 1 == ourAnnot.size())
229 // remove singleton alignment annotation row
230 ourAnnot.get(lastAnnot).graphGroup = -1;
236 jalview.gui.FeatureRenderer fr = ((jalview.gui.AlignmentPanel) ap)
237 .cloneFeatureRenderer();
238 for (String ft : fc.keySet())
240 Object gc = fr.getFeatureStyle(ft);
241 if (gc instanceof Color)
243 // set graduated color as fading to white for minimum, and
244 // autoscaling to values on alignment
245 GraduatedColor ggc = new GraduatedColor(Color.white,
246 (Color) gc, Float.MIN_VALUE, Float.MAX_VALUE);
247 ggc.setAutoScaled(true);
248 fr.setColour(ft, ggc);
251 // TODO: JAL-1150 - create sequence feature settings API for defining styles and enabling/disabling feature overlay on alignment panel
252 ((jalview.gui.AlignmentPanel) ap).updateFeatureRendererFrom(fr);
253 if (af.alignPanel==ap)
255 // only do this if the alignFrame is currently showing this view.
256 af.setShowSeqFeatures(true);
258 ap.paintAlignment(true);
260 if (ourAnnot.size() > 0)
262 // Modify the visible annotation on the alignment viewport with the
263 // new alignment annotation rows created.
264 updateOurAnnots(ourAnnot);
265 ap.adjustAnnotationHeight();