From 205fc0b63664531e264f8da0ad76a8d41eb9c8f5 Mon Sep 17 00:00:00 2001 From: delangel Date: Mon, 20 Sep 2010 19:53:30 +0000 Subject: [PATCH] Cleanup: Use Tribble's version of createVariantContextWithPaddedAlleles (no real functional difference) to avoid duplicated code. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4315 348d0f76-0448-11de-a6fe-93d51630548a --- .../variantcontext/VariantContextUtils.java | 73 +------------------ 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java index 98df3e159..a9f716f37 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java @@ -293,9 +293,8 @@ public class VariantContextUtils { for (VariantContext vc : prepaddedVCs) { // also a reasonable place to remove filtered calls, if needed if ( ! filteredAreUncalled || vc.isNotFiltered() ) - VCs.add(createVariantContextWithPaddedAlleles(vc,inputRefBase)); + VCs.add(VariantContext.createVariantContextWithPaddedAlleles(vc,inputRefBase,false)); } - if ( VCs.size() == 0 ) // everything is filtered out and we're filteredareUncalled return null; @@ -564,76 +563,6 @@ public class VariantContextUtils { } - public static VariantContext createVariantContextWithPaddedAlleles(VariantContext inputVC, byte inputRefBase) { - Allele refAllele = inputVC.getReference(); - - - // see if we need to pad common reference base from all alleles - boolean padVC; - - // We need to pad a VC with a common base if the reference allele length is less than the vc location span. - long locLength = getLocation(inputVC).size(); - if (refAllele.length() == locLength) - padVC = false; - else if (refAllele.length() == locLength-1) - padVC = true; - else throw new ReviewedStingException("Badly formed variant context, reference length must be at most one base shorter than location size"); - - - // nothing to do if we don't need to pad bases - if (padVC) { - Byte refByte; - - Map attributes = inputVC.getAttributes(); - - if (BaseUtils.isRegularBase(inputRefBase)) - refByte = inputRefBase; - else if (attributes.containsKey(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY)) - refByte = (Byte)attributes.get(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY); - else - throw new ReviewedStingException("Error when trying to pad Variant Context: either input reference base must be a regular base, or input VC must contain reference base key"); - - List alleles = new ArrayList(); - Map genotypes = new TreeMap(); - - Map inputGenotypes = inputVC.getGenotypes(); - - for (Allele a : inputVC.getAlleles()) { - // get bases for current allele and create a new one with trimmed bases - String newBases = new String(new byte[]{refByte}) + a.getBaseString(); - alleles.add(Allele.create(newBases,a.isReference())); - } - - // now we can recreate new genotypes with trimmed alleles - for (String sample : inputVC.getSampleNames()) { - Genotype g = inputGenotypes.get(sample); - - List inAlleles = g.getAlleles(); - List newGenotypeAlleles = new ArrayList(); - for (Allele a : inAlleles) { - if (a.isCalled()) { - String newBases = new String(new byte[]{refByte}) + a.getBaseString(); - newGenotypeAlleles.add(Allele.create(newBases,a.isReference())); - } - else { - // add no-call allele - newGenotypeAlleles.add(Allele.NO_CALL); - } - } - genotypes.put(sample, new Genotype(sample, newGenotypeAlleles, g.getNegLog10PError(), - g.getFilters(),g.getAttributes(),g.genotypesArePhased())); - - } - return new VariantContext(inputVC.getName(), inputVC.getChr(), inputVC.getStart(), inputVC.getEnd(), alleles, genotypes, inputVC.getNegLog10PError(), - inputVC.getFilters(), attributes); - - - - } - else - return inputVC; - - } static class CompareByPriority implements Comparator, Serializable { List priorityListOfVCs;