1 package jalview.ws.jws2;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.Annotation;
6 import jalview.gui.AlignFrame;
7 import jalview.ws.jws2.jabaws2.Jws2Instance;
8 import jalview.ws.params.WsParamSetI;
10 import java.util.ArrayList;
11 import java.util.Iterator;
12 import java.util.List;
14 import java.util.TreeSet;
16 import compbio.data.sequence.Score;
17 import compbio.metadata.Argument;
19 public class AAConsClient extends JabawsAlignCalcWorker
22 public AAConsClient(Jws2Instance service, AlignFrame alignFrame,
23 WsParamSetI preset, List<Argument> paramset)
25 super(service, alignFrame, preset, paramset);
28 nucleotidesAllowed=false;
32 public String getServiceActionText()
34 return "calculating Amino acid consensus using AACons service";
38 * update the consensus annotation from the sequence profile data using
39 * current visualization settings.
42 public void updateResultAnnotation(boolean immediate)
45 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
47 AlignmentAnnotation annotation;
49 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
50 int alWidth = alignViewport.getAlignment().getWidth();
52 int ann = (alignment = alignViewport.getAlignment())
53 .getAlignmentAnnotation().length;
54 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
55 for (String score : scoremap.keySet())
57 TreeSet<Score> scores = scoremap.get(score);
58 for (Score scr : scores)
60 if (scr.getRanges() != null && scr.getRanges().size() > 0)
63 * annotation in range annotation = findOrCreate(scr.getMethod(),
64 * true, null, null); Annotation[] elm = new Annotation[alWidth];
65 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
66 * : scr.getRanges()) { float val = vals.next().floatValue(); for
67 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
68 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
69 * annotation.validateRangeAndDisplay();
74 // simple annotation row
75 annotation = findOrCreate(scr.getMethod(), true, null, null);
76 Annotation[] elm = new Annotation[alWidth];
77 if (alWidth == scr.getScores().size())
79 Iterator<Float> vals = scr.getScores().iterator();
81 for (int i = 0; vals.hasNext(); i++)
83 float val = vals.next().floatValue();
101 elm[i] = new Annotation("", "" + val, ' ', val);
104 annotation.annotations = elm;
105 annotation.belowAlignment = true;
111 annotation.graphMax = x;
112 annotation.graphMin = m;
113 annotation.validateRangeAndDisplay();
114 ourAnnot.add(annotation);
119 if (ourAnnot.size() > 0)
121 List<AlignmentAnnotation> our = ourAnnots;
122 ourAnnots = ourAnnot;
127 for (AlignmentAnnotation an : our)
129 if (!ourAnnots.contains(an))
131 // remove the old annotation
132 alignment.deleteAnnotation(an);
140 // alignViewport.getAlignment().getAlignmentAnnotation().length)
142 ap.adjustAnnotationHeight();
145 * else { ap.paintAlignment(true); }