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.dm.AAConsSettings;
9 import jalview.ws.jws2.jabaws2.Jws2Instance;
10 import jalview.ws.params.WsParamSetI;
12 import java.util.ArrayList;
13 import java.util.Iterator;
14 import java.util.List;
16 import java.util.TreeSet;
18 import compbio.data.sequence.Score;
19 import compbio.metadata.Argument;
21 public class AAConsClient extends JabawsAlignCalcWorker
24 public AAConsClient(Jws2Instance service, AlignFrame alignFrame,
25 WsParamSetI preset, List<Argument> paramset)
27 super(service, alignFrame, preset, paramset);
30 nucleotidesAllowed = false;
31 proteinAllowed = true;
32 gapMap=new boolean[0];
36 protected void initViewportParams()
38 ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(getCalcId(), new AAConsSettings(true, service, this.preset, (arguments!=null) ? JabaParamStore.getJwsArgsfromJaba(arguments) : null), true);
41 public void updateParameters(WsParamSetI newpreset, java.util.List<Argument> newarguments) {
42 super.updateParameters(newpreset, newarguments);
45 public String getServiceActionText()
47 return "calculating Amino acid consensus using AACons service";
51 * update the consensus annotation from the sequence profile data using
52 * current visualization settings.
55 public void updateResultAnnotation(boolean immediate)
57 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
59 AlignmentAnnotation annotation;
60 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
61 int alWidth = alignViewport.getAlignment().getWidth();
63 int ann = (alignment = alignViewport.getAlignment())
64 .getAlignmentAnnotation().length;
65 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
66 for (String score : scoremap.keySet())
68 TreeSet<Score> scores = scoremap.get(score);
69 for (Score scr : scores)
71 if (scr.getRanges() != null && scr.getRanges().size() > 0)
74 * annotation in range annotation = findOrCreate(scr.getMethod(),
75 * true, null, null); Annotation[] elm = new Annotation[alWidth];
76 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
77 * : scr.getRanges()) { float val = vals.next().floatValue(); for
78 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
79 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
80 * annotation.validateRangeAndDisplay();
85 // simple annotation row
86 annotation = alignViewport.getAlignment()
87 .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
90 Annotation[] elm = new Annotation[alWidth];
91 if (alWidth == gapMap.length) // scr.getScores().size())
93 Iterator<Float> vals = scr.getScores().iterator();
95 for (int i = 0; vals.hasNext(); i++)
97 float val = vals.next().floatValue();
115 // if we're at a gapped column then skip to next ungapped position
116 if (gapMap != null && gapMap.length > 0)
120 elm[i++]=new Annotation("", "" , ' ', Float.NaN);
123 elm[i] = new Annotation("", "" + val, ' ', val);
126 annotation.annotations = elm;
127 annotation.belowAlignment = true;
133 annotation.graphMax = x;
134 annotation.graphMin = m;
135 annotation.validateRangeAndDisplay();
136 ourAnnot.add(annotation);
141 if (ourAnnot.size() > 0)
143 List<AlignmentAnnotation> our = ourAnnots;
144 ourAnnots = ourAnnot;
149 for (AlignmentAnnotation an : our)
151 if (!ourAnnots.contains(an))
153 // remove the old annotation
154 alignment.deleteAnnotation(an);
162 // alignViewport.getAlignment().getAlignmentAnnotation().length)
164 ap.adjustAnnotationHeight();
167 * else { ap.paintAlignment(true); }
172 public String getCalcId()
174 return SequenceAnnotationWSClient.AAConsCalcId;
177 public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
179 for (AlignmentAnnotation aa: alignPanel.getAlignment().findAnnotation(SequenceAnnotationWSClient.AAConsCalcId))
181 alignPanel.getAlignment().deleteAnnotation(aa);
183 // List<AlignmentAnnotation>
184 // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.)
185 // TODO Auto-generated method stub