Need to use ints for quals in HaplotypeScore instead of bytes because of overflow (they are summed when haplotypes are combined)
This commit is contained in:
parent
79bc818022
commit
dbb69a1e10
|
|
@ -216,14 +216,14 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
||||||
final Haplotype haplotype1 = consensusHaplotypeQueue.poll();
|
final Haplotype haplotype1 = consensusHaplotypeQueue.poll();
|
||||||
|
|
||||||
List<Haplotype> hlist = new ArrayList<Haplotype>();
|
List<Haplotype> hlist = new ArrayList<Haplotype>();
|
||||||
hlist.add(new Haplotype(haplotype1.getBases(), (byte)60));
|
hlist.add(new Haplotype(haplotype1.getBases(), 60));
|
||||||
|
|
||||||
for (int k = 1; k < haplotypesToCompute; k++) {
|
for (int k = 1; k < haplotypesToCompute; k++) {
|
||||||
Haplotype haplotype2 = consensusHaplotypeQueue.poll();
|
Haplotype haplotype2 = consensusHaplotypeQueue.poll();
|
||||||
if (haplotype2 == null) {
|
if (haplotype2 == null) {
|
||||||
haplotype2 = haplotype1;
|
haplotype2 = haplotype1;
|
||||||
} // Sometimes only the reference haplotype can be found
|
} // Sometimes only the reference haplotype can be found
|
||||||
hlist.add(new Haplotype(haplotype2.getBases(), (byte)20));
|
hlist.add(new Haplotype(haplotype2.getBases(), 20));
|
||||||
}
|
}
|
||||||
return hlist;
|
return hlist;
|
||||||
} else
|
} else
|
||||||
|
|
@ -285,10 +285,10 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
||||||
|
|
||||||
final int length = a.length;
|
final int length = a.length;
|
||||||
final byte[] consensusChars = new byte[length];
|
final byte[] consensusChars = new byte[length];
|
||||||
final byte[] consensusQuals = new byte[length];
|
final int[] consensusQuals = new int[length];
|
||||||
|
|
||||||
final byte[] qualsA = haplotypeA.getQuals();
|
final int[] qualsA = haplotypeA.getQuals();
|
||||||
final byte[] qualsB = haplotypeB.getQuals();
|
final int[] qualsB = haplotypeB.getQuals();
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
chA = a[i];
|
chA = a[i];
|
||||||
|
|
@ -308,7 +308,7 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
||||||
consensusQuals[i] = qualsA[i];
|
consensusQuals[i] = qualsA[i];
|
||||||
} else {
|
} else {
|
||||||
consensusChars[i] = chA;
|
consensusChars[i] = chA;
|
||||||
consensusQuals[i] = (byte)((int)qualsA[i] + (int)qualsB[i]);
|
consensusQuals[i] = qualsA[i] + qualsB[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,31 +442,38 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
||||||
|
|
||||||
private static class Haplotype {
|
private static class Haplotype {
|
||||||
private final byte[] bases;
|
private final byte[] bases;
|
||||||
private final byte[] quals;
|
private final int[] quals;
|
||||||
private int qualitySum = -1;
|
private int qualitySum = -1;
|
||||||
|
|
||||||
public Haplotype( final byte[] bases, final byte[] quals ) {
|
public Haplotype( final byte[] bases, final int[] quals ) {
|
||||||
this.bases = bases;
|
this.bases = bases;
|
||||||
this.quals = quals;
|
this.quals = quals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Haplotype( final byte[] bases, final byte qual ) {
|
public Haplotype( final byte[] bases, final int qual ) {
|
||||||
this.bases = bases;
|
this.bases = bases;
|
||||||
quals = new byte[bases.length];
|
quals = new int[bases.length];
|
||||||
Arrays.fill(quals, qual);
|
Arrays.fill(quals, qual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Haplotype( final byte[] bases, final byte[] quals ) {
|
||||||
|
this.bases = bases;
|
||||||
|
this.quals = new int[quals.length];
|
||||||
|
for ( int i = 0 ; i < quals.length; i++ )
|
||||||
|
this.quals[i] = (int)quals[i];
|
||||||
|
}
|
||||||
|
|
||||||
public double getQualitySum() {
|
public double getQualitySum() {
|
||||||
if ( qualitySum == -1 ) {
|
if ( qualitySum == -1 ) {
|
||||||
qualitySum = 0;
|
qualitySum = 0;
|
||||||
for ( final byte qual : quals ) {
|
for ( final int qual : quals ) {
|
||||||
qualitySum += (int)qual;
|
qualitySum += qual;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return qualitySum;
|
return qualitySum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getQuals() {
|
public int[] getQuals() {
|
||||||
return quals.clone();
|
return quals.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue