X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fanalysis%2FConservation.java;h=565924b83e51de6d16a064121bd1fb58e12adbe3;hb=aaa5a9341963ac324baa558bf3f5b744cfdee9c7;hp=7e72dcd638cab9e327cbb4c5a01d502c452cc3fb;hpb=0a5ce6145bb76fc7eb8a5cc2670e20453fbedd29;p=jalview.git diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index 7e72dcd..565924b 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -23,9 +23,9 @@ package jalview.analysis; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.datamodel.ResidueCount; +import jalview.datamodel.ResidueCount.SymbolCounts; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; -import jalview.datamodel.ResidueCount.SymbolCounts; import jalview.schemes.ResidueProperties; import jalview.util.Comparison; @@ -33,17 +33,21 @@ import java.awt.Color; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.SortedMap; import java.util.TreeMap; import java.util.Vector; /** * Calculates conservation values for a given set of sequences - * - * @author $author$ - * @version $Revision$ */ public class Conservation { + /* + * need to have a minimum of 3% of sequences with a residue + * for it to be included in the conservation calculation + */ + private static final int THRESHOLD_PERCENT = 3; + private static final int TOUPPERCASE = 'a' - 'A'; SequenceI[] sequences; @@ -92,12 +96,10 @@ public class Conservation private String[] consSymbs; /** - * Creates a new Conservation object. + * Constructor using default threshold of 3% * * @param name * Name of conservation - * @param threshold - * to count the residues in residueHash(). commonly used value is 3 * @param sequences * sequences to be used in calculation * @param start @@ -105,6 +107,27 @@ public class Conservation * @param end * end residue position */ + public Conservation(String name, List sequences, int start, + int end) + { + this(name, THRESHOLD_PERCENT, sequences, start, end); + } + + /** + * Constructor + * + * @param name + * Name of conservation + * @param threshold + * percentage of sequences at or below which property conservation is + * ignored + * @param sequences + * sequences to be used in calculation + * @param start + * start column position + * @param end + * end column position + */ public Conservation(String name, int threshold, List sequences, int start, int end) { @@ -210,7 +233,9 @@ public class Conservation { ResidueCount values = countResidues(column); - // TODO is threshold a percentage or count value? + /* + * percentage count at or below which we ignore residues + */ int thresh = (threshold * height) / 100; /* @@ -219,7 +244,7 @@ public class Conservation * or not conserved (-1) * Using TreeMap means properties are displayed in alphabetical order */ - Map resultHash = new TreeMap(); + SortedMap resultHash = new TreeMap(); SymbolCounts symbolCounts = values.getSymbolCounts(); char[] symbols = symbolCounts.symbols; int[] counts = symbolCounts.values; @@ -494,7 +519,7 @@ public class Conservation * * @return Conservation sequence */ - public Sequence getConsSequence() + public SequenceI getConsSequence() { return consSequence; } @@ -781,9 +806,6 @@ public class Conservation * * @param name * - name of conservation - * @param threshold - * - minimum number of conserved residues needed to indicate - * conservation (typically 3) * @param seqs * @param start * first column in calculation window @@ -799,10 +821,10 @@ public class Conservation * @return Conservation object ready for use in visualization */ public static Conservation calculateConservation(String name, - int threshold, List seqs, int start, int end, - boolean positiveOnly, int maxPercentGaps, boolean calcQuality) + List seqs, int start, int end, boolean positiveOnly, + int maxPercentGaps, boolean calcQuality) { - Conservation cons = new Conservation(name, threshold, seqs, start, end); + Conservation cons = new Conservation(name, seqs, start, end); cons.calculate(); cons.verdict(positiveOnly, maxPercentGaps);