1 package jalview.ws.jws2;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.datamodel.AlignmentI;
5 import jalview.gui.AlignFrame;
6 import jalview.gui.AlignmentPanel;
7 import jalview.ws.jws2.dm.AAConsSettings;
8 import jalview.ws.jws2.jabaws2.Jws2Instance;
9 import jalview.ws.params.WsParamSetI;
11 import java.util.ArrayList;
12 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];
35 protected void initViewportParams()
37 ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(
39 new AAConsSettings(true, service, this.preset,
40 (arguments != null) ? JabaParamStore
41 .getJwsArgsfromJaba(arguments) : null), true);
45 public void updateParameters(WsParamSetI newpreset,
46 java.util.List<Argument> newarguments)
48 super.updateParameters(newpreset, newarguments);
52 public String getServiceActionText()
54 return "calculating Amino acid consensus using AACons service";
58 * update the consensus annotation from the sequence profile data using
59 * current visualization settings.
62 public void updateResultAnnotation(boolean immediate)
64 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
66 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
67 int alWidth = alignViewport.getAlignment().getWidth();
68 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
69 for (String score : scoremap.keySet())
71 Set<Score> scores = scoremap.get(score);
72 for (Score scr : scores)
74 if (scr.getRanges() != null && scr.getRanges().size() > 0)
77 * annotation in range annotation = findOrCreate(scr.getMethod(),
78 * true, null, null); Annotation[] elm = new Annotation[alWidth];
79 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
80 * : scr.getRanges()) { float val = vals.next().floatValue(); for
81 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
82 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
83 * annotation.validateRangeAndDisplay();
88 createAnnotationRowsForScores(ourAnnot, getCalcId(), alWidth,
94 if (ourAnnot.size() > 0)
96 updateOurAnnots(ourAnnot);
101 public String getCalcId()
103 return SequenceAnnotationWSClient.AAConsCalcId;
106 public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
108 for (AlignmentAnnotation aa : alignPanel.getAlignment().findAnnotation(
109 SequenceAnnotationWSClient.AAConsCalcId))
111 alignPanel.getAlignment().deleteAnnotation(aa);