X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FResidueCount.java;h=154af20b6888b9a09593089e5f92609420395e6c;hb=304e64fb34b32659be1bbfd39fb4e15b2f79586e;hp=efab97cabcf0267fcc24f5d3e746217e124ce118;hpb=61ff8fb4efa315c35149c9d11850d99e3d00c441;p=jalview.git diff --git a/src/jalview/datamodel/ResidueCount.java b/src/jalview/datamodel/ResidueCount.java index efab97c..154af20 100644 --- a/src/jalview/datamodel/ResidueCount.java +++ b/src/jalview/datamodel/ResidueCount.java @@ -25,6 +25,8 @@ import jalview.util.Format; import jalview.util.QuickSort; import jalview.util.SparseCount; +import java.util.List; + /** * A class to count occurrences of residues in a profile, optimised for speed * and memory footprint. @@ -148,6 +150,24 @@ public class ResidueCount } /** + * A constructor that counts frequency of all symbols (including gaps) in the + * sequences (not case-sensitive) + * + * @param sequences + */ + public ResidueCount(List sequences) + { + this(); + for (SequenceI seq : sequences) + { + for (int i = 0; i < seq.getLength(); i++) + { + add(seq.getCharAt(i)); + } + } + } + + /** * Increments the count for the given character. The supplied character may be * upper or lower case but counts are for the upper case only. Gap characters * (space, ., -) are all counted together. @@ -637,4 +657,19 @@ public class ResidueCount sb.append("]"); return sb.toString(); } + + /** + * Answers the total count for all symbols (excluding gaps) + * + * @return + */ + public int getTotalResidueCount() + { + int total = 0; + for (char symbol : this.getSymbolCounts().symbols) + { + total += getCount(symbol); + } + return total; + } }