More BaseCounts optimizations for RR.

This commit is contained in:
Eric Banks 2012-10-17 00:55:44 -04:00
parent 19e2b5f0d5
commit 33df1afe0e
1 changed files with 3 additions and 13 deletions

View File

@ -167,13 +167,9 @@ import java.util.Map;
*/
@Ensures({"result >=0.0", "result<= 1.0"})
public double baseCountProportion(final BaseIndex baseIndex) {
final int total = totalCount();
if (total == 0)
return 0.0;
return (double) counts.get(baseIndex) / total;
return (totalCount == 0) ? 0.0 : (double)counts.get(baseIndex) / (double)totalCount;
}
@Ensures("result != null")
public String toString() {
StringBuilder b = new StringBuilder();
@ -239,11 +235,7 @@ import java.util.Map;
@Ensures("result >=0")
public int totalCountWithoutIndels() {
int sum = 0;
for (Map.Entry<BaseIndex, Integer> entry : counts.entrySet())
if (entry.getKey().isNucleotide())
sum += entry.getValue();
return sum;
return totalCount - counts.get(BaseIndex.D) - counts.get(BaseIndex.I);
}
/**
@ -256,9 +248,7 @@ import java.util.Map;
@Ensures({"result >=0.0", "result<= 1.0"})
public double baseCountProportionWithoutIndels(final BaseIndex index) {
final int total = totalCountWithoutIndels();
if (total == 0)
return 0.0;
return (double) counts.get(index) / total;
return (total == 0) ? 0.0 : (double)counts.get(index) / (double)total;
}
public Object[] countsArray() {