2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.ws.jws2;
20 import jalview.datamodel.AlignmentAnnotation;
21 import jalview.datamodel.AlignmentI;
22 import jalview.gui.AlignFrame;
23 import jalview.gui.AlignmentPanel;
24 import jalview.ws.jws2.dm.AAConSettings;
25 import jalview.ws.jws2.jabaws2.Jws2Instance;
26 import jalview.ws.params.WsParamSetI;
28 import java.util.ArrayList;
29 import java.util.List;
32 import java.util.TreeSet;
34 import compbio.data.sequence.Score;
35 import compbio.metadata.Argument;
37 public class AAConClient extends JabawsAlignCalcWorker
40 public AAConClient(Jws2Instance service, AlignFrame alignFrame,
41 WsParamSetI preset, List<Argument> paramset)
43 super(service, alignFrame, preset, paramset);
46 nucleotidesAllowed = false;
47 proteinAllowed = true;
48 gapMap = new boolean[0];
52 protected void initViewportParams()
54 ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(
56 new AAConSettings(true, service, this.preset,
57 (arguments != null) ? JabaParamStore
58 .getJwsArgsfromJaba(arguments) : null), true);
62 public void updateParameters(WsParamSetI newpreset,
63 java.util.List<Argument> newarguments)
65 super.updateParameters(newpreset, newarguments);
69 public String getServiceActionText()
71 return "calculating Amino acid consensus using AACon service";
75 * update the consensus annotation from the sequence profile data using
76 * current visualization settings.
79 public void updateResultAnnotation(boolean immediate)
81 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
83 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
84 int alWidth = alignViewport.getAlignment().getWidth();
85 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
86 for (String score : scoremap.keySet())
88 Set<Score> scores = scoremap.get(score);
89 for (Score scr : scores)
91 if (scr.getRanges() != null && scr.getRanges().size() > 0)
94 * annotation in range annotation = findOrCreate(scr.getMethod(),
95 * true, null, null); Annotation[] elm = new Annotation[alWidth];
96 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
97 * : scr.getRanges()) { float val = vals.next().floatValue(); for
98 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
99 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
100 * annotation.validateRangeAndDisplay();
105 createAnnotationRowsForScores(ourAnnot, getCalcId(), alWidth,
111 if (ourAnnot.size() > 0)
113 updateOurAnnots(ourAnnot);
118 public String getCalcId()
120 return SequenceAnnotationWSClient.AAConCalcId;
123 public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
125 for (AlignmentAnnotation aa : alignPanel.getAlignment().findAnnotation(
126 SequenceAnnotationWSClient.AAConCalcId))
128 alignPanel.getAlignment().deleteAnnotation(aa);