diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java index c2cbf23fb..7d39dc789 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/vcf/AbstractVCFCodec.java @@ -642,7 +642,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec { boolean stillClipping = true; while ( stillClipping ) { - for ( Allele a : unclippedAlleles ) { + for ( final Allele a : unclippedAlleles ) { if ( a.isSymbolic() ) continue; diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java index dff214e23..3faad46e2 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java @@ -160,7 +160,7 @@ import java.util.*; * * @author depristo */ -public class VariantContext implements Feature { // to enable tribble intergration +public class VariantContext implements Feature { // to enable tribble integration protected CommonInfo commonInfo = null; public final static double NO_LOG10_PERROR = CommonInfo.NO_LOG10_PERROR; @@ -377,7 +377,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati * * Not currently supported: * - * Heterozygous sequencea + * Heterozygous sequence * The term heterozygous is used to specify a region detected by certain methods that do not * resolve the polymorphism into a specific sequence motif. In these cases, a unique flanking * sequence must be provided to define a sequence context for the variation. diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java index a1926956d..85ba71f1a 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextUtils.java @@ -620,8 +620,8 @@ public class VariantContextUtils { String key = p.getKey(); // if we don't like the key already, don't go anywhere if ( ! inconsistentAttributes.contains(key) ) { - boolean alreadyFound = attributes.containsKey(key); - Object boundValue = attributes.get(key); + final boolean alreadyFound = attributes.containsKey(key); + final Object boundValue = attributes.get(key); final boolean boundIsMissingValue = alreadyFound && boundValue.equals(VCFConstants.MISSING_VALUE_v4); if ( alreadyFound && ! boundValue.equals(p.getValue()) && ! boundIsMissingValue ) { @@ -802,17 +802,16 @@ public class VariantContextUtils { return inputVC; } - public static VariantContext reverseTrimAlleles(VariantContext inputVC) { + public static VariantContext reverseTrimAlleles( final VariantContext inputVC ) { // see if we need to trim common reference base from all alleles final int trimExtent = AbstractVCFCodec.computeReverseClipping(inputVC.getAlleles(), inputVC.getReference().getDisplayString().getBytes(), 0, true, -1); - if ( trimExtent <= 0 ) - return inputVC; + if ( trimExtent <= 0 || inputVC.getAlleles().size() <= 1 ) + return inputVC; final List alleles = new ArrayList(); - GenotypesContext genotypes = GenotypesContext.create(); - - Map originalToTrimmedAlleleMap = new HashMap(); + final GenotypesContext genotypes = GenotypesContext.create(); + final Map originalToTrimmedAlleleMap = new HashMap(); for (final Allele a : inputVC.getAlleles()) { if (a.isSymbolic()) { @@ -820,8 +819,8 @@ public class VariantContextUtils { originalToTrimmedAlleleMap.put(a, a); } else { // get bases for current allele and create a new one with trimmed bases - byte[] newBases = Arrays.copyOfRange(a.getBases(), 0, a.length()-trimExtent); - Allele trimmedAllele = Allele.create(newBases, a.isReference()); + final byte[] newBases = Arrays.copyOfRange(a.getBases(), 0, a.length()-trimExtent); + final Allele trimmedAllele = Allele.create(newBases, a.isReference()); alleles.add(trimmedAllele); originalToTrimmedAlleleMap.put(a, trimmedAllele); } @@ -829,9 +828,8 @@ public class VariantContextUtils { // now we can recreate new genotypes with trimmed alleles for ( final Genotype genotype : inputVC.getGenotypes() ) { - - List originalAlleles = genotype.getAlleles(); - List trimmedAlleles = new ArrayList(); + final List originalAlleles = genotype.getAlleles(); + final List trimmedAlleles = new ArrayList(); for ( final Allele a : originalAlleles ) { if ( a.isCalled() ) trimmedAlleles.add(originalToTrimmedAlleleMap.get(a)); @@ -841,8 +839,7 @@ public class VariantContextUtils { genotypes.add(Genotype.modifyAlleles(genotype, trimmedAlleles)); } - final VariantContextBuilder builder = new VariantContextBuilder(inputVC).stop(inputVC.getStart() + alleles.get(0).length()); - return builder.alleles(alleles).genotypes(genotypes).make(); + return new VariantContextBuilder(inputVC).stop(inputVC.getEnd() - trimExtent).alleles(alleles).genotypes(genotypes).make(); } public static GenotypesContext stripPLs(GenotypesContext genotypes) {