From 82b4798913e29f3c77570751981d85513d76a228 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Mon, 23 Apr 2012 17:24:22 -0400 Subject: [PATCH] CountBasesWalker -- a quick QC walker. --- .../gatk/walkers/qc/CountBasesWalker.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountBasesWalker.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountBasesWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountBasesWalker.java new file mode 100755 index 000000000..b846ce6b0 --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountBasesWalker.java @@ -0,0 +1,51 @@ +package org.broadinstitute.sting.gatk.walkers.qc; + +import org.broadinstitute.sting.gatk.contexts.ReferenceContext; +import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; +import org.broadinstitute.sting.gatk.walkers.DataSource; +import org.broadinstitute.sting.gatk.walkers.ReadWalker; +import org.broadinstitute.sting.gatk.walkers.Requires; +import org.broadinstitute.sting.utils.sam.GATKSAMRecord; + +/** + * Walks over the input data set, calculating the number of reads seen for diagnostic purposes. + * + *

+ * Can also count the number of reads matching a given criterion using read filters (see the + * --read-filter command line argument). Simplest example of a read-backed analysis. + * + * + *

Input

+ *

+ * One or more BAM files. + *

+ * + *

Output

+ *

+ * Number of reads seen. + *

+ * + *

Examples

+ *
+ * java -Xmx2g -jar GenomeAnalysisTK.jar \
+ *   -R ref.fasta \
+ *   -T CountReads \
+ *   -o output.txt \
+ *   -I input.bam \
+ *   [-L input.intervals]
+ * 
+ * + */ +@Requires({DataSource.READS, DataSource.REFERENCE}) +public class CountBasesWalker extends ReadWalker { + public Integer map(ReferenceContext ref, GATKSAMRecord read, ReadMetaDataTracker tracker) { + + return read.getReadLength(); + } + + public Long reduceInit() { return 0L; } + + public Long reduce(Integer value, Long sum) { + return (long) value + sum; + } +}