package jalview.ws.jws2; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.gui.AlignFrame; import jalview.gui.AlignmentPanel; 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.TreeSet; import compbio.data.sequence.Score; import compbio.metadata.Argument; public class AAConsClient extends JabawsAlignCalcWorker { public AAConsClient(Jws2Instance service, AlignFrame alignFrame, WsParamSetI preset, List paramset) { super(service, alignFrame, preset, paramset); submitGaps = true; alignedSeqs = true; nucleotidesAllowed = false; proteinAllowed = true; gapMap=new boolean[0]; } public String getServiceActionText() { return "calculating Amino acid consensus using AACons service"; } /** * update the consensus annotation from the sequence profile data using * current visualization settings. */ public void updateResultAnnotation(boolean immediate) { if (immediate || !calcMan.isWorking(this) && scoremanager != null) { AlignmentAnnotation annotation; ; Map> scoremap = scoremanager.asMap(); int alWidth = alignViewport.getAlignment().getWidth(); AlignmentI alignment; int ann = (alignment = alignViewport.getAlignment()) .getAlignmentAnnotation().length; ArrayList ourAnnot = new ArrayList(); for (String score : scoremap.keySet()) { TreeSet scores = scoremap.get(score); for (Score scr : scores) { if (scr.getRanges() != null && scr.getRanges().size() > 0) { /** * annotation in range annotation = findOrCreate(scr.getMethod(), * true, null, null); Annotation[] elm = new Annotation[alWidth]; * Iterator vals = scr.getScores().iterator(); for (Range rng * : scr.getRanges()) { float val = vals.next().floatValue(); for * (int i = rng.from; i <= rng.to; i++) { elm[i] = new * Annotation("", "", ' ', val); } } annotation.annotations = elm; * annotation.validateRangeAndDisplay(); */ } else { // simple annotation row annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null); Annotation[] elm = new Annotation[alWidth]; if (alWidth == gapMap.length) // scr.getScores().size()) { Iterator 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); } } } } if (ourAnnot.size() > 0) { List 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(); } /* * else { ap.paintAlignment(true); } */ } } public static void removeAAConsAnnotation(AlignmentPanel alignPanel) { // List // ourannots=alignPanel.getAlignment().findAnnotation(Screen3D.) // TODO Auto-generated method stub } }