2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.jws2;
21 import jalview.datamodel.AlignmentAnnotation;
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;
27 import jalview.ws.uimodel.AlignAnalysisUIText;
29 import java.util.ArrayList;
30 import java.util.List;
33 import java.util.TreeSet;
35 import compbio.data.sequence.Score;
36 import compbio.metadata.Argument;
38 public class AAConClient extends JabawsAlignCalcWorker
41 public AAConClient(Jws2Instance service, AlignFrame alignFrame,
42 WsParamSetI preset, List<Argument> paramset)
44 super(service, alignFrame, preset, paramset);
47 nucleotidesAllowed = false;
48 proteinAllowed = true;
49 gapMap = new boolean[0];
53 public String getServiceActionText()
55 return "calculating Amino acid consensus using AACon service";
59 * update the consensus annotation from the sequence profile data using
60 * current visualization settings.
63 public void updateResultAnnotation(boolean immediate)
65 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
67 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
68 int alWidth = alignViewport.getAlignment().getWidth();
69 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
70 for (String score : scoremap.keySet())
72 Set<Score> scores = scoremap.get(score);
73 for (Score scr : scores)
75 if (scr.getRanges() != null && scr.getRanges().size() > 0)
78 * annotation in range annotation = findOrCreate(scr.getMethod(),
79 * true, null, null); Annotation[] elm = new Annotation[alWidth];
80 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
81 * : scr.getRanges()) { float val = vals.next().floatValue(); for
82 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
83 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
84 * annotation.validateRangeAndDisplay();
89 createAnnotationRowsForScores(ourAnnot, getCalcId(), alWidth,
95 if (ourAnnot.size() > 0)
97 updateOurAnnots(ourAnnot);
103 public String getCalcId()
107 private static String CALC_ID="jabaws2.AACon";
109 public static AlignAnalysisUIText getAlignAnalysisUITest()
111 return new AlignAnalysisUIText(
112 compbio.ws.client.Services.AAConWS.toString(),
113 jalview.ws.jws2.AAConClient.class, CALC_ID, false, true, true,
114 "AACon Calculations",
115 "When checked, AACon calculations are updated automatically.",
116 "Change AACon Settings...",
117 "Modify settings for AACon calculations.");