<commit_before>package org.broadinstitute.sting.playground.gatk.walkers.poolseq;

import org.broadinstitute.sting.playground.utils.SQuad;
import org.broadinstitute.sting.playground.utils.ReadOffsetQuad;
import org.broadinstitute.sting.playground.utils.PoolUtils;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.cmdLine.Argument;
import org.broadinstitute.sting.utils.*;
import net.sf.samtools.SAMRecord;

import java.io.PrintStream;
import java.io.FileNotFoundException;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Ghost
 * Date: Sep 12, 2009
 * Time: 12:20:42 PM
 * To change this template use File | Settings | File Templates.
 */
@By(DataSource.REFERENCE)
public class PowerAndCoverageWalker extends LocusWalker<SQuad<Integer>, SQuad<Long>> {

    @Argument(fullName="suppressLocusPrinting", doc="Walker does not output locus data to any file. Only total coverage information is given at the end", required=false)
    public boolean suppressPrinting = false;

    @Argument(fullName="outputFile", shortName="of", doc="Locus information is printed to this file instead of standard out", required = false)
    public String outputFile = null;

    @Argument(fullName="bootStrapIterations", shortName="bs", doc="Use a bootstrap method with this many iterations", required=false)
    public int bootstrapIterations = 0;

    @Argument(fullName="lodThreshold", shortName="lod", doc="Threshold for log likelihood ratio to be called a SNP. Defaults to 3.0", required = false)
    public double lodThresh = 3.0;

    @Argument(fullName="minimumQScore", shortName="qm", doc="Use bases whose phred (Q) score meets or exceeds this number. Defaults to 0", required = false)
    public byte minQ = 0;

    @Argument(fullName="aboveQScoreOutputOnly", doc="Output only the information for reads that exceed the q-score threshold", required=false)
    public boolean aboveQScoreOutputOnly = false;

    @Argument(fullName="outputRawStatistics", shortName="rp", doc="Walker outputs the median quality score and power for the un-thresholded reads as well as those that are thresholded", required=false)
    public boolean outputRawStatistics = false;

    @Argument(fullName="poolSize", shortName="pf", doc="Number of individuals in the pool", required = true)
    public int numIndividuals = 0;

    protected PrintStream outputWriter = null;

    public void initialize() {
        if(numIndividuals <= 0) {
            throw new StingException("Pool size must be greater than 1. You input "+numIndividuals);
        }
        if( outputFile != null ) {
            try {
                outputWriter = new PrintStream(outputFile);
            } catch (FileNotFoundException e) {
                String errMsg = "The filepath input as an argument to -of, "+outputFile+" was a directory or could not be found or created.";
                throw new StingException(errMsg, e);
            }
                outputWriter.printf("%s%n", generateHeaderString());
        } else if( ! suppressPrinting ) {
            out.printf("%s%n", generateHeaderString());
        }
    }

    public SQuad<Long> reduceInit() {
        return new SQuad<Long>(0l,0l,0l,0l);
    }

    /* REDUCE
     * Add up filtered and unfiltered coverage in the forward
     * and reverse directions.<commit_msg>Changed some ShortNames so they made more sense.<commit_after>package org.broadinstitute.sting.playground.gatk.walkers.poolseq;

import org.broadinstitute.sting.playground.utils.SQuad;
import org.broadinstitute.sting.playground.utils.ReadOffsetQuad;
import org.broadinstitute.sting.playground.utils.PoolUtils;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.cmdLine.Argument;
import org.broadinstitute.sting.utils.*;
import net.sf.samtools.SAMRecord;

import java.io.PrintStream;
import java.io.FileNotFoundException;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Ghost
 * Date: Sep 12, 2009
 * Time: 12:20:42 PM
 * To change this template use File | Settings | File Templates.
 */
@By(DataSource.REFERENCE)
public class PowerAndCoverageWalker extends LocusWalker<SQuad<Integer>, SQuad<Long>> {

    @Argument(fullName="suppressLocusPrinting", doc="Walker does not output locus data to any file. Only total coverage information is given at the end", required=false)
    public boolean suppressPrinting = false;

    @Argument(fullName="outputFile", shortName="of", doc="Locus information is printed to this file instead of standard out", required = false)
    public String outputFile = null;

    @Argument(fullName="bootStrapIterations", shortName="bs", doc="Use a bootstrap method with this many iterations", required=false)
    public int bootstrapIterations = 0;

    @Argument(fullName="lodThreshold", shortName="lod", doc="Threshold for log likelihood ratio to be called a SNP. Defaults to 3.0", required = false)
    public double lodThresh = 3.0;

    @Argument(fullName="minimumQScore", shortName="qm", doc="Use bases whose phred (Q) score meets or exceeds this number. Defaults to 0", required = false)
    public byte minQ = 0;

    @Argument(fullName="aboveQScoreOutputOnly", doc="Output only the information for reads that exceed the q-score threshold", required=false)
    public boolean aboveQScoreOutputOnly = false;

    @Argument(fullName="outputRawStatistics", shortName="rs", doc="Walker outputs the median quality score and power for the un-thresholded reads as well as those that are thresholded", required=false)
    public boolean outputRawStatistics = false;

    @Argument(fullName="poolSize", shortName="ps", doc="Number of individuals in the pool", required = true)
    public int numIndividuals = 0;

    protected PrintStream outputWriter = null;

    public void initialize() {
        if(numIndividuals <= 0) {
            throw new StingException("Pool size must be greater than 1. You input "+numIndividuals);
        }
        if( outputFile != null ) {
            try {
                outputWriter = new PrintStream(outputFile);
            } catch (FileNotFoundException e) {
                String errMsg = "The filepath input as an argument to -of, "+outputFile+" was a directory or could not be found or created.";
                throw new StingException(errMsg, e);
            }
                outputWriter.printf("%s%n", generateHeaderString());
        } else if( ! suppressPrinting ) {
            out.printf("%s%n", generateHeaderString());
        }
    }

    public SQuad<Long> reduceInit() {
        return new SQuad<Long>(0l,0l,0l,0l);
    }

    /* REDUCE
     * Add up filtered and unfiltered coverage in the forward
     * and reverse directions.
{'fraction_non_alphanumeric': 0.0991927760295526, 'fraction_numerical': 0.007114516349705842, 'mean_word_length': 4.003422313483915, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3638675', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2039, 'n_words': 608}