import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
import jalview.gui.AlignFrame;
import jalview.gui.AlignmentPanel;
+import jalview.ws.jws2.dm.AAConsSettings;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.WsParamSetI;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TreeSet;
import compbio.data.sequence.Score;
nucleotidesAllowed = false;
proteinAllowed = true;
gapMap=new boolean[0];
+ initViewportParams();
}
+ protected void initViewportParams()
+ {
+ ((jalview.gui.AlignViewport) alignViewport).setCalcIdSettingsFor(getCalcId(), new AAConsSettings(true, service, this.preset, (arguments!=null) ? JabaParamStore.getJwsArgsfromJaba(arguments) : null), true);
+ }
+ @Override
+ public void updateParameters(WsParamSetI newpreset, java.util.List<Argument> newarguments) {
+ super.updateParameters(newpreset, newarguments);
+ initViewportParams();
+ };
public String getServiceActionText()
{
return "calculating Amino acid consensus using AACons service";
{
if (immediate || !calcMan.isWorking(this) && scoremanager != null)
{
- AlignmentAnnotation annotation;
Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
int alWidth = alignViewport.getAlignment().getWidth();
- AlignmentI alignment;
- int ann = (alignment = alignViewport.getAlignment())
- .getAlignmentAnnotation().length;
ArrayList<AlignmentAnnotation> ourAnnot = new ArrayList<AlignmentAnnotation>();
for (String score : scoremap.keySet())
{
- TreeSet<Score> scores = scoremap.get(score);
+ Set<Score> scores = scoremap.get(score);
for (Score scr : scores)
{
if (scr.getRanges() != null && scr.getRanges().size() > 0)
}
else
{
- // simple annotation row
- annotation = alignViewport.getAlignment()
- .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
- null, null);
-
- Annotation[] elm = new Annotation[alWidth];
- if (alWidth == gapMap.length) // scr.getScores().size())
- {
- Iterator<Float> vals = scr.getScores().iterator();
- float m = 0f, x = 0f;
- for (int i = 0; vals.hasNext(); i++)
- {
- float val = vals.next().floatValue();
- if (i == 0)
- {
- m = val;
- x = val;
- }
- else
- {
- if (m > val)
- {
- m = val;
- }
- ;
- if (x < val)
- {
- x = val;
- }
- }
- // if we're at a gapped column then skip to next ungapped position
- if (gapMap != null && gapMap.length > 0)
- {
- while (!gapMap[i])
- {
- elm[i++]=new Annotation("", "" , ' ', Float.NaN);
- }
- }
- elm[i] = new Annotation("", "" + val, ' ', val);
- }
-
- annotation.annotations = elm;
- annotation.belowAlignment = true;
- if (x < 0)
- {
- x = 0;
- }
- x += (x - m) * 0.1;
- annotation.graphMax = x;
- annotation.graphMin = m;
- annotation.validateRangeAndDisplay();
- ourAnnot.add(annotation);
- }
+ createAnnotationRowsForScores(ourAnnot, getCalcId(), alWidth,
+ scr);
}
}
}
+
if (ourAnnot.size() > 0)
{
- List<AlignmentAnnotation> our = ourAnnots;
- ourAnnots = ourAnnot;
- if (our != null)
- {
- if (our.size() > 0)
- {
- for (AlignmentAnnotation an : our)
- {
- if (!ourAnnots.contains(an))
- {
- // remove the old annotation
- alignment.deleteAnnotation(an);
- }
- }
- }
- our.clear();
- }
- }
- // if (ann !=
- // alignViewport.getAlignment().getAlignmentAnnotation().length)
- {
- ap.adjustAnnotationHeight();
+ updateOurAnnots(ourAnnot);
}
- /*
- * else { ap.paintAlignment(true); }
- */
}
}
+ public String getCalcId()
+ {
+ return SequenceAnnotationWSClient.AAConsCalcId;
+ }
+
public static void removeAAConsAnnotation(AlignmentPanel alignPanel)
{
+ for (AlignmentAnnotation aa: alignPanel.getAlignment().findAnnotation(SequenceAnnotationWSClient.AAConsCalcId))
+ {
+ alignPanel.getAlignment().deleteAnnotation(aa);
+ }
// List<AlignmentAnnotation>
// ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.)
// TODO Auto-generated method stub