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;
29 proteinAllowed = true;
30 gapMap=new boolean[0];
33 public String getServiceActionText()
35 return "calculating Amino acid consensus using AACons service";
39 * update the consensus annotation from the sequence profile data using
40 * current visualization settings.
43 public void updateResultAnnotation(boolean immediate)
46 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
48 AlignmentAnnotation annotation;
50 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
51 int alWidth = alignViewport.getAlignment().getWidth();
53 int ann = (alignment = alignViewport.getAlignment())
54 .getAlignmentAnnotation().length;
55 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
56 for (String score : scoremap.keySet())
58 TreeSet<Score> scores = scoremap.get(score);
59 for (Score scr : scores)
61 if (scr.getRanges() != null && scr.getRanges().size() > 0)
64 * annotation in range annotation = findOrCreate(scr.getMethod(),
65 * true, null, null); Annotation[] elm = new Annotation[alWidth];
66 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
67 * : scr.getRanges()) { float val = vals.next().floatValue(); for
68 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
69 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
70 * annotation.validateRangeAndDisplay();
75 // simple annotation row
76 annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
77 Annotation[] elm = new Annotation[alWidth];
78 if (alWidth == scr.getScores().size())
80 Iterator<Float> vals = scr.getScores().iterator();
82 for (int i = 0; vals.hasNext(); i++)
84 float val = vals.next().floatValue();
102 // if we're at a gapped column then skip to next ungapped position
103 if (gapMap != null && gapMap.length > 0)
107 elm[i++]=new Annotation("", "" , ' ', Float.NaN);
110 elm[i] = new Annotation("", "" + val, ' ', val);
113 annotation.annotations = elm;
114 annotation.belowAlignment = true;
120 annotation.graphMax = x;
121 annotation.graphMin = m;
122 annotation.validateRangeAndDisplay();
123 ourAnnot.add(annotation);
128 if (ourAnnot.size() > 0)
130 List<AlignmentAnnotation> our = ourAnnots;
131 ourAnnots = ourAnnot;
136 for (AlignmentAnnotation an : our)
138 if (!ourAnnots.contains(an))
140 // remove the old annotation
141 alignment.deleteAnnotation(an);
149 // alignViewport.getAlignment().getAlignmentAnnotation().length)
151 ap.adjustAnnotationHeight();
154 * else { ap.paintAlignment(true); }