diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java deleted file mode 100755 index d7f4f6ca8..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2010, 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.genotyper; - -import org.broad.tribble.util.variantcontext.VariantContext; -import org.broad.tribble.vcf.VCFWriter; -import org.broadinstitute.sting.gatk.contexts.*; -import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils; -import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.*; -import org.broadinstitute.sting.commandline.*; -import org.broadinstitute.sting.utils.pileup.PileupElement; -import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; -import org.broadinstitute.sting.utils.pileup.ReadBackedPileupImpl; -import org.broadinstitute.sting.utils.SampleUtils; -import org.broadinstitute.sting.utils.vcf.VCFUtils; -import org.broad.tribble.vcf.VCFHeaderLine; -import org.broad.tribble.vcf.VCFHeader; - -import java.util.*; - -import net.sf.samtools.SAMReadGroupRecord; - - -/** - * A walker that merges multiple batches of calls, by calling into the Genotyper to fill in sites that - * were called in one batch but not another. - */ -@Reference(window=@Window(start=-20,stop=20)) -@By(DataSource.REFERENCE) -@Requires(value={},referenceMetaData=@RMD(name="trigger", type=VariantContext.class)) -public class BatchedCallsMerger extends LocusWalker implements TreeReducible { - @ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection(); - - @Output(doc = "VCF file to which variants should be written", required = true) - public VCFWriter writer = null; - - @Argument(fullName="rod_list", shortName="rods", doc="A comma-separated string describing the rod names representing individual call batches", required=true) - protected String ROD_STRING = null; - private HashSet targetRods; - - // the calculation arguments - private UnifiedGenotyperEngine UG_engine = null; - - // mapping from rod name to set of samples coming from it - private Map> rodsToSamples = new HashMap>(); - - // enable deletions in the pileup - public boolean includeReadsWithDeletionAtLoci() { return true; } - - // enable extended events for indels - public boolean generateExtendedEvents() { return UAC.GLmodel == GenotypeLikelihoodsCalculationModel.Model.DINDEL; } - - public void initialize() { - - targetRods = new HashSet(Arrays.asList(ROD_STRING.split(","))); - - Set headerLines = new HashSet(); - - // get all of the sample names and meta data - Map headers = VCFUtils.getVCFHeadersFromRods(getToolkit(), targetRods); - Set samples = SampleUtils.getSampleList(headers); - for ( String rodName : headers.keySet() ) { - VCFHeader header = headers.get(rodName); - headerLines.addAll(header.getMetaData()); - HashSet mySamples = new HashSet(header.getGenotypeSamples()); - rodsToSamples.put(rodName, mySamples); - } - - // update the engine - UG_engine = new UnifiedGenotyperEngine(getToolkit(), UAC, logger, null, null, samples); - - // initialize the header - writer.writeHeader(new VCFHeader(headerLines, samples)); - } - - public VariantContext map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { - if ( tracker == null ) - return null; - - // get the calls at this locus - Collection VCs = tracker.getAllVariantContexts(ref, null, context.getLocation(), true, false); - - Set calls = new HashSet(); - Set seenRods = new HashSet(); - for ( VariantContext vc : VCs ) { - if ( targetRods.contains(vc.getSource()) ) { - calls.add(vc); - seenRods.add(vc.getSource()); - } - } - - // if there are no calls, ignore this site - if ( seenRods.size() == 0 ) - return null; - - // figure out which samples still need to be called - Set missedSamples = new HashSet(); - for ( String rod : targetRods ) { - if ( !seenRods.contains(rod) ) - missedSamples.addAll(rodsToSamples.get(rod)); - } - - // we are missing samples, call them - if ( missedSamples.size() > 0 ) { - AlignmentContext prunedContext = filterForSamples(context.getBasePileup(), missedSamples); - VariantCallContext vcc = UG_engine.calculateLikelihoodsAndGenotypes(tracker, ref, prunedContext); - if ( vcc != null && vcc.vc != null ) - calls.add(vcc.vc); - } - - // merge the variant contexts - return VariantContextUtils.simpleMerge(getToolkit().getGenomeLocParser(), calls, ref.getBase()); - } - - public static AlignmentContext filterForSamples(ReadBackedPileup pileup, Set samples) { - - ArrayList newPileup = new ArrayList(); - - for (PileupElement p : pileup ) { - SAMReadGroupRecord readGroup = p.getRead().getReadGroup(); - if ( readGroup != null && samples.contains(readGroup.getSample()) ) - newPileup.add(p); - } - return new AlignmentContext(pileup.getLocation(), new ReadBackedPileupImpl(pileup.getLocation(), newPileup)); - - } - - public Integer reduceInit() { return 0; } - - public Integer treeReduce(Integer lhs, Integer rhs) { - return lhs + rhs; - } - - public Integer reduce(VariantContext value, Integer sum) { - // can't call the locus because of no coverage or no confidence - if ( value == null ) - return sum; - - try { - writer.add(value, value.getReference().getBases()[0]); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException(e.getMessage() + "; this is often caused by using the --assume_single_sample_reads argument with the wrong sample name"); - } - - return sum; - } - - public void onTraversalDone(Integer sum) {} -} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/CreateTriggerTrack.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/CreateTriggerTrack.java deleted file mode 100755 index 97a69deb7..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/CreateTriggerTrack.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2010, 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.genotyper; - -import org.broad.tribble.util.variantcontext.VariantContext; -import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.*; -import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.AlignmentContext; -import org.broadinstitute.sting.commandline.Output; - -import java.util.Collection; -import java.io.PrintWriter; - -/** - * Creates a bed-format trigger-track for the Unified Genotyper based on input variant files. - */ -public class CreateTriggerTrack extends RodWalker { - @Output - private PrintWriter writer; - - public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { - if ( tracker == null ) - return 0; - - Collection VCs = tracker.getAllVariantContexts(ref); - if ( VCs.size() > 0 ) - writer.println(context.getLocation().getContig() + "\t" + (context.getLocation().getStart()-1) + "\t" + context.getLocation().getStart()); - - return 0; - } - - public Integer reduceInit() { return 0; } - - public Integer reduce(Integer value, Integer sum) { return 0; } - - public void onTraversalDone(Integer result) { - writer.close(); - } -} \ No newline at end of file