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.gui.AlignmentPanel;
8 import jalview.ws.jws2.jabaws2.Jws2Instance;
9 import jalview.ws.params.WsParamSetI;
11 import java.util.ArrayList;
12 import java.util.Iterator;
13 import java.util.List;
15 import java.util.TreeSet;
17 import compbio.data.sequence.Score;
18 import compbio.metadata.Argument;
20 public class AAConsClient extends JabawsAlignCalcWorker
23 public AAConsClient(Jws2Instance service, AlignFrame alignFrame,
24 WsParamSetI preset, List<Argument> paramset)
26 super(service, alignFrame, preset, paramset);
29 nucleotidesAllowed = false;
30 proteinAllowed = true;
31 gapMap=new boolean[0];
34 public String getServiceActionText()
36 return "calculating Amino acid consensus using AACons service";
40 * update the consensus annotation from the sequence profile data using
41 * current visualization settings.
44 public void updateResultAnnotation(boolean immediate)
46 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
48 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 = alignViewport.getAlignment()
76 .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
79 Annotation[] elm = new Annotation[alWidth];
80 if (alWidth == gapMap.length) // scr.getScores().size())
82 Iterator<Float> vals = scr.getScores().iterator();
84 for (int i = 0; vals.hasNext(); i++)
86 float val = vals.next().floatValue();
104 // if we're at a gapped column then skip to next ungapped position
105 if (gapMap != null && gapMap.length > 0)
109 elm[i++]=new Annotation("", "" , ' ', Float.NaN);
112 elm[i] = new Annotation("", "" + val, ' ', val);
115 annotation.annotations = elm;
116 annotation.belowAlignment = true;
122 annotation.graphMax = x;
123 annotation.graphMin = m;
124 annotation.validateRangeAndDisplay();
125 ourAnnot.add(annotation);
130 if (ourAnnot.size() > 0)
132 List<AlignmentAnnotation> our = ourAnnots;
133 ourAnnots = ourAnnot;
138 for (AlignmentAnnotation an : our)
140 if (!ourAnnots.contains(an))
142 // remove the old annotation
143 alignment.deleteAnnotation(an);
151 // alignViewport.getAlignment().getAlignmentAnnotation().length)
153 ap.adjustAnnotationHeight();
156 * else { ap.paintAlignment(true); }
161 public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
163 // List<AlignmentAnnotation>
164 // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.)
165 // TODO Auto-generated method stub