Bug fixing for BWA output formats.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1841 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2009-10-14 19:32:22 +00:00
parent 60183229ab
commit 72c34f11dd
1 changed files with 10 additions and 9 deletions

View File

@ -68,9 +68,10 @@ public class Counts implements Cloneable {
int[] countArray = new int[counts.size()]; int[] countArray = new int[counts.size()];
if(cumulative) { if(cumulative) {
int index = 0; int index = 0;
boolean first = true;
for(byte base: Bases.instance) { for(byte base: Bases.instance) {
if(index == 0) { if(first) {
index++; first = false;
continue; continue;
} }
countArray[index++] = getCumulative(base); countArray[index++] = getCumulative(base);
@ -80,7 +81,7 @@ public class Counts implements Cloneable {
else { else {
int index = 0; int index = 0;
for(byte base: Bases.instance) for(byte base: Bases.instance)
countArray[index] = get(base); countArray[index++] = counts.get(base);
} }
return countArray; return countArray;
} }
@ -98,6 +99,7 @@ public class Counts implements Cloneable {
throw new StingException("Unable to clone counts object", ex); throw new StingException("Unable to clone counts object", ex);
} }
other.counts = new HashMap<Byte,Integer>(counts); other.counts = new HashMap<Byte,Integer>(counts);
other.cumulativeCounts = new HashMap<Byte,Integer>(cumulativeCounts);
return other; return other;
} }
@ -107,10 +109,10 @@ public class Counts implements Cloneable {
*/ */
public void increment(byte base) { public void increment(byte base) {
counts.put(base,counts.get(base)+1); counts.put(base,counts.get(base)+1);
int previous = 0; boolean increment = false;
for(byte cumulative: Bases.instance) { for(byte cumulative: Bases.instance) {
cumulativeCounts.put(cumulative,counts.get(cumulative)+previous); if(increment) cumulativeCounts.put(cumulative,cumulativeCounts.get(cumulative)+1);
previous += counts.get(cumulative); increment |= (cumulative == base);
} }
} }
@ -126,9 +128,8 @@ public class Counts implements Cloneable {
} }
/** /**
* Gets a count of the number of bases of each seen type. * Gets a count of the number of bases seen before this base.
* Note that counts in this case are cumulative (counts for A,C,G,T * Note that counts in this case are cumulative.
* are independent).
* @param base Base for which to query counts. * @param base Base for which to query counts.
* @return Number of bases of this type seen. * @return Number of bases of this type seen.
*/ */