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";
68 featureMap = new HashMap<String, Map<String, String[]>>();
69 Map<String, String[]> fmap;
70 featureMap.put(compbio.ws.client.Services.IUPredWS.toString(),
71 fmap = new HashMap<String, String[]>());
72 fmap.put("Glob", new String[]
73 { "Globular Domain", "Predicted globular domain" });
74 featureMap.put(compbio.ws.client.Services.JronnWS.toString(),
75 fmap = new HashMap<String, String[]>());
76 featureMap.put(compbio.ws.client.Services.DisemblWS.toString(),
77 fmap = new HashMap<String, String[]>());
78 fmap.put("REM465", new String[]
79 { "REM465", "Missing density" });
80 fmap.put("HOTLOOPS", new String[]
81 { "HOTLOOPS", "Flexible loops" });
82 fmap.put("COILS", new String[]
83 { "COILS", "Random coil" });
84 featureMap.put(compbio.ws.client.Services.GlobPlotWS.toString(),
85 fmap = new HashMap<String, String[]>());
86 fmap.put("GlobDoms", new String[]
87 { "Globular Domain", "Predicted globular domain" });
88 fmap.put("Disorder", new String[]
89 { "Protein Disorder", "Probable unstructured peptide region" });
90 Map<String, Map<String, Object>> amap;
91 annotMap = new HashMap<String, Map<String, Map<String, Object>>>();
92 annotMap.put(compbio.ws.client.Services.GlobPlotWS.toString(),
93 amap = new HashMap<String, Map<String, Object>>());
94 amap.put("Dydx", new HashMap<String, Object>());
95 amap.get("Dydx").put(DONTCOMBINE, DONTCOMBINE);
96 annotMap.put(compbio.ws.client.Services.DisemblWS.toString(),
97 amap = new HashMap<String, Map<String, Object>>());
102 public void updateResultAnnotation(boolean immediate)
105 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
107 Map<String, String[]> featureTypeMap = featureMap
108 .get(service.serviceType);
109 Map<String, Map<String, Object>> annotTypeMap = annotMap
110 .get(service.serviceType);
111 boolean dispFeatures = false;
112 Map<String, Object> fc = new Hashtable<String, Object>();
113 List<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
115 * grouping for any annotation rows created
117 int graphGroup = 1, iGraphGroup = 1;
118 if (alignViewport.getAlignment().getAlignmentAnnotation() != null)
120 for (AlignmentAnnotation ala : alignViewport.getAlignment()
121 .getAlignmentAnnotation())
123 if (ala.graphGroup > graphGroup)
125 graphGroup = ala.graphGroup;
130 for (String seqId : seqNames.keySet())
132 boolean sameGroup = false;
133 SequenceI dseq, aseq, seq = seqNames.get(seqId);
134 int base = seq.getStart() - 1;
136 while ((dseq = seq).getDatasetSequence() != null)
138 seq = seq.getDatasetSequence();
141 ScoreHolder scores = scoremanager.getAnnotationForSequence(seqId);
142 float last = Float.NaN, val = Float.NaN;
143 int lastAnnot = ourAnnot.size();
144 for (Score scr : scores.scores)
147 if (scr.getRanges() != null && scr.getRanges().size() > 0)
149 Iterator<Float> vals = scr.getScores().iterator();
150 // make features on sequence
151 for (Range rn : scr.getRanges())
155 String[] type = featureTypeMap.get(scr.getMethod());
158 // create a default type for this feature
160 { typeName + " (" + scr.getMethod() + ")",
161 service.getActionText() };
165 sf = new SequenceFeature(type[0], type[1], base + rn.from,
166 base + rn.to, val = vals.next().floatValue(),
171 sf = new SequenceFeature(type[0], type[1], null, base
172 + rn.from, base + rn.to, methodName);
174 dseq.addSequenceFeature(sf);
175 if (last != val && last != Float.NaN)
177 fc.put(sf.getType(), sf);
186 AlignmentAnnotation annot = createAnnotationRowsForScores(
187 ourAnnot, service.serviceType + " (" + scr.getMethod()
188 + ")", service.getServiceTypeURI()+"/"+ scr.getMethod(), aseq,
190 annot.graph = AlignmentAnnotation.LINE_GRAPH;
191 if (annotTypeMap==null || annotTypeMap.get(scr.getMethod())==null || annotTypeMap.get(scr.getMethod()).get(DONTCOMBINE) == null)
200 annot.graphGroup = graphGroup;
203 annot.description = service.getActionText() + " - raw scores";
204 Color col = new UserColourScheme(typeName)
205 .createColourFromName(typeName + scr.getMethod());
206 for (int p = 0, ps = annot.annotations.length; p < ps; p++)
208 if (annot.annotations[p] != null)
210 annot.annotations[p].colour = col;
215 if (lastAnnot + 1 == ourAnnot.size())
217 // remove singleton alignment annotation row
218 ourAnnot.get(lastAnnot).graphGroup = -1;
224 jalview.gui.FeatureRenderer fr = ((jalview.gui.AlignmentPanel) ap)
225 .cloneFeatureRenderer();
226 for (String ft : fc.keySet())
228 Object gc = fr.getFeatureStyle(ft);
229 if (gc instanceof Color)
231 // set graduated color as fading to white for minimum, and
232 // autoscaling to values on alignment
233 GraduatedColor ggc = new GraduatedColor(Color.white,
234 (Color) gc, Float.MIN_VALUE, Float.MAX_VALUE);
235 ggc.setAutoScaled(true);
236 fr.setColour(ft, ggc);
239 // TODO: JAL-1150 - create sequence feature settings API for defining styles and enabling/disabling feature overlay on alignment panel
240 ((jalview.gui.AlignmentPanel) ap).updateFeatureRendererFrom(fr);
241 if (af.alignPanel==ap)
243 // only do this if the alignFrame is currently showing this view.
244 af.setShowSeqFeatures(true);
246 ap.paintAlignment(true);
248 if (ourAnnot.size() > 0)
250 // Modify the visible annotation on the alignment viewport with the
251 // new alignment annotation rows created.
252 updateOurAnnots(ourAnnot);
253 ap.adjustAnnotationHeight();