package org.broadinstitute.sting.playground.gatk.walkers; import net.sf.samtools.SAMRecord; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.Genotype; import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.VariationRod; import org.broadinstitute.sting.gatk.refdata.rodDbSNP; import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyper; import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * Implements a rudimentary algorithm for calling SNPs that are de novo in that they appear in an individual but not in * its parents. */ @By(DataSource.REFERENCE) @Requires(value={DataSource.REFERENCE, DataSource.REFERENCE_BASES, DataSource.READS},referenceMetaData={@RMD(name="child",type= VariationRod.class)}) @Allows({DataSource.READS, DataSource.REFERENCE}) @ReadFilters(ZeroMappingQualityReadFilter.class) //, @RMD(name="parent1",type= VariationRod.class), @RMD(name="parent2",type= VariationRod.class)}) public class DeNovoSNPWalker extends RefWalker{ /** * Implements a rudimentary algorithm for calling SNPs that are de novo in that they appear in an individual but not in * its parents. Using BAM files corresponding to parents and child, it calls UnifiedGenotyper directly and outputs a * confidence for positions being de novo SNPs. * */ UnifiedGenotyper UG; private List> readGroupSets; public void initialize() { UG = new UnifiedGenotyper(); UG.initialize(); readGroupSets = getToolkit().getMergedReadGroupsByReaders(); } public String map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { VariationRod child = tracker.lookup("child",VariationRod.class); VariationRod dbsnp = tracker.lookup(rodDbSNP.STANDARD_DBSNP_TRACK_NAME,VariationRod.class); if (child != null) { if (child.isSNP() && child.getNegLog10PError() > 5) { // BTR > 5 List reads = context.getReads(); List offsets = context.getOffsets(); List parent1_reads = new ArrayList(); List parent2_reads = new ArrayList(); List parent1_offsets = new ArrayList(); List parent2_offsets = new ArrayList(); assert( reads.size() == offsets.size() ); // should be same number or we're in trouble int num_reads = reads.size(); for (int i=0; i 5 && !parent2call.isHomRef() && parent2call.getNegLog10PError() > 5) { double sumConfidences = 0.5 * (0.5 * child.getNegLog10PError() + Math.min(parent1call.getNegLog10PError(), parent2call.getNegLog10PError())); out.format("%s\t", child.getLocation().getContig()); out.format("%s\t", child.getLocation().getStart()); out.format("%.4f\t", sumConfidences); out.format("%.4f\t", child.getNegLog10PError()); out.format("%.4f\t", parent1call.getNegLog10PError()); out.format("%.4f\t", parent2call.getNegLog10PError()); out.format("%s\t", dbsnp != null); out.format ("%s\t", child.toString()); out.format ("%s\t", parent1.toString()); out.format ("%s", parent2.toString()); if (dbsnp != null) out.format ("\tDBSNP\t:%s", dbsnp.toString()); out.println(); } } } } return ""; } public Integer reduceInit() { return 0; } public Integer reduce(String line, Integer a) { return 1; } public void onTraversalDone(Integer result) {} // Don't print the reduce result }