X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FResidueCount.java;h=dc98f998c1739f35a93b6cddbb51b5485ba1ba82;hb=HEAD;hp=0d0348cc89d4b1139e3fa60fe42cfef71cf95abe;hpb=0a5ce6145bb76fc7eb8a5cc2670e20453fbedd29;p=jalview.git diff --git a/src/jalview/datamodel/ResidueCount.java b/src/jalview/datamodel/ResidueCount.java index 0d0348c..dc98f99 100644 --- a/src/jalview/datamodel/ResidueCount.java +++ b/src/jalview/datamodel/ResidueCount.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.datamodel; import jalview.util.Comparison; @@ -8,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 * */ @@ -49,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 @@ -191,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; } @@ -280,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; } @@ -427,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)); } } } @@ -438,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)); } } } @@ -472,7 +490,8 @@ public class ResidueCount * * @return */ - public int size() { + public int size() + { int size = 0; if (useIntCounts) { @@ -526,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++; @@ -540,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++;