From fdd16dc6f99eee6a866780540702b371d3abaf1d Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Sat, 20 Apr 2013 21:49:50 -0400 Subject: [PATCH] DiagnoseTargets refactor A plugin enabled implementation of DiagnoseTargets Summarized Changes: ------------------- * move argument collection into Thresholder object * make thresholder object private member of all statistics classes * rework the logic of the mate pairing thresholds * update unit and integration tests to reflect the new behavior * Implements Locus Statistic plugins * Extend Locus Statistic plugins to determine sample status * Export all common plugin functionality into utility class * Update tests accordingly [fixes #48465557] --- .../diagnostics/targets/DiagnoseTargets.java | 183 ++++++------- .../targets/FindCoveredIntervals.java | 2 +- .../targets/IntervalStatistics.java | 71 +++-- .../diagnostics/targets/LocusStatistics.java | 48 ++-- .../diagnostics/targets/SampleStatistics.java | 259 ++++++------------ .../diagnostics/targets/ThresHolder.java | 152 +++++----- .../targets/statistics/Interval.java | 63 +++++ .../diagnostics/targets/statistics/Locus.java | 65 +++++ .../targets/statistics/LocusCoverageGap.java} | 88 ++---- .../statistics/LocusExcessiveCoverage.java | 79 ++++++ .../targets/statistics/LocusLowCoverage.java | 80 ++++++ .../targets/statistics/LocusPoorQuality.java | 79 ++++++ .../targets/statistics/PluginUtils.java | 66 +++++ .../targets/statistics/Sample.java | 63 +++++ .../targets/statistics/SampleBadMates.java | 76 +++++ .../targets/statistics/SampleNoReads.java | 73 +++++ .../DiagnoseTargetsIntegrationTest.java | 4 +- .../targets/LocusStatisticsUnitTest.java | 38 +-- 18 files changed, 983 insertions(+), 506 deletions(-) create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Interval.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Locus.java rename protected/java/{test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatisticsUnitTest.java => src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusCoverageGap.java} (73%) create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusExcessiveCoverage.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusLowCoverage.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusPoorQuality.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/PluginUtils.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Sample.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleBadMates.java create mode 100644 protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleNoReads.java diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargets.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargets.java index 5bdb81906..d90f2d1fa 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargets.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargets.java @@ -47,23 +47,26 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; import net.sf.picard.util.PeekableIterator; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Hidden; +import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.gatk.CommandLineGATK; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.*; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Interval; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Locus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Sample; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.SampleUtils; -import org.broadinstitute.sting.utils.help.HelpConstants; -import org.broadinstitute.variant.vcf.VCFConstants; -import org.broadinstitute.variant.vcf.VCFHeader; +import org.broadinstitute.sting.utils.classloader.PluginManager; +import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException; import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.help.DocumentedGATKFeature; +import org.broadinstitute.sting.utils.help.HelpConstants; import org.broadinstitute.variant.variantcontext.*; import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter; +import org.broadinstitute.variant.vcf.*; import java.util.*; @@ -111,80 +114,19 @@ import java.util.*; @PartitionBy(PartitionType.INTERVAL) public class DiagnoseTargets extends LocusWalker { + private static final String AVG_INTERVAL_DP_KEY = "IDP"; + @Output(doc = "File to which interval statistics should be written") private VariantContextWriter vcfWriter = null; - /** - * Only bases with quality greater than this will be considered in the coverage metrics. - */ - @Argument(fullName = "minimum_base_quality", shortName = "BQ", doc = "The minimum Base Quality that is considered for calls", required = false) - private int minimumBaseQuality = 20; - - /** - * Only reads with mapping quality greater than this will be considered in the coverage metrics. - */ - @Argument(fullName = "minimum_mapping_quality", shortName = "MQ", doc = "The minimum read mapping quality considered for calls", required = false) - private int minimumMappingQuality = 20; - - /** - * If at any locus, a sample has less coverage than this, it will be reported as LOW_COVERAGE - */ - @Argument(fullName = "minimum_coverage", shortName = "min", doc = "The minimum allowable coverage, used for calling LOW_COVERAGE", required = false) - private int minimumCoverage = 5; - - /** - * If at any locus, a sample has more coverage than this, it will be reported as EXCESSIVE_COVERAGE - */ - @Argument(fullName = "maximum_coverage", shortName = "max", doc = "The maximum allowable coverage, used for calling EXCESSIVE_COVERAGE", required = false) - private int maximumCoverage = 700; - - /** - * If any sample has a paired read whose distance between alignment starts (between the pairs) is greater than this, it will be reported as BAD_MATE - */ - @Argument(fullName = "maximum_insert_size", shortName = "ins", doc = "The maximum allowed distance between a read and its mate", required = false) - private int maxInsertSize = 500; - - /** - * The proportion of samples that must have a status for it to filter the entire interval. Example: 8 out of 10 samples have low coverage status on the interval, - * with a threshold higher than 0.2, this interval will be filtered as LOW_COVERAGE. - */ - @Argument(fullName = "voting_status_threshold", shortName = "stV", doc = "The needed proportion of samples containing a call for the interval to adopt the call ", required = false) - private double votePercentage = 0.50; - - /** - * The proportion of reads in the loci that must have bad mates for the sample to be reported as BAD_MATE - */ - @Argument(fullName = "bad_mate_status_threshold", shortName = "stBM", doc = "The proportion of the loci needed for calling BAD_MATE", required = false) - private double badMateStatusThreshold = 0.50; - - /** - * The proportion of loci in a sample that must fall under the LOW_COVERAGE or COVERAGE_GAPS category for the sample to be reported as either (or both) - */ - @Argument(fullName = "coverage_status_threshold", shortName = "stC", doc = "The proportion of the loci needed for calling LOW_COVERAGE and COVERAGE_GAPS", required = false) - private double coverageStatusThreshold = 0.20; - - /** - * The proportion of loci in a sample that must fall under the EXCESSIVE_COVERAGE category for the sample to be reported as EXCESSIVE_COVERAGE - */ - @Argument(fullName = "excessive_coverage_status_threshold", shortName = "stXC", doc = "The proportion of the loci needed for calling EXCESSIVE_COVERAGE", required = false) - private double excessiveCoverageThreshold = 0.20; - - /** - * The proportion of loci in a sample that must fall under the LOW_QUALITY category for the sample to be reported as LOW_QUALITY - */ - @Argument(fullName = "quality_status_threshold", shortName = "stQ", doc = "The proportion of the loci needed for calling POOR_QUALITY", required = false) - private double qualityStatusThreshold = 0.50; - - @Hidden - @Argument(fullName = "print_debug_log", shortName = "dl", doc = "Used only for debugging the walker. Prints extra info to screen", required = false) - private boolean debug = false; + @ArgumentCollection + private ThresHolder thresholds = new ThresHolder(); private Map intervalMap = null; // maps each interval => statistics private PeekableIterator intervalListIterator; // an iterator to go over all the intervals provided as we traverse the genome private Set samples = null; // all the samples being processed private static final Allele SYMBOLIC_ALLELE = Allele.create("
", false); // avoid creating the symbolic allele multiple times private static final Allele UNCOVERED_ALLELE = Allele.create("A", true); // avoid creating the 'fake' ref allele for uncovered intervals multiple times - private ThresHolder thresholds = null; // object that holds all the thresholds for Diagnose Targets (todo -- should become a plugin based system) private static final int INITIAL_HASH_SIZE = 500000; @@ -192,18 +134,18 @@ public class DiagnoseTargets extends LocusWalker { public void initialize() { super.initialize(); - if (getToolkit().getIntervals() == null) - throw new UserException("This tool only works if you provide one or more intervals. ( Use the -L argument )"); - - thresholds = new ThresHolder(minimumBaseQuality, minimumMappingQuality, minimumCoverage, maximumCoverage, maxInsertSize, votePercentage, - badMateStatusThreshold, coverageStatusThreshold, excessiveCoverageThreshold, qualityStatusThreshold); + if (getToolkit().getIntervals() == null || getToolkit().getIntervals().isEmpty()) + throw new UserException("This tool only works if you provide one or more intervals (use the -L argument). If you want to run whole genome, use -T DepthOfCoverage instead."); intervalMap = new HashMap(INITIAL_HASH_SIZE); intervalListIterator = new PeekableIterator(getToolkit().getIntervals().iterator()); // get all of the unique sample names for the VCF Header samples = SampleUtils.getSAMFileSamples(getToolkit().getSAMFileHeader()); - vcfWriter.writeHeader(new VCFHeader(ThresHolder.getHeaderInfo(), samples)); + vcfWriter.writeHeader(new VCFHeader(getHeaderInfo(), samples)); + + // pre load all the statistics classes because it is costly to operate on the JVM and we only want to do it once. + loadAllPlugins(thresholds); } @Override @@ -217,8 +159,7 @@ public class DiagnoseTargets extends LocusWalker { // at this point, all intervals in intervalMap overlap with this locus, so update all of them for (IntervalStatistics intervalStatistics : intervalMap.values()) - intervalStatistics.addLocus(context, ref, thresholds); - + intervalStatistics.addLocus(context); return 1L; } @@ -317,37 +258,26 @@ public class DiagnoseTargets extends LocusWalker { alleles.add(SYMBOLIC_ALLELE); VariantContextBuilder vcb = new VariantContextBuilder("DiagnoseTargets", interval.getContig(), interval.getStart(), interval.getStop(), alleles); - vcb = vcb.log10PError(VariantContext.NO_LOG10_PERROR); // QUAL field makes no sense in our VCF - vcb.filters(new HashSet(statusesToStrings(stats.callableStatuses(thresholds), true))); + vcb = vcb.log10PError(VariantContext.NO_LOG10_PERROR); + vcb.filters(new HashSet(statusesToStrings(stats.callableStatuses(), true))); attributes.put(VCFConstants.END_KEY, interval.getStop()); - attributes.put(ThresHolder.AVG_INTERVAL_DP_KEY, stats.averageCoverage()); + attributes.put(AVG_INTERVAL_DP_KEY, stats.averageCoverage()); vcb = vcb.attributes(attributes); - if (debug) { - System.out.printf("Output -- Interval: %s, Coverage: %.2f%n", stats.getInterval(), stats.averageCoverage()); - } for (String sample : samples) { final GenotypeBuilder gb = new GenotypeBuilder(sample); - SampleStatistics sampleStat = stats.getSample(sample); - gb.attribute(ThresHolder.AVG_INTERVAL_DP_KEY, sampleStat.averageCoverage()); - gb.attribute("Q1", sampleStat.getQuantileDepth(0.25)); - gb.attribute("MED", sampleStat.getQuantileDepth(0.50)); - gb.attribute("Q3", sampleStat.getQuantileDepth(0.75)); + SampleStatistics sampleStat = stats.getSampleStatics(sample); + gb.attribute(AVG_INTERVAL_DP_KEY, sampleStat.averageCoverage()); - if (debug) { - System.out.printf("Found %d bad mates out of %d reads %n", sampleStat.getnBadMates(), sampleStat.getnReads()); - } - gb.filters(statusesToStrings(stats.getSample(sample).getCallableStatuses(thresholds), false)); + gb.filters(statusesToStrings(stats.getSampleStatics(sample).getCallableStatuses(), false)); genotypes.add(gb.make()); } vcb = vcb.genotypes(genotypes); - vcfWriter.add(vcb.make()); - } /** @@ -356,17 +286,74 @@ public class DiagnoseTargets extends LocusWalker { * @param statuses the set of statuses to be converted * @return a matching set of strings */ - private List statusesToStrings(Set statuses, final boolean includePASS) { + private List statusesToStrings(Set statuses, final boolean isInfoField) { List output = new ArrayList(statuses.size()); for (CallableStatus status : statuses) - if ( includePASS || status != CallableStatus.PASS ) // adding pass => results in a filter for genotypes + if ( isInfoField || status != CallableStatus.PASS ) output.add(status.name()); return output; } private IntervalStatistics createIntervalStatistic(GenomeLoc interval) { - return new IntervalStatistics(samples, interval); + return new IntervalStatistics(samples, interval, thresholds); } + + protected static void loadAllPlugins(final ThresHolder thresholds) { + for (Class stat : new PluginManager(Locus.class).getPlugins()) { + try { + final Locus stats = (Locus) stat.newInstance(); + stats.initialize(thresholds); + thresholds.locusStatisticList.add(stats); + } catch (Exception e) { + throw new DynamicClassResolutionException(stat, e); + } + } + + for (Class stat : new PluginManager(Sample.class).getPlugins()) { + try { + final Sample stats = (Sample) stat.newInstance(); + stats.initialize(thresholds); + thresholds.sampleStatisticList.add(stats); + } catch (Exception e) { + throw new DynamicClassResolutionException(stat, e); + } + } + + for (Class stat : new PluginManager(Interval.class).getPlugins()) { + try { + final Interval stats = (Interval) stat.newInstance(); + stats.initialize(thresholds); + thresholds.intervalStatisticList.add(stats); + } catch (Exception e) { + throw new DynamicClassResolutionException(stat, e); + } + } + } + + /** + * Gets the header lines for the VCF writer + * + * @return A set of VCF header lines + */ + private static Set getHeaderInfo() { + Set headerLines = new HashSet(); + + // INFO fields for overall data + headerLines.add(VCFStandardHeaderLines.getInfoLine(VCFConstants.END_KEY)); + headerLines.add(new VCFInfoHeaderLine(AVG_INTERVAL_DP_KEY, 1, VCFHeaderLineType.Float, "Average depth across the interval. Sum of the depth in a loci divided by interval size.")); + headerLines.add(new VCFInfoHeaderLine("Diagnose Targets", 0, VCFHeaderLineType.Flag, "DiagnoseTargets mode")); + + // FORMAT fields for each genotype + headerLines.add(VCFStandardHeaderLines.getFormatLine(VCFConstants.GENOTYPE_FILTER_KEY)); + headerLines.add(new VCFFormatHeaderLine(AVG_INTERVAL_DP_KEY, 1, VCFHeaderLineType.Float, "Average sample depth across the interval. Sum of the sample specific depth in all loci divided by interval size.")); + + // FILTER fields + for (CallableStatus stat : CallableStatus.values()) + headerLines.add(new VCFFilterHeaderLine(stat.name(), stat.description)); + + return headerLines; + } + } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/FindCoveredIntervals.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/FindCoveredIntervals.java index eef581160..1c9751c5b 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/FindCoveredIntervals.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/FindCoveredIntervals.java @@ -105,7 +105,7 @@ public class FindCoveredIntervals extends ActiveRegionWalker { // Look to see if the region has sufficient coverage public ActivityProfileState isActive(final RefMetaDataTracker tracker, final ReferenceContext ref, final AlignmentContext context) { - int depth = ThresHolder.DEFAULTS.getFilteredCoverage(context.getBasePileup()); + int depth = context.getBasePileup().getBaseFilteredPileup(coverageThreshold).depthOfCoverage(); // note the linear probability scale return new ActivityProfileState(ref.getLocus(), Math.min(depth / coverageThreshold, 1)); diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java index 0f4b33747..2e7333cc6 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java @@ -47,7 +47,7 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; -import org.broadinstitute.sting.gatk.contexts.ReferenceContext; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Interval; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; @@ -57,27 +57,23 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -class IntervalStatistics { +public class IntervalStatistics { private final Map samples; private final GenomeLoc interval; - private boolean hasNref = false; + private final ThresHolder thresholds; - private int preComputedTotalCoverage = -1; // avoids re-calculating the total sum (-1 means we haven't pre-computed it yet) + private int preComputedTotalCoverage = -1; - /* - private double minMedianDepth = 20.0; - private double badMedianDepthPercentage = 0.20; - private double votePercentage = 0.50; - */ - public IntervalStatistics(Set samples, GenomeLoc interval/*, int minimumCoverageThreshold, int maximumCoverageThreshold, int minimumMappingQuality, int minimumBaseQuality*/) { + public IntervalStatistics(Set samples, GenomeLoc interval, ThresHolder thresholds) { this.interval = interval; + this.thresholds = thresholds; this.samples = new HashMap(samples.size()); for (String sample : samples) - this.samples.put(sample, new SampleStatistics(interval /*, minimumCoverageThreshold, maximumCoverageThreshold, minimumMappingQuality, minimumBaseQuality*/)); + this.samples.put(sample, new SampleStatistics(interval, thresholds)); } - public SampleStatistics getSample(String sample) { + public SampleStatistics getSampleStatics(String sample) { return samples.get(sample); } @@ -85,19 +81,19 @@ class IntervalStatistics { return interval; } + public int getNSamples() { + return samples.size(); + } + /** * The function to populate data into the Statistics from the walker. * This takes the input and manages passing the data to the SampleStatistics and Locus Statistics * * @param context The alignment context given from the walker - * @param ref the reference context given from the walker - * @param thresholds the class contains the statistical threshold for making calls */ - public void addLocus(AlignmentContext context, ReferenceContext ref, ThresHolder thresholds) { + public void addLocus(AlignmentContext context) { ReadBackedPileup pileup = context.getBasePileup(); - //System.out.println(ref.getLocus().toString()); - Map samplePileups = pileup.getPileupsForSamples(samples.keySet()); for (Map.Entry entry : samplePileups.entrySet()) { @@ -108,11 +104,9 @@ class IntervalStatistics { if (sampleStatistics == null) throw new ReviewedStingException(String.format("Trying to add locus statistics to a sample (%s) that doesn't exist in the Interval.", sample)); - sampleStatistics.addLocus(context.getLocation(), samplePileup, thresholds); + sampleStatistics.addLocus(context.getLocation(), samplePileup); } - if (!hasNref && ref.getBase() == 'N') - hasNref = true; } public double averageCoverage() { @@ -129,29 +123,34 @@ class IntervalStatistics { /** * Return the Callable statuses for the interval as a whole - * todo -- add missingness filter * - * @param thresholds the class contains the statistical threshold for making calls * @return the callable status(es) for the whole interval */ - public Set callableStatuses(ThresHolder thresholds) { - Set output = new HashSet(); + public Set callableStatuses() { + final Set output = new HashSet(); - // Initialize the Map - Map votes = new HashMap(); - for (CallableStatus status : CallableStatus.values()) - votes.put(status, 0); + // sum up all the callable status for each sample + final Map sampleStatusTally = new HashMap(CallableStatus.values().length); + for (SampleStatistics sampleStatistics : samples.values()) { + for (CallableStatus status : sampleStatistics.getCallableStatuses()) { + sampleStatusTally.put(status, !sampleStatusTally.containsKey(status) ? 1 : sampleStatusTally.get(status) + 1); + } + } - // tally up the votes - for (SampleStatistics sample : samples.values()) - for (CallableStatus status : sample.getCallableStatuses(thresholds)) - votes.put(status, votes.get(status) + 1); + // check if any of the votes pass the threshold + final int nSamples = getNSamples(); + for (Map.Entry entry : sampleStatusTally.entrySet()) { + if ((double) entry.getValue() / nSamples > thresholds.votePercentageThreshold) { + output.add(entry.getKey()); + } + } - // output tall values above the threshold - final double minVotesNeeded = thresholds.getVotePercentageThreshold() * samples.size(); - for (CallableStatus status : votes.keySet()) { - if (!status.equals((CallableStatus.PASS)) && votes.get(status) > minVotesNeeded) + // add the interval specific statitics statuses + for (Interval intervalStat : thresholds.intervalStatisticList) { + final CallableStatus status = intervalStat.status(this); + if (status != null) { output.add(status); + } } return output; diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatistics.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatistics.java index 5ec1a1608..e85f3d9c1 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatistics.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatistics.java @@ -46,21 +46,25 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Locus; + import java.util.HashSet; +import java.util.List; import java.util.Set; -class LocusStatistics { - private final int coverage; - private final int rawCoverage; +public class LocusStatistics { + private int coverage; + private int rawCoverage; + private final List locusStatisticsList; - public LocusStatistics() { - this.coverage = 0; - this.rawCoverage = 0; + public LocusStatistics(ThresHolder thresholds) { + this(0,0,thresholds); } - public LocusStatistics(int coverage, int rawCoverage) { + protected LocusStatistics(int coverage, int rawCoverage, ThresHolder thresholds) { this.coverage = coverage; this.rawCoverage = rawCoverage; + this.locusStatisticsList = thresholds.locusStatisticList; } public int getCoverage() { @@ -74,31 +78,21 @@ class LocusStatistics { /** * Generates all applicable statuses from the coverages in this locus * - * @param thresholds the class contains the statistical threshold for making calls * @return a set of all statuses that apply */ - public Set callableStatuses(ThresHolder thresholds) { + public Set callableStatuses() { Set output = new HashSet(); - - // if too much coverage - if (getCoverage() > thresholds.getMaximumCoverage()) - output.add(CallableStatus.EXCESSIVE_COVERAGE); - - // if not enough coverage - if (getCoverage() < thresholds.getMinimumCoverage()) { - // was there a lot of low Qual coverage? - if (getRawCoverage() >= thresholds.getMinimumCoverage()) - output.add(CallableStatus.POOR_QUALITY); - // no? - else { - // is there any coverage? - if (getRawCoverage() > 0) - output.add(CallableStatus.LOW_COVERAGE); - else - output.add(CallableStatus.COVERAGE_GAPS); + for (Locus stats : locusStatisticsList) { + CallableStatus status = stats.status(this); + if (status != null) { + output.add(status); } } - return output; } + + public void set(final int coverage, final int rawCoverage) { + this.coverage = coverage; + this.rawCoverage = rawCoverage; + } } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java index afde93ea3..c05feebbd 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java @@ -46,6 +46,8 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Locus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Sample; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; @@ -56,93 +58,100 @@ import java.util.*; /** * The statistics calculator for a specific sample given the interval */ -class SampleStatistics { +public class SampleStatistics { private final GenomeLoc interval; private final ArrayList loci; + private final ThresHolder thresholds; - private int[] preSortedDepths = null; - private int preComputedTotalCoverage = -1; // avoids re-calculating the total sum (-1 means we haven't pre-computed it yet) - + // avoids re-calculating these sums over loci + private int preComputedTotalCoverage = -1; + private Map locusStatusTally = null; private int nReads = -1; private int nBadMates = -1; - private SampleStatistics(GenomeLoc interval, ArrayList loci) { + public SampleStatistics(final GenomeLoc interval, final ThresHolder thresholds) { this.interval = interval; - this.loci = loci; + this.loci = new ArrayList(interval.size()); + this.thresholds = thresholds; nReads = 0; nBadMates = 0; - } - - public SampleStatistics(GenomeLoc interval) { - this(interval, new ArrayList(interval.size())); // Initialize every loci (this way we don't have to worry about non-existent loci in the object for (int i = 0; i < interval.size(); i++) - this.loci.add(new LocusStatistics()); + this.loci.add(new LocusStatistics(thresholds)); } + /** + * Calculates the total "good" coverage of this sample. Good means "passes the base and + * mapping quality requirements. + * + * @return the total "good" coverage across the interval for this sample + */ public long totalCoverage() { if (preComputedTotalCoverage < 0) calculateTotalCoverage(); return preComputedTotalCoverage; } + /** + * Calculates the average "good" coverage of this sample. Good means "passes the base and + * mapping quality requirements. + * + * @return the average "good" coverage + */ public double averageCoverage() { - if (preComputedTotalCoverage < 0) - calculateTotalCoverage(); - return (double) preComputedTotalCoverage / loci.size(); + return (double) totalCoverage() / loci.size(); + } + + /** + * Tally up all the callable status of all the loci in this sample. + * + * @return a map of callable status and counts + */ + public Map getLocusStatusTally() { + if (locusStatusTally == null) { + locusStatusTally = new HashMap(CallableStatus.values().length); + + // sum up all the callable statuses for each locus + for (int i = 0; i < interval.size(); i++) { + LocusStatistics locus = loci.get(i); + for (CallableStatus status : locus.callableStatuses()) { + locusStatusTally.put(status, !locusStatusTally.containsKey(status) ? 1 : locusStatusTally.get(status) + 1); + } + } + } + return locusStatusTally; } /** * Calculates the callable statuses of the entire sample * - * @param thresholds the class contains the statistical threshold for making calls * @return the callable statuses of the entire sample */ - public Set getCallableStatuses(ThresHolder thresholds) { - // We check if reads are present to prevent div / 0 exceptions - if (nReads == 0) { - return Collections.singleton(CallableStatus.NO_READS); - } + public Set getCallableStatuses() { + final Set output = new HashSet(); - Set output = new HashSet(); - Map totals = new HashMap(CallableStatus.values().length); - - // initialize map - for (CallableStatus status : CallableStatus.values()) - totals.put(status, 0.0); - - // sum up all the callable statuses for each locus - for (int i = 0; i < interval.size(); i++) { - for (CallableStatus status : callableStatus(i, thresholds)) { - double count = totals.get(status); - - totals.put(status, count + 1); + // get the tally of all the locus callable statuses + for (Locus locusStat : thresholds.locusStatisticList) { + final CallableStatus status = locusStat.sampleStatus(this); + if (status != null) { + output.add(status); } } - double intervalSize = interval.size(); - - if (((double) nBadMates / nReads) >= thresholds.getBadMateStatusThreshold()) - output.add(CallableStatus.BAD_MATE); - - if ((totals.get(CallableStatus.COVERAGE_GAPS) / intervalSize) >= thresholds.getCoverageStatusThreshold()) - output.add(CallableStatus.COVERAGE_GAPS); - - if ((totals.get(CallableStatus.LOW_COVERAGE) / intervalSize) >= thresholds.getCoverageStatusThreshold()) - output.add(CallableStatus.LOW_COVERAGE); - - if ((totals.get(CallableStatus.EXCESSIVE_COVERAGE) / intervalSize) >= thresholds.getExcessiveCoverageThreshold()) - output.add(CallableStatus.EXCESSIVE_COVERAGE); - - if ((totals.get(CallableStatus.POOR_QUALITY) / intervalSize) >= thresholds.getQualityStatusThreshold()) - output.add(CallableStatus.POOR_QUALITY); - - if (output.isEmpty()) { - output.add(CallableStatus.PASS); + // get the sample specific statitics statuses + for (Sample sampleStat : thresholds.sampleStatisticList) { + final CallableStatus status = sampleStat.status(this); + if (status != null) { + output.add(status); + } } + // special case, if there are no reads, then there is no sense reporting coverage gaps. + if (output.contains(CallableStatus.NO_READS) && output.contains(CallableStatus.COVERAGE_GAPS)) + output.remove(CallableStatus.COVERAGE_GAPS); + return output; } @@ -151,50 +160,37 @@ class SampleStatistics { * * @param locus The locus given as a GenomeLoc * @param pileup The pileup of that locus, this exclusively contains the sample - * @param thresholds the class contains the statistical threshold for making calls */ - public void addLocus(GenomeLoc locus, ReadBackedPileup pileup, ThresHolder thresholds) { + public void addLocus(GenomeLoc locus, ReadBackedPileup pileup) { if (!interval.containsP(locus)) throw new ReviewedStingException(String.format("Locus %s is not part of the Interval %s", locus, interval)); // a null pileup means there nothing ot add if (pileup != null) { - - int locusIndex = locus.getStart() - interval.getStart(); - - int rawCoverage = pileup.depthOfCoverage(); - int coverage = thresholds.getFilteredCoverage(pileup); - - LocusStatistics locusData = new LocusStatistics(coverage, rawCoverage); - - loci.set(locusIndex, locusData); + final int locusIndex = locus.getStart() - interval.getStart(); + final int rawCoverage = pileup.depthOfCoverage(); + final int coverage = pileup.getBaseAndMappingFilteredPileup(thresholds.minimumBaseQuality, thresholds.minimumMappingQuality).depthOfCoverage(); + final LocusStatistics locusData = loci.get(locusIndex); + locusData.set(coverage, rawCoverage); for (GATKSAMRecord read : pileup.getReads()) - processRead(read, thresholds); - } - } - - private void processRead(GATKSAMRecord read, ThresHolder thresholds) { - // Was this read already processed? - if (read.getTemporaryAttribute("checkedBadMate") == null) { - nReads++; - if (!hasValidMate(read, thresholds)) - nBadMates++; - read.setTemporaryAttribute("checkedBadMate", true); + processRead(read); } } /** - * returns the callable status of a given locus without taking the reference base into account. - * - * @param locusIndex location in the genome to inquire (only one locus) - * @param thresholds the class contains the statistical threshold for making calls - * @return the callable status of a locus + * Account for the read and check it for any statistics necessary. Reads are marked in the temporary + * attribute "seen" to make sure they're not counted twice. + * + * @param read the read */ - private Set callableStatus(int locusIndex, ThresHolder thresholds) { - LocusStatistics locus = loci.get(locusIndex); - - return locus.callableStatuses(thresholds); + private void processRead(GATKSAMRecord read) { + if (read.getTemporaryAttribute("seen") == null) { + nReads++; + if (read.getReadPairedFlag() && !read.getProperPairFlag()) + nBadMates++; + read.setTemporaryAttribute("seen", true); + } } private void calculateTotalCoverage() { @@ -203,101 +199,8 @@ class SampleStatistics { preComputedTotalCoverage += locus.getCoverage(); } - public double getQuantileDepth(double percentage) { - if (preSortedDepths == null) - getDepthsAsSortedArray(); - - return getQuartile(preSortedDepths, percentage); - } - - static double getQuartile(int[] data, double percentage) { - int size = data.length; - if (size == 1) - return (double) data[0]; - - if (percentage == 0.5) { - return getMedian(data); - } - - double position = (size - 1.0) / 2; - if (percentage == 0.25) { - // if the position is a whole number - return getMedian(Arrays.copyOfRange(data, 0, (int) position + 1)); - - } - if (percentage == 0.75) { - if (position % 1 == 0) { - return getMedian(Arrays.copyOfRange(data, (int) position, size)); - } else { - return getMedian(Arrays.copyOfRange(data, (int) position + 1, size)); - } - } - return -1; - } - - // Assumes data is sorted - private static double getMedian(int[] data) { - double size = (double) data.length; - if (size == 1) - return (double) data[0]; - - double position = (size - 1.0) / 2; - - if (position % 1 == 0) - return (double) data[(int) position]; - - else { - double high = (double) data[(int) Math.ceil(position)]; - double low = (double) data[(int) Math.floor(position)]; - - return (high + low) / 2; - - } - - } - - private void getDepthsAsSortedArray() { - preSortedDepths = new int[loci.size()]; - - for (int i = 0; i < loci.size(); i++) - preSortedDepths[i] = loci.get(i).getCoverage(); - - Arrays.sort(preSortedDepths); - } - - boolean hasValidMate(GATKSAMRecord read, ThresHolder thresholds) { - /** Check the following - * Does it have a pair? - * reasonable insert size? - * inverted? - * same orientation? - * same contig? - * is pair mapped? - * todo - is forced mate? - * - */ - - // has NO pair - if (!read.getReadPairedFlag()) - return false; - - // different contigs - if (!read.getMateReferenceIndex().equals(read.getReferenceIndex())) - return false; - - // unmapped - if (read.getMateUnmappedFlag() || read.getReadUnmappedFlag()) - return false; - - // same orientation - if (read.getReadNegativeStrandFlag() == read.getMateNegativeStrandFlag()) - return false; - - // todo -- inverted ? - - // mates are too far apart - return Math.abs(read.getAlignmentStart() - read.getMateAlignmentStart()) <= thresholds.getMaximumInsertSize(); - + public int getIntervalSize() { + return interval.size(); } public int getnReads() { diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/ThresHolder.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/ThresHolder.java index c2dd2f4ff..3b7626708 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/ThresHolder.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/ThresHolder.java @@ -46,29 +46,82 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; -import org.broadinstitute.variant.vcf.*; -import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; +import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Interval; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Locus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics.Sample; -import java.util.HashSet; -import java.util.Set; +import java.util.LinkedList; +import java.util.List; -class ThresHolder { - public static final String AVG_INTERVAL_DP_KEY = "AVG_INTERVAL_DP"; - public static final ThresHolder DEFAULTS = new ThresHolder(20, 20, 5, 700, 50, 0.5, 0.5, 0.2, 0.2, 0.5); +public class ThresHolder { - private final int minimumBaseQuality; - private final int minimumMappingQuality; + /** + * Only bases with quality greater than this will be considered in the coverage metrics. + */ + @Argument(fullName = "minimum_base_quality", shortName = "BQ", doc = "The minimum Base Quality that is considered for calls", required = false) + public int minimumBaseQuality = 20; - private final int minimumCoverage; - private final int maximumCoverage; + /** + * Only reads with mapping quality greater than this will be considered in the coverage metrics. + */ + @Argument(fullName = "minimum_mapping_quality", shortName = "MQ", doc = "The minimum read mapping quality considered for calls", required = false) + public int minimumMappingQuality = 20; - private final int maximumInsertSize; + /** + * If at any locus, a sample has less coverage than this, it will be reported as LOW_COVERAGE + */ + @Argument(fullName = "minimum_coverage", shortName = "min", doc = "The minimum allowable coverage, used for calling LOW_COVERAGE", required = false) + public int minimumCoverage = 5; - private final double votePercentageThreshold; - private final double badMateStatusThreshold; - private final double coverageStatusThreshold; - private final double excessiveCoverageThreshold; - private final double qualityStatusThreshold; + /** + * If at any locus, a sample has more coverage than this, it will be reported as EXCESSIVE_COVERAGE + */ + @Argument(fullName = "maximum_coverage", shortName = "max", doc = "The maximum allowable coverage, used for calling EXCESSIVE_COVERAGE", required = false) + public int maximumCoverage = 700; + + /** + * If any sample has a paired read whose distance between alignment starts (between the pairs) is greater than this, it will be reported as BAD_MATE + */ + @Argument(fullName = "maximum_insert_size", shortName = "ins", doc = "The maximum allowed distance between a read and its mate", required = false) + public int maximumInsertSize = 500; + + /** + * The proportion of samples that must have a status for it to filter the entire interval. Example: 8 out of 10 samples have low coverage status on the interval, + * with a threshold higher than 0.2, this interval will be filtered as LOW_COVERAGE. + */ + @Argument(fullName = "voting_status_threshold", shortName = "stV", doc = "The needed proportion of samples containing a call for the interval to adopt the call ", required = false) + public double votePercentageThreshold = 0.50; + + /** + * The proportion of reads in the loci that must have bad mates for the sample to be reported as BAD_MATE + */ + @Argument(fullName = "bad_mate_status_threshold", shortName = "stBM", doc = "The proportion of the loci needed for calling BAD_MATE", required = false) + public double badMateStatusThreshold = 0.50; + + /** + * The proportion of loci in a sample that must fall under the LOW_COVERAGE or COVERAGE_GAPS category for the sample to be reported as either (or both) + */ + @Argument(fullName = "coverage_status_threshold", shortName = "stC", doc = "The proportion of the loci needed for calling LOW_COVERAGE and COVERAGE_GAPS", required = false) + public double coverageStatusThreshold = 0.20; + + /** + * The proportion of loci in a sample that must fall under the EXCESSIVE_COVERAGE category for the sample to be reported as EXCESSIVE_COVERAGE + */ + @Argument(fullName = "excessive_coverage_status_threshold", shortName = "stXC", doc = "The proportion of the loci needed for calling EXCESSIVE_COVERAGE", required = false) + public double excessiveCoverageThreshold = 0.20; + + /** + * The proportion of loci in a sample that must fall under the LOW_QUALITY category for the sample to be reported as LOW_QUALITY + */ + @Argument(fullName = "quality_status_threshold", shortName = "stQ", doc = "The proportion of the loci needed for calling POOR_QUALITY", required = false) + public double qualityStatusThreshold = 0.50; + + public final List locusStatisticList = new LinkedList(); + public final List sampleStatisticList = new LinkedList(); + public final List intervalStatisticList = new LinkedList(); + + public ThresHolder() {} public ThresHolder(final int minimumBaseQuality, final int minimumMappingQuality, @@ -91,69 +144,4 @@ class ThresHolder { this.excessiveCoverageThreshold = excessiveCoverageThreshold; this.qualityStatusThreshold = qualityStatusThreshold; } - - public int getMinimumCoverage() { - return minimumCoverage; - } - - public int getMaximumCoverage() { - return maximumCoverage; - } - - public int getMaximumInsertSize() { - return maximumInsertSize; - } - - public double getVotePercentageThreshold() { - return votePercentageThreshold; - } - - public double getBadMateStatusThreshold() { - return badMateStatusThreshold; - } - - public double getCoverageStatusThreshold() { - return coverageStatusThreshold; - } - - public double getExcessiveCoverageThreshold() { - return excessiveCoverageThreshold; - } - - public double getQualityStatusThreshold() { - return qualityStatusThreshold; - } - - public int getFilteredCoverage(ReadBackedPileup pileup) { - return pileup.getBaseAndMappingFilteredPileup(minimumBaseQuality, minimumMappingQuality).depthOfCoverage(); - } - - /** - * Gets the header lines for the VCF writer - * - * @return A set of VCF header lines - */ - public static Set getHeaderInfo() { - Set headerLines = new HashSet(); - - // INFO fields for overall data - headerLines.add(VCFStandardHeaderLines.getInfoLine(VCFConstants.END_KEY)); - headerLines.add(new VCFInfoHeaderLine(AVG_INTERVAL_DP_KEY, 1, VCFHeaderLineType.Float, "Average depth across the interval. Sum of the depth in a loci divided by interval size.")); - headerLines.add(new VCFInfoHeaderLine("Diagnose Targets", 0, VCFHeaderLineType.Flag, "DiagnoseTargets mode")); - - // FORMAT fields for each genotype - headerLines.add(VCFStandardHeaderLines.getFormatLine(VCFConstants.GENOTYPE_FILTER_KEY)); - headerLines.add(new VCFFormatHeaderLine(AVG_INTERVAL_DP_KEY, 1, VCFHeaderLineType.Float, "Average depth across the interval. Sum of the depth in a loci divided by interval size.")); - headerLines.add(new VCFFormatHeaderLine("Q1", 1, VCFHeaderLineType.Float, "Lower Quartile of depth distribution.")); - headerLines.add(new VCFFormatHeaderLine("MED", 1, VCFHeaderLineType.Float, "Median of depth distribution.")); - headerLines.add(new VCFFormatHeaderLine("Q3", 1, VCFHeaderLineType.Float, "Upper Quartile of depth Distribution.")); - - - // FILTER fields - for (CallableStatus stat : CallableStatus.values()) - headerLines.add(new VCFFilterHeaderLine(stat.name(), stat.description)); - - return headerLines; - } - } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Interval.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Interval.java new file mode 100644 index 000000000..3e8adc978 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Interval.java @@ -0,0 +1,63 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.IntervalStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * Created with IntelliJ IDEA. + * User: carneiro + * Date: 4/20/13 + * Time: 11:30 PM + * To change this template use File | Settings | File Templates. + */ +public interface Interval { + public void initialize(ThresHolder thresholds); + public CallableStatus status (IntervalStatistics intervalStatistics); +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Locus.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Locus.java new file mode 100644 index 000000000..aee41846b --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Locus.java @@ -0,0 +1,65 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.LocusStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * Created with IntelliJ IDEA. + * User: carneiro + * Date: 4/20/13 + * Time: 11:29 PM + * To change this template use File | Settings | File Templates. + */ +public interface Locus { + public void initialize(ThresHolder thresholds); + public CallableStatus status (LocusStatistics locusStatistics); + public CallableStatus sampleStatus (SampleStatistics sampleStatistics); +} diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatisticsUnitTest.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusCoverageGap.java similarity index 73% rename from protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatisticsUnitTest.java rename to protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusCoverageGap.java index dd9e1d86e..effdd33b0 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatisticsUnitTest.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusCoverageGap.java @@ -44,78 +44,34 @@ * 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. */ -package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; -import net.sf.samtools.SAMFileHeader; -import org.broadinstitute.sting.utils.GenomeLoc; -import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.broadinstitute.sting.utils.sam.GATKSAMRecord; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.LocusStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; -public class SampleStatisticsUnitTest/* extends BaseTest */ { +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class LocusCoverageGap implements Locus { + private double threshold; + private static final CallableStatus CALL = CallableStatus.COVERAGE_GAPS; - @DataProvider(name = "QuartileValues") - public Object[][] getQuantileValues() { - - int[] a1 = {5}; - int[] a2 = {1, 2}; - int[] a5 = {10, 20, 30, 40, 50}; - int[] a10 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - - - return new Object[][]{ - new Object[]{a1, 0.5, 5}, - new Object[]{a1, 0, 5}, - new Object[]{a1, 1, 5}, - new Object[]{a2, 0.5, 1.5}, - new Object[]{a2, 0.25, 1}, - new Object[]{a2, 0.75, 2}, - new Object[]{a5, 0.5, 30}, - new Object[]{a5, 0.25, 20}, - new Object[]{a5, 0.75, 40}, - new Object[]{a5, 0, -1}, - new Object[]{a10, 0.5, 5.5}, - new Object[]{a10, 0.25, 3}, - new Object[]{a10, 0.75, 8} - }; + @Override + public void initialize(ThresHolder thresholds) { + threshold = thresholds.coverageStatusThreshold; } - @Test(dataProvider = "QuartileValues") - public void testGetQuartile(int[] dataList, double percentage, double expected) { - Assert.assertEquals(SampleStatistics.getQuartile(dataList, percentage), expected); - + @Override + public CallableStatus status(LocusStatistics locusStatistics) { + return locusStatistics.getRawCoverage() == 0 ? CALL : null; } - @DataProvider(name = "ReadsAndMates") - public Object[][] getReadAndMates() { - SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); - - GATKSAMRecord noPair = ArtificialSAMUtils.createArtificialRead(header, "test", 0, 100, 50); - GATKSAMRecord good = ArtificialSAMUtils.createPair(header, "test", 30, 100, 150, true, false).get(0); - GATKSAMRecord bigInsertSize = ArtificialSAMUtils.createPair(header, "test", 30, 100, 151, true, false).get(0); -// GATKSAMRecord inverted = ArtificialSAMUtils.createPair(header, "test", 30, 151, 150, true, false).get(0); - GATKSAMRecord sameOrientation = ArtificialSAMUtils.createPair(header, "test", 30, 100, 151, true, true).get(0); - - GATKSAMRecord pairNotMapped = ArtificialSAMUtils.createPair(header, "test", 30, 100, 140, true, false).get(1); - pairNotMapped.setMateUnmappedFlag(true); - - // finish test - return new Object[][]{ - new Object[]{noPair, false}, - new Object[]{good, true}, - new Object[]{bigInsertSize, false}, -// new Object[]{inverted, false}, - new Object[]{sameOrientation, false}, - new Object[]{pairNotMapped, false} - }; + @Override + public CallableStatus sampleStatus(SampleStatistics sampleStatistics) { + return PluginUtils.genericSampleStatus(sampleStatistics, CALL, threshold); } - - @Test(dataProvider = "ReadsAndMates") - public void testHasValidMate(GATKSAMRecord read, boolean expected) { - //50 is out maximum insert size - Assert.assertEquals(new SampleStatistics(GenomeLoc.UNMAPPED).hasValidMate(read, ThresHolder.DEFAULTS), expected); - } - } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusExcessiveCoverage.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusExcessiveCoverage.java new file mode 100644 index 000000000..72709a0f6 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusExcessiveCoverage.java @@ -0,0 +1,79 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.LocusStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class LocusExcessiveCoverage implements Locus { + private int excessiveCoverage; + private double threshold; + private static final CallableStatus CALL = CallableStatus.EXCESSIVE_COVERAGE ; + + @Override + public void initialize(ThresHolder thresholds) { + this.excessiveCoverage = thresholds.maximumCoverage; + this.threshold = thresholds.coverageStatusThreshold; + } + + @Override + public CallableStatus status(LocusStatistics locusStatistics) { + return locusStatistics.getCoverage() > excessiveCoverage ? CALL : null; + } + + @Override + public CallableStatus sampleStatus(SampleStatistics sampleStatistics) { + return PluginUtils.genericSampleStatus(sampleStatistics, CALL, threshold); + } +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusLowCoverage.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusLowCoverage.java new file mode 100644 index 000000000..f3f181bd1 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusLowCoverage.java @@ -0,0 +1,80 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.LocusStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class LocusLowCoverage implements Locus { + private int minCoverage; + private double threshold; + private static final CallableStatus CALL = CallableStatus.LOW_COVERAGE ; + + @Override + public void initialize(ThresHolder thresholds) { + this.minCoverage = thresholds.minimumCoverage; + this.threshold = thresholds.coverageStatusThreshold; + } + + @Override + public CallableStatus status(LocusStatistics locusStatistics) { + final int raw = locusStatistics.getRawCoverage(); + return raw > 0 && raw < minCoverage ? CALL: null; + } + + @Override + public CallableStatus sampleStatus(SampleStatistics sampleStatistics) { + return PluginUtils.genericSampleStatus(sampleStatistics, CALL, threshold); + } +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusPoorQuality.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusPoorQuality.java new file mode 100644 index 000000000..91d5f8c04 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/LocusPoorQuality.java @@ -0,0 +1,79 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.LocusStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class LocusPoorQuality implements Locus { + private int minCoverage; + private double threshold; + private static final CallableStatus CALL = CallableStatus.POOR_QUALITY ; + + @Override + public void initialize(ThresHolder thresholds) { + this.minCoverage = thresholds.minimumCoverage; + this.threshold = thresholds.coverageStatusThreshold; + } + + @Override + public CallableStatus status(LocusStatistics locusStatistics) { + return locusStatistics.getCoverage() < minCoverage && locusStatistics.getRawCoverage() >= minCoverage ? CALL: null; + } + + @Override + public CallableStatus sampleStatus(SampleStatistics sampleStatistics) { + return PluginUtils.genericSampleStatus(sampleStatistics, CALL, threshold); + } +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/PluginUtils.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/PluginUtils.java new file mode 100644 index 000000000..0a29aea4d --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/PluginUtils.java @@ -0,0 +1,66 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; + +import java.util.Map; + +/** + * User: carneiro + * Date: 4/21/13 + * Time: 11:23 AM + */ +public class PluginUtils { + public static CallableStatus genericSampleStatus (final SampleStatistics sampleStatistics, final CallableStatus CALL, final double threshold) { + final Map totals = sampleStatistics.getLocusStatusTally(); + final int size = sampleStatistics.getIntervalSize(); + final int statusCount = totals.containsKey(CALL) ? totals.get(CALL) : 0; + return ( (double) statusCount / size) >= threshold ? CALL: null; + } +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Sample.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Sample.java new file mode 100644 index 000000000..a33c33877 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/Sample.java @@ -0,0 +1,63 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * Created with IntelliJ IDEA. + * User: carneiro + * Date: 4/20/13 + * Time: 11:30 PM + * To change this template use File | Settings | File Templates. + */ +public interface Sample { + public void initialize(ThresHolder thresholds); + public CallableStatus status (SampleStatistics sampleStatistics); +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleBadMates.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleBadMates.java new file mode 100644 index 000000000..07e2cca5a --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleBadMates.java @@ -0,0 +1,76 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class SampleBadMates implements Sample { + private static final CallableStatus CALL = CallableStatus.NO_READS ; + + private double threshold; + private double votingThreshold; + + @Override + public void initialize(ThresHolder thresholds) { + threshold = thresholds.badMateStatusThreshold; + votingThreshold = thresholds.votePercentageThreshold; + } + + @Override + public CallableStatus status(SampleStatistics sampleStatistics) { + final int nReads = sampleStatistics.getnReads(); + return nReads > 0 && (double) sampleStatistics.getnBadMates() / nReads > threshold ? CALL : null; + } + +} diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleNoReads.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleNoReads.java new file mode 100644 index 000000000..30a6fbda3 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/statistics/SampleNoReads.java @@ -0,0 +1,73 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.gatk.walkers.diagnostics.targets.statistics; + +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.CallableStatus; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.SampleStatistics; +import org.broadinstitute.sting.gatk.walkers.diagnostics.targets.ThresHolder; + +/** + * User: carneiro + * Date: 4/20/13 + * Time: 11:44 PM + */ +public class SampleNoReads implements Sample { + private static final CallableStatus CALL = CallableStatus.NO_READS; + + private double votingThreshold; + + @Override + public void initialize(ThresHolder thresholds) { + votingThreshold = thresholds.votePercentageThreshold; + } + + @Override + public CallableStatus status(SampleStatistics sampleStatistics) { + return sampleStatistics.getnReads() == 0 ? CALL : null; + } + +} diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java index ef14f8386..e5cea2c7b 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java @@ -66,11 +66,11 @@ public class DiagnoseTargetsIntegrationTest extends WalkerTest { @Test(enabled = true) public void testSingleSample() { - DTTest("testSingleSample ", "-I " + singleSample + " -max 75", "742c13fc092b42f9ff71fc3fff4a95cc"); + DTTest("testSingleSample ", "-I " + singleSample + " -max 75", "850304909477afa8c2a8f128d6eedde9"); } @Test(enabled = true) public void testMultiSample() { - DTTest("testMultiSample ", "-I " + multiSample, "7083cc720a2caa02fb0fa8f49f94a826"); + DTTest("testMultiSample ", "-I " + multiSample, "bedd19bcf21d1a779f6706c0351c9d26"); } } diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatisticsUnitTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatisticsUnitTest.java index c86acebb9..96747619f 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatisticsUnitTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/LocusStatisticsUnitTest.java @@ -47,37 +47,43 @@ package org.broadinstitute.sting.gatk.walkers.diagnostics.targets; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.util.Set; -public class LocusStatisticsUnitTest /*extends BaseTest*/ { +public class LocusStatisticsUnitTest { + + ThresHolder thresholds = new ThresHolder(); + + @BeforeClass + public void init() { + DiagnoseTargets.loadAllPlugins(thresholds); + } @Test(dataProvider = "StatusTestValues") public void testCallableStatuses(int coverage, int rawCoverage, CallableStatus status) { - // The min Coverage threshold is 10, the max is 100 - ThresHolder thresholds = new ThresHolder(20, 20, 10, 100, 50, 0.5, 0.5, 0.2, 0.2, 0.5); - Set statuses = new LocusStatistics(coverage, rawCoverage).callableStatuses(thresholds); - // Check to make sure the status provides matches the actual + Set statuses = new LocusStatistics(coverage, rawCoverage, thresholds).callableStatuses(); Assert.assertTrue((status == null) ? statuses.isEmpty() : (statuses.contains(status) && statuses.size() == 1)); - } @DataProvider(name = "StatusTestValues") public Object[][] getStatusTestValues() { + final int max = thresholds.maximumCoverage; + final int min = thresholds.minimumCoverage; return new Object[][]{ - new Object[]{100, 100, null}, - new Object[]{100, 101, null}, - new Object[]{101, 101, CallableStatus.EXCESSIVE_COVERAGE}, - new Object[]{10, 101, null}, - new Object[]{9, 101, CallableStatus.POOR_QUALITY}, - new Object[]{9, 10, CallableStatus.POOR_QUALITY}, - new Object[]{9, 9, CallableStatus.LOW_COVERAGE}, + new Object[]{max, max, null}, + new Object[]{max, max+1, null}, + new Object[]{max+1, max+1, CallableStatus.EXCESSIVE_COVERAGE}, + new Object[]{min, max+1, null}, + new Object[]{min-1, max+1, CallableStatus.POOR_QUALITY}, + new Object[]{min-1, min, CallableStatus.POOR_QUALITY}, + new Object[]{min-1, min-1, CallableStatus.LOW_COVERAGE}, new Object[]{0, 0, CallableStatus.COVERAGE_GAPS}, - new Object[]{0, 9, CallableStatus.LOW_COVERAGE}, - new Object[]{0, 101, CallableStatus.POOR_QUALITY}, - new Object[]{10, Integer.MAX_VALUE, null}, + new Object[]{0, min-1, CallableStatus.LOW_COVERAGE}, + new Object[]{0, max+1, CallableStatus.POOR_QUALITY}, + new Object[]{min, Integer.MAX_VALUE, null}, new Object[]{Integer.MAX_VALUE, Integer.MAX_VALUE, CallableStatus.EXCESSIVE_COVERAGE}, }; }