From 418fbdfbabcd61c8c3a5d5af4ef07cc29c0f7e30 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Sat, 7 Dec 2013 21:03:27 -0500 Subject: [PATCH 1/2] Added HC trio calls and NA12878 KB snapshot to resource bundle. Also, don't touch the current link until the resources are finished being produced. --- .../queue/qscripts/GATKResourcesBundle.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/public/scala/qscript/org/broadinstitute/sting/queue/qscripts/GATKResourcesBundle.scala b/public/scala/qscript/org/broadinstitute/sting/queue/qscripts/GATKResourcesBundle.scala index 307ce171f..d0c917a9e 100644 --- a/public/scala/qscript/org/broadinstitute/sting/queue/qscripts/GATKResourcesBundle.scala +++ b/public/scala/qscript/org/broadinstitute/sting/queue/qscripts/GATKResourcesBundle.scala @@ -168,11 +168,18 @@ class GATKResourcesBundle extends QScript { "Mills_and_1000G_gold_standard.indels", b37, true, false)) // - // CEU trio (NA12878,NA12891,NA12892) best practices results (including PBT) + // CEU trio (NA12878,NA12891,NA12892) best practices results // - addResource(new Resource("/humgen/gsa-hpprojects/NA12878Collection/callsets/CEUtrio_BestPractices/CEUTrio.HiSeq.WGS.b37.snps_and_indels.recalibrated.filtered.phased.CURRENT.vcf", - "CEUTrio.HiSeq.WGS.b37.bestPractices.phased",b37,true,false)) + addResource(new Resource("/humgen/1kg/processing/production_wgs_final/trio/CEU/CEU.wgs.HaplotypeCaller.20131118.snps_indels.high_coverage_pcr_free.genotypes.vcf", + "CEUTrio.HiSeq.WGS.b37.bestPractices",b37,true,false)) + + // + // NA12878 knowledgebase snapshot + // + + addResource(new Resource("/humgen/gsa-hpprojects/NA12878Collection/knowledgeBase/snapshots/NA12878.wgs.broad_truth_set.20131119.snps_and_indels.genotypes.vcf", + "NA12878.knowledgebase.snapshot.20131119",b37,true,false)) // // example call set for documentation guide tutorial @@ -290,9 +297,8 @@ class GATKResourcesBundle extends QScript { } } - createCurrentLink(BUNDLE_DIR) - } else { + createCurrentLink(BUNDLE_DIR) createBundleDirectories(DOWNLOAD_DIR) createDownloadsFromBundle(BUNDLE_DIR, DOWNLOAD_DIR) } From 400e7c14048ae3c408d7d8ac704982f5f9d0f429 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Sat, 7 Dec 2013 22:07:22 -0500 Subject: [PATCH 2/2] Fixed bug in the filtering of lifted over variants where a deletion at the end of a contig could cause it to error out. Added a unit test. --- .../variantutils/FilterLiftedVariants.java | 41 +++++++++----- .../FilterLiftedVariantsUnitTest.java | 54 +++++++++++++++++++ 2 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariantsUnitTest.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java index d26ab08f7..2b18eda20 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java @@ -77,32 +77,49 @@ public class FilterLiftedVariants extends RodWalker { writer.writeHeader(vcfHeader); } - private void filterAndWrite(byte[] ref, VariantContext vc) { + /** + * Determines whether records should be filtered; if not, writes them to the output + * + * @param ref the reference context + * @param vc the VariantContext to process + * @return true if the record is not filtered, false otherwise + */ + protected boolean filterOrWrite(final byte[] ref, final VariantContext vc) { + if ( ref == null ) throw new IllegalArgumentException("Cannot filter based on a null reference array"); + if ( vc == null ) throw new IllegalArgumentException("Cannot filter a null Variant Context"); totalLocs++; - boolean failed = false; - byte[] recordRef = vc.getReference().getBases(); - for (int i = 0; i < recordRef.length && i < MAX_VARIANT_SIZE; i++) { - if ( recordRef[i] != ref[i] ) { - failed = true; - break; + boolean filter = false; + final byte[] recordRef = vc.getReference().getBases(); + + // this can happen for records that get placed at the ends of chromosomes + if ( recordRef.length > ref.length ) { + filter = true; + } else { + for (int i = 0; i < recordRef.length && i < MAX_VARIANT_SIZE; i++) { + if ( recordRef[i] != ref[i] ) { + filter = true; + break; + } } } - if ( failed ) + if ( filter ) failedLocs++; else writer.add(vc); + + return !filter; } public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); - for ( VariantContext vc : VCs ) - filterAndWrite(ref.getBases(), vc); + final Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); + for ( final VariantContext vc : VCs ) + filterOrWrite(ref.getBases(), vc); return 0; } @@ -114,4 +131,4 @@ public class FilterLiftedVariants extends RodWalker { public void onTraversalDone(Integer result) { System.out.println("Filtered " + failedLocs + " records out of " + totalLocs + " total records."); } -} \ No newline at end of file +} diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariantsUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariantsUnitTest.java new file mode 100644 index 000000000..83d571748 --- /dev/null +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariantsUnitTest.java @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2012 The Broad Institute +* +* Permission is hereby granted, free of charge, to any person +* obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, +* copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following +* conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +* THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +package org.broadinstitute.sting.gatk.walkers.variantutils; + +import org.broadinstitute.sting.BaseTest; +import org.broadinstitute.variant.variantcontext.Allele; +import org.broadinstitute.variant.variantcontext.VariantContext; +import org.broadinstitute.variant.variantcontext.VariantContextBuilder; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + + +public class FilterLiftedVariantsUnitTest extends BaseTest { + + @Test + public void testIndelAtEndOfContig() { + + final List alleles = new ArrayList<>(2); + alleles.add(Allele.create("AAAAA", true)); + alleles.add(Allele.create("A", false)); + final VariantContext vc = new VariantContextBuilder("test", "1", 10, 14, alleles).make(); + + final FilterLiftedVariants filter = new FilterLiftedVariants(); + + Assert.assertFalse(filter.filterOrWrite(new byte[]{'A'}, vc)); + } + +}