comparison GenomeAnalysisTK-2.7-2-g6bda569/resources/CountLoci.java @ 0:1485d70afa12 draft default tip

Uploaded
author halley
date Tue, 15 Oct 2013 03:09:34 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1485d70afa12
1 /*
2 * Copyright (c) 2012 The Broad Institute
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
11 * conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 package org.broadinstitute.sting.gatk.walkers.qc;
27
28 import org.broadinstitute.sting.commandline.Output;
29 import org.broadinstitute.sting.gatk.CommandLineGATK;
30 import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
31 import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
32 import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
33 import org.broadinstitute.sting.gatk.walkers.LocusWalker;
34 import org.broadinstitute.sting.gatk.walkers.NanoSchedulable;
35 import org.broadinstitute.sting.gatk.walkers.TreeReducible;
36 import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
37 import org.broadinstitute.sting.utils.help.HelpConstants;
38
39 import java.io.PrintStream;
40
41 /**
42 * Walks over the input data set, calculating the total number of covered loci for diagnostic purposes.
43 *
44 * <p>
45 * This is the simplest example of a locus walker.
46 * </p>
47 *
48 * <h3>Input</h3>
49 * <p>
50 * One or more BAM files.
51 * </p>
52 *
53 * <h3>Output</h3>
54 * <p>
55 * Number of loci traversed. If an output file name is provided, then the result will be written to that file.
56 * Otherwise it will be sent to standard console output.
57 * </p>
58 *
59 * <h3>Examples</h3>
60 * <pre>
61 * java -Xmx2g -jar GenomeAnalysisTK.jar \
62 * -T CountLoci \
63 * -R ref.fasta \
64 * -I input.bam \
65 * -o output.txt \
66 * [-L input.intervals]
67 * </pre>
68 *
69 */
70 @DocumentedGATKFeature( groupName = HelpConstants.DOCS_CAT_QC, extraDocs = {CommandLineGATK.class} )
71 public class CountLoci extends LocusWalker<Integer, Long> implements TreeReducible<Long>, NanoSchedulable {
72 @Output
73 PrintStream out;
74
75 public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
76 return 1;
77 }
78
79 public Long reduceInit() { return 0l; }
80
81 public Long reduce(Integer value, Long sum) {
82 return value + sum;
83 }
84
85 /**
86 * Reduces two subtrees together. In this case, the implementation of the tree reduce
87 * is exactly the same as the implementation of the single reduce.
88 */
89 public Long treeReduce(Long lhs, Long rhs) {
90 return lhs + rhs;
91 }
92
93 public void onTraversalDone( Long c ) {
94 out.println(c);
95 }
96 }