X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fanalysis%2FAAFrequency.java;h=6c21c749f416220a6a7f987b884a9cd64434b1c4;hb=4e1cb9b8b058d9b633af223b1cdb7b220d5d2ccd;hp=36534a36a9eaed2a7da3acb49c312974dc1e948a;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 36534a3..6c21c74 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -156,4 +156,47 @@ public class AAFrequency result[i] = residueHash; } } + + /** + * Compute all or part of the annotation row from the given consensus hashtable + * @param consensus - pre-allocated annotation row + * @param hconsensus + * @param iStart + * @param width + * @param ignoreGapsInConsensusCalculation + */ + public static void completeConsensus(AlignmentAnnotation consensus, + Hashtable[] hconsensus, int iStart, int width, + boolean ignoreGapsInConsensusCalculation) + { + for (int i = iStart; i < width; i++) + { + float value = 0; + if (ignoreGapsInConsensusCalculation) + { + value = ((Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)) + .floatValue(); + } + else + { + value = ((Float) hconsensus[i].get(AAFrequency.PID_GAPS)) + .floatValue(); + } + + String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE) + .toString(); + String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + + " "; + + if (maxRes.length() > 1) + { + mouseOver = "[" + maxRes + "] "; + maxRes = "+"; + } + + mouseOver += ((int) value + "%"); + consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', + value); + } + } }