Now properly extending candidate haplotypes with bases from the reference context instead of filling with padding bases. Functionality in the private Haplotype class is no longer necessary so removing it. No need to have four different Haplotype classes in the GATK.
This commit is contained in:
parent
888d3b4fdc
commit
611a395783
|
|
@ -180,12 +180,12 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
|||
final Haplotype haplotype1 = consensusHaplotypeQueue.poll();
|
||||
|
||||
List<Haplotype>hlist = new ArrayList<Haplotype>();
|
||||
hlist.add(new Haplotype(haplotype1.getBasesAsBytes(), 60));
|
||||
hlist.add(new Haplotype(haplotype1.getBases(), 60));
|
||||
|
||||
for (int k=1; k < haplotypesToCompute; k++) {
|
||||
Haplotype haplotype2 = consensusHaplotypeQueue.poll();
|
||||
if(haplotype2 == null ) { haplotype2 = haplotype1; } // Sometimes only the reference haplotype can be found
|
||||
hlist.add(new Haplotype(haplotype2.getBasesAsBytes(), 20));
|
||||
hlist.add(new Haplotype(haplotype2.getBases(), 20));
|
||||
}
|
||||
return hlist;
|
||||
} else
|
||||
|
|
@ -229,8 +229,8 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
|||
}
|
||||
|
||||
private Haplotype getConsensusHaplotype(final Haplotype haplotypeA, final Haplotype haplotypeB) {
|
||||
final byte[] a = haplotypeA.getBasesAsBytes();
|
||||
final byte[] b = haplotypeB.getBasesAsBytes();
|
||||
final byte[] a = haplotypeA.getBases();
|
||||
final byte[] b = haplotypeB.getBases();
|
||||
|
||||
if (a.length != b.length) {
|
||||
throw new ReviewedStingException("Haplotypes a and b must be of same length");
|
||||
|
|
@ -313,7 +313,7 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
|
|||
// actually be a miscall in a matching direction, which would happen at a e / 3 rate. If b != c, then
|
||||
// the chance that it is actually a mismatch is 1 - e, since any of the other 3 options would be a mismatch.
|
||||
// so the probability-weighted mismatch rate is sum_i ( matched ? e_i / 3 : 1 - e_i ) for i = 1 ... n
|
||||
final byte[] haplotypeBases = haplotype.getBasesAsBytes();
|
||||
final byte[] haplotypeBases = haplotype.getBases();
|
||||
final SAMRecord read = p.getRead();
|
||||
byte[] readBases = read.getReadBases();
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ public class HaplotypeIndelErrorModel {
|
|||
|
||||
byte haplotypeBase;
|
||||
if (haplotypeIndex < RIGHT_ALIGN_INDEX)
|
||||
haplotypeBase = haplotype.getBasesAsBytes()[haplotypeIndex];
|
||||
haplotypeBase = haplotype.getBases()[haplotypeIndex];
|
||||
else
|
||||
haplotypeBase = (byte)0; // dummy
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ public class HaplotypeIndelErrorModel {
|
|||
if (readQual > 3)
|
||||
pRead += pBaseRead;
|
||||
haplotypeIndex++;
|
||||
if (haplotypeIndex >= haplotype.getBasesAsBytes().length)
|
||||
if (haplotypeIndex >= haplotype.getBases().length)
|
||||
haplotypeIndex = RIGHT_ALIGN_INDEX;
|
||||
//System.out.format("H:%c R:%c RQ:%d HI:%d %4.5f %4.5f\n", haplotypeBase, readBase, (int)readQual, haplotypeIndex, pBaseRead, pRead);
|
||||
}
|
||||
|
|
@ -227,8 +227,8 @@ public class HaplotypeIndelErrorModel {
|
|||
System.out.println(read.getReadName());
|
||||
System.out.print("Haplotype:");
|
||||
|
||||
for (int k=0; k <haplotype.getBasesAsBytes().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBasesAsBytes()[k]);
|
||||
for (int k=0; k <haplotype.getBases().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBases()[k]);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
|
|
@ -246,8 +246,8 @@ public class HaplotypeIndelErrorModel {
|
|||
|
||||
System.out.println("Haplotype:");
|
||||
|
||||
for (int k=initialIndexInHaplotype; k <haplotype.getBasesAsBytes().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBasesAsBytes()[k]);
|
||||
for (int k=initialIndexInHaplotype; k <haplotype.getBases().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBases()[k]);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ public class HaplotypeIndelErrorModel {
|
|||
|
||||
byte haplotypeBase;
|
||||
if (indX > LEFT_ALIGN_INDEX && indX < RIGHT_ALIGN_INDEX)
|
||||
haplotypeBase = haplotype.getBasesAsBytes()[indX-1];
|
||||
haplotypeBase = haplotype.getBases()[indX-1];
|
||||
else
|
||||
haplotypeBase = readBase;
|
||||
|
||||
|
|
@ -296,8 +296,8 @@ public class HaplotypeIndelErrorModel {
|
|||
System.out.println(read.getReadName());
|
||||
System.out.print("Haplotype:");
|
||||
|
||||
for (int k=0; k <haplotype.getBasesAsBytes().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBasesAsBytes()[k]);
|
||||
for (int k=0; k <haplotype.getBases().length; k++) {
|
||||
System.out.format("%c ", haplotype.getBases()[k]);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ public class PairHMMIndelErrorModel {
|
|||
// todo -- refactor into separate function
|
||||
for (Allele a: haplotypeMap.keySet()) {
|
||||
Haplotype haplotype = haplotypeMap.get(a);
|
||||
byte[] haplotypeBases = haplotype.getBasesAsBytes();
|
||||
byte[] haplotypeBases = haplotype.getBases();
|
||||
double[] contextLogGapOpenProbabilities = new double[haplotypeBases.length];
|
||||
double[] contextLogGapContinuationProbabilities = new double[haplotypeBases.length];
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ public class PairHMMIndelErrorModel {
|
|||
long indStart = start - haplotype.getStartPosition();
|
||||
long indStop = stop - haplotype.getStartPosition();
|
||||
|
||||
byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBasesAsBytes(),
|
||||
byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBases(),
|
||||
(int)indStart, (int)indStop);
|
||||
|
||||
double readLikelihood;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
|
||||
public class Haplotype {
|
||||
protected byte[] bases = null;
|
||||
protected double[] quals = null;
|
||||
protected final byte[] bases;
|
||||
protected final double[] quals;
|
||||
private GenomeLoc genomeLocation = null;
|
||||
private boolean isReference = false;
|
||||
|
||||
|
|
@ -69,6 +69,11 @@ public class Haplotype {
|
|||
this.isReference = isRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object h ) {
|
||||
return h instanceof Haplotype && Arrays.equals(bases, ((Haplotype) h).bases);
|
||||
}
|
||||
|
||||
public double getQualitySum() {
|
||||
double s = 0;
|
||||
for (int k=0; k < bases.length; k++) {
|
||||
|
|
@ -88,7 +93,7 @@ public class Haplotype {
|
|||
public double[] getQuals() {
|
||||
return quals;
|
||||
}
|
||||
public byte[] getBasesAsBytes() {
|
||||
public byte[] getBases() {
|
||||
return bases;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +105,6 @@ public class Haplotype {
|
|||
return genomeLocation.getStop();
|
||||
}
|
||||
|
||||
|
||||
public boolean isReference() {
|
||||
return isReference;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue