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)
47 if (immediate || !calcMan.isWorking(this) && scoremanager != null)
49 AlignmentAnnotation annotation;
51 Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
52 int alWidth = alignViewport.getAlignment().getWidth();
54 int ann = (alignment = alignViewport.getAlignment())
55 .getAlignmentAnnotation().length;
56 ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
57 for (String score : scoremap.keySet())
59 TreeSet<Score> scores = scoremap.get(score);
60 for (Score scr : scores)
62 if (scr.getRanges() != null && scr.getRanges().size() > 0)
65 * annotation in range annotation = findOrCreate(scr.getMethod(),
66 * true, null, null); Annotation[] elm = new Annotation[alWidth];
67 * Iterator<Float> vals = scr.getScores().iterator(); for (Range rng
68 * : scr.getRanges()) { float val = vals.next().floatValue(); for
69 * (int i = rng.from; i <= rng.to; i++) { elm[i] = new
70 * Annotation("", "", ' ', val); } } annotation.annotations = elm;
71 * annotation.validateRangeAndDisplay();
76 // simple annotation row
77 annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
78 Annotation[] elm = new Annotation[alWidth];
79 if (alWidth == gapMap.length) // scr.getScores().size())
81 Iterator<Float> vals = scr.getScores().iterator();
83 for (int i = 0; vals.hasNext(); i++)
85 float val = vals.next().floatValue();
103 // if we're at a gapped column then skip to next ungapped position
104 if (gapMap != null && gapMap.length > 0)
108 elm[i++]=new Annotation("", "" , ' ', Float.NaN);
111 elm[i] = new Annotation("", "" + val, ' ', val);
114 annotation.annotations = elm;
115 annotation.belowAlignment = true;
121 annotation.graphMax = x;
122 annotation.graphMin = m;
123 annotation.validateRangeAndDisplay();
124 ourAnnot.add(annotation);
129 if (ourAnnot.size() > 0)
131 List<AlignmentAnnotation> our = ourAnnots;
132 ourAnnots = ourAnnot;
137 for (AlignmentAnnotation an : our)
139 if (!ourAnnots.contains(an))
141 // remove the old annotation
142 alignment.deleteAnnotation(an);
150 // alignViewport.getAlignment().getAlignmentAnnotation().length)
152 ap.adjustAnnotationHeight();
155 * else { ap.paintAlignment(true); }
160 public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
162 // List<AlignmentAnnotation>
163 // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.)
164 // TODO Auto-generated method stub