diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/GenotypingEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/GenotypingEngine.java index a2920a432..53dc4f1bd 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/GenotypingEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/GenotypingEngine.java @@ -368,7 +368,7 @@ public class GenotypingEngine { for( final Map.Entry> readEntry : haplotypeReadMapEntry.getValue().getLikelihoodReadMap().entrySet() ) { // for each read double maxLikelihood = Double.NEGATIVE_INFINITY; for( final Map.Entry alleleDoubleEntry : readEntry.getValue().entrySet() ) { // for each input allele - if( mappedHaplotypes.contains( new Haplotype(alleleDoubleEntry.getKey().getBases())) ) { // exact match of haplotype base string + if( mappedHaplotypes.contains( new Haplotype(alleleDoubleEntry.getKey())) ) { // exact match of haplotype base string maxLikelihood = Math.max( maxLikelihood, alleleDoubleEntry.getValue() ); } } @@ -442,7 +442,7 @@ public class GenotypingEngine { } // count up the co-occurrences of the events for the R^2 calculation for( final String sample : samples ) { - final double haplotypeLikelihood = LikelihoodCalculationEngine.computeDiploidHaplotypeLikelihoods( Collections.singleton(sample), haplotypeReadMap, Collections.singletonList(Allele.create(h.getBases())) )[0][0]; + final double haplotypeLikelihood = LikelihoodCalculationEngine.computeDiploidHaplotypeLikelihoods( Collections.singleton(sample), haplotypeReadMap, Collections.singletonList(Allele.create(h, true)) )[0][0]; if( thisHapVC == null ) { if( nextHapVC == null ) { x11 = MathUtils.approximateLog10SumLog10(x11, haplotypeLikelihood); } else { x12 = MathUtils.approximateLog10SumLog10(x12, haplotypeLikelihood); } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index 63aa54fa5..76ad61b77 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -125,7 +125,7 @@ public class LikelihoodCalculationEngine { final int numHaplotypes = haplotypes.size(); final Map alleleVersions = new HashMap(numHaplotypes); for ( final Haplotype haplotype : haplotypes ) { - alleleVersions.put(haplotype, Allele.create(haplotype.getBases())); + alleleVersions.put(haplotype, Allele.create(haplotype, true)); } final PerReadAlleleLikelihoodMap perReadAlleleLikelihoodMap = new PerReadAlleleLikelihoodMap(); @@ -232,7 +232,7 @@ public class LikelihoodCalculationEngine { final List bestHaplotypesIndexList = new ArrayList(); bestHaplotypesIndexList.add( findReferenceIndex(haplotypes) ); // always start with the reference haplotype final List haplotypesAsAlleles = new ArrayList(); - for( final Haplotype h : haplotypes ) { haplotypesAsAlleles.add(Allele.create(h.getBases())); } + for( final Haplotype h : haplotypes ) { haplotypesAsAlleles.add(Allele.create(h, true)); } final double[][] haplotypeLikelihoodMatrix = computeDiploidHaplotypeLikelihoods( sampleKeySet, stratifiedReadMap, haplotypesAsAlleles ); // all samples pooled together diff --git a/public/java/src/org/broadinstitute/sting/utils/Haplotype.java b/public/java/src/org/broadinstitute/sting/utils/Haplotype.java index 6e8a412c3..cdb5f8279 100644 --- a/public/java/src/org/broadinstitute/sting/utils/Haplotype.java +++ b/public/java/src/org/broadinstitute/sting/utils/Haplotype.java @@ -61,6 +61,15 @@ public class Haplotype extends Allele { this(bases, false); } + /** + * Copy constructor. Note the ref state of the provided allele is ignored! + * + * @param allele allele to copy + */ + public Haplotype( final Allele allele ) { + super(allele, true); + } + protected Haplotype( final byte[] bases, final Event artificialEvent ) { this(bases, false); this.artificialEvent = artificialEvent; @@ -94,10 +103,6 @@ public class Haplotype extends Allele { return getDisplayString(); } - public byte[] getBases() { - return super.getBases().clone(); - } - public long getStartPosition() { return genomeLocation.getStart(); } @@ -150,13 +155,15 @@ public class Haplotype extends Allele { public Haplotype insertAllele( final Allele refAllele, final Allele altAllele, final int refInsertLocation, final int genomicInsertLocation ) { // refInsertLocation is in ref haplotype offset coordinates NOT genomic coordinates final int haplotypeInsertLocation = ReadUtils.getReadCoordinateForReferenceCoordinate(alignmentStartHapwrtRef, cigar, refInsertLocation, ReadUtils.ClippingTail.RIGHT_TAIL, true); - if( haplotypeInsertLocation == -1 || haplotypeInsertLocation + refAllele.length() >= getBases().length ) { // desired change falls inside deletion so don't bother creating a new haplotype + final byte[] myBases = this.getBases(); + if( haplotypeInsertLocation == -1 || haplotypeInsertLocation + refAllele.length() >= myBases.length ) { // desired change falls inside deletion so don't bother creating a new haplotype return null; } + byte[] newHaplotypeBases = new byte[]{}; - newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(getBases(), 0, haplotypeInsertLocation)); // bases before the variant + newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(myBases, 0, haplotypeInsertLocation)); // bases before the variant newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, altAllele.getBases()); // the alt allele of the variant - newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(getBases(), haplotypeInsertLocation + refAllele.length(), getBases().length)); // bases after the variant + newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(myBases, haplotypeInsertLocation + refAllele.length(), myBases.length)); // bases after the variant return new Haplotype(newHaplotypeBases, new Event(refAllele, altAllele, genomicInsertLocation)); } @@ -199,7 +206,7 @@ public class Haplotype extends Allele { if (refAllele == null) throw new ReviewedStingException("BUG: no ref alleles in input to makeHaplotypeListfrom Alleles at loc: "+ startPos); - byte[] refBases = ref.getBases(); + final byte[] refBases = ref.getBases(); final int startIdxInReference = 1 + startPos - numPrefBases - ref.getWindow().getStart(); final String basesBeforeVariant = new String(Arrays.copyOfRange(refBases, startIdxInReference, startIdxInReference + numPrefBases)); diff --git a/settings/repository/org.broadinstitute/variant-1.84.1338.jar b/settings/repository/org.broadinstitute/variant-1.85.1357.jar similarity index 94% rename from settings/repository/org.broadinstitute/variant-1.84.1338.jar rename to settings/repository/org.broadinstitute/variant-1.85.1357.jar index 16812d569..d341e1cf5 100644 Binary files a/settings/repository/org.broadinstitute/variant-1.84.1338.jar and b/settings/repository/org.broadinstitute/variant-1.85.1357.jar differ diff --git a/settings/repository/org.broadinstitute/variant-1.84.1338.xml b/settings/repository/org.broadinstitute/variant-1.85.1357.xml similarity index 71% rename from settings/repository/org.broadinstitute/variant-1.84.1338.xml rename to settings/repository/org.broadinstitute/variant-1.85.1357.xml index dde6f560d..f6d7a2caa 100644 --- a/settings/repository/org.broadinstitute/variant-1.84.1338.xml +++ b/settings/repository/org.broadinstitute/variant-1.85.1357.xml @@ -1,3 +1,3 @@ - +