@@ -0,0 +1,2059 @@
+%0Apackage org.broadinstitute.sting.playground.gatk.walkers;%0A%0Aimport net.sf.samtools.SAMFileHeader;%0Aimport net.sf.samtools.SAMReadGroupRecord;%0Aimport net.sf.samtools.SAMRecord;%0Aimport org.broadinstitute.sting.gatk.GenomeAnalysisEngine;%0Aimport org.broadinstitute.sting.gatk.LocusContext;%0Aimport org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;%0Aimport org.broadinstitute.sting.gatk.walkers.LocusWalker;%0Aimport org.broadinstitute.sting.playground.utils.AlleleFrequencyEstimate;%0Aimport org.broadinstitute.sting.playground.utils.*;%0Aimport org.broadinstitute.sting.utils.*;%0Aimport org.broadinstitute.sting.utils.ReadBackedPileup;%0Aimport org.broadinstitute.sting.utils.cmdLine.Argument;%0A%0Aimport java.util.*;%0Aimport java.util.zip.*;%0Aimport java.io.*;%0A%0A// Plot a histogram of depth of coverage%0A// j.maguire 6-11-2009%0A%0Apublic class CoverageHistogram extends LocusWalker%3CInteger,Integer%3E%0A%7B%0A%09//@Argument(fullName=%22start%22, shortName=%22start%22, required=false, doc=%22start%22) public Integer START = 0;%0A%0A%09// Private state.%0A%09int%5B%5D coverage_hist;%0A%09int max_depth;%0A%0A%09long sum_coverage;%0A%09long num_sites;%0A%0A%09/////////%0A%09// Walker Interface Functions %0A    public void initialize() %0A%09%7B%0A%09%09coverage_hist = new int%5B1000000%5D;%0A%09%09max_depth = 0;%0A%0A%09%09sum_coverage = 0;%0A%09%09num_sites = 0;%0A%09%7D%0A%0A    public Integer map(RefMetaDataTracker tracker, char ref, LocusContext context) %0A%09%7B%0A%09%09if (ref == 'N') %7B return null; %7D%0A%09%09int depth = context.getReads().size();%0A%09%09coverage_hist%5Bdepth%5D += 1;%0A%09%09if (depth %3E max_depth) %7B max_depth = depth; %7D%0A%0A%09%09sum_coverage += depth;%0A%09%09num_sites += 1;%0A%0A%09%09return 0;%0A%09%7D%0A%0A    public void onTraversalDone(Integer sum) %0A%09%7B%0A%09%09double mean_coverage = (double)sum_coverage / (double)num_sites;%0A%09%09out.printf(%22# mean:%25f num_sites:%25d%5Cn%5Cn%22, mean_coverage, num_sites);%0A%0A%09%09out.println(%22depth count%22);%0A%09%09for (int i = 0; i %3C max_depth; i++)%0A%09%09%7B%0A%09%09%09out.printf(%22%25d %25d%5Cn%22, i, coverage_hist%5Bi%5D);%0A%09%09%7D%0A%09%09return;%0A%09%7D%0A%0A    public Integer reduceInit() %0A%09%7B%0A%09%09return 0;%0A%09%7D%0A%0A    public Integer reduce(Integer record, Integer sum) %0A%09%7B%0A%09%09return 0;%0A%09%7D%0A%0A%09// END Walker Interface Functions%0A%09/////////%0A%7D%0A

Compute a simple histogram of depth of coverage.