Merge pull request #448 from broadinstitute/eb_add_stuff_to_the_bundle

Eb add stuff to the bundle
This commit is contained in:
Bertrand 2013-12-12 07:31:59 -08:00
commit d6169a28cd
3 changed files with 94 additions and 17 deletions

View File

@ -77,32 +77,49 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
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<VariantContext> VCs = tracker.getValues(variantCollection.variants, context.getLocation());
for ( VariantContext vc : VCs )
filterAndWrite(ref.getBases(), vc);
final Collection<VariantContext> 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<Integer, Integer> {
public void onTraversalDone(Integer result) {
System.out.println("Filtered " + failedLocs + " records out of " + totalLocs + " total records.");
}
}
}

View File

@ -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<Allele> 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));
}
}

View File

@ -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)
}