X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FResidueCount.java;h=efab97cabcf0267fcc24f5d3e746217e124ce118;hb=0aa7f6fab658c9a203b410d4bead72217da5c9a0;hp=3e3a9666ddf2061e6d19e9f9fb30ca22b63136e2;hpb=5776cb3b3d74f3c3d3d791d56287d8d78e46b01b;p=jalview.git diff --git a/src/jalview/datamodel/ResidueCount.java b/src/jalview/datamodel/ResidueCount.java index 3e3a966..efab97c 100644 --- a/src/jalview/datamodel/ResidueCount.java +++ b/src/jalview/datamodel/ResidueCount.java @@ -28,6 +28,7 @@ import jalview.util.SparseCount; /** * A class to count occurrences of residues in a profile, optimised for speed * and memory footprint. + * * @author gmcarstairs * */ @@ -69,7 +70,7 @@ public class ResidueCount */ private static final String AAS = "ACDEFGHIKLMNPQRSTUVWXY"; - private static final int GAP_COUNT = 0; + static final int GAP_COUNT = 0; /* * fast lookup tables holding the index into our count @@ -211,7 +212,12 @@ public class ResidueCount counts[offset] = (short) ++newValue; } } - maxCount = Math.max(maxCount, newValue); + + if (offset!=GAP_COUNT) + { + // update modal residue count + maxCount = Math.max(maxCount, newValue); + } return newValue; } @@ -300,15 +306,7 @@ public class ResidueCount */ public int addGap() { - int newValue; - if (useIntCounts) - { - newValue = ++intCounts[GAP_COUNT]; - } - else - { - newValue = ++counts[GAP_COUNT]; - } + int newValue = increment(GAP_COUNT); return newValue; } @@ -447,8 +445,8 @@ public class ResidueCount { if (intCounts[i] == count) { - modal.append(isNucleotide ? NUCS.charAt(i - 1) : AAS - .charAt(i - 1)); + modal.append( + isNucleotide ? NUCS.charAt(i - 1) : AAS.charAt(i - 1)); } } } @@ -458,8 +456,8 @@ public class ResidueCount { if (counts[i] == count) { - modal.append(isNucleotide ? NUCS.charAt(i - 1) : AAS - .charAt(i - 1)); + modal.append( + isNucleotide ? NUCS.charAt(i - 1) : AAS.charAt(i - 1)); } } } @@ -492,7 +490,8 @@ public class ResidueCount * * @return */ - public int size() { + public int size() + { int size = 0; if (useIntCounts) { @@ -546,8 +545,8 @@ public class ResidueCount { if (intCounts[i] > 0) { - char symbol = isNucleotide ? NUCS.charAt(i - 1) : AAS - .charAt(i - 1); + char symbol = isNucleotide ? NUCS.charAt(i - 1) + : AAS.charAt(i - 1); symbols[j] = symbol; values[j] = intCounts[i]; j++; @@ -560,8 +559,8 @@ public class ResidueCount { if (counts[i] > 0) { - char symbol = isNucleotide ? NUCS.charAt(i - 1) : AAS - .charAt(i - 1); + char symbol = isNucleotide ? NUCS.charAt(i - 1) + : AAS.charAt(i - 1); symbols[j] = symbol; values[j] = counts[i]; j++;