From bee7f655b7f8f01bf4885b69a089ff28d2e3cfba Mon Sep 17 00:00:00 2001 From: Ron Levine Date: Sat, 7 Mar 2015 21:53:32 -0500 Subject: [PATCH] Log a warning if using incompatible arguments in DepthOfCoverage Add reference gene list file --- .../walkers/coverage/DepthOfCoverage.java | 18 +++++++++- .../DepthOfCoverageIntegrationTest.java | 33 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverage.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverage.java index 20c480901..92395a4f9 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverage.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverage.java @@ -26,6 +26,7 @@ package org.broadinstitute.gatk.tools.walkers.coverage; import htsjdk.samtools.SAMReadGroupRecord; +import org.apache.log4j.Logger; import org.broadinstitute.gatk.engine.walkers.*; import org.broadinstitute.gatk.utils.commandline.*; import org.broadinstitute.gatk.engine.CommandLineGATK; @@ -108,7 +109,6 @@ import java.util.*; * [-ct 4 -ct 6 -ct 10] \ * [-L my_capture_genes.interval_list] * - * */ // todo -- cache the map from sample names to means in the print functions, rather than regenerating each time // todo -- support for granular histograms for total depth; maybe n*[start,stop], bins*sqrt(n) @@ -120,6 +120,13 @@ import java.util.*; @PartitionBy(PartitionType.NONE) @Downsample(by= DownsampleType.NONE, toCoverage=Integer.MAX_VALUE) public class DepthOfCoverage extends LocusWalker>, CoveragePartitioner> implements TreeReducible { + private final static Logger logger = Logger.getLogger(DepthOfCoverage.class); + + /** + * Warning message for when the incompatible arguments --calculateCoverageOverGenes and --omitIntervalStatistics are used together. + */ + private static final String incompatibleArgsMsg = "The arguments --calculateCoverageOverGenes and --omitIntervalStatistics are incompatible. Using them together will result in an empty gene summary output file."; + @Output @Multiplex(value=DoCOutputMultiplexer.class,arguments={"partitionTypes","refSeqGeneList","omitDepthOutput","omitIntervals","omitSampleSummary","omitLocusTable"}) Map out; @@ -172,6 +179,9 @@ public class DepthOfCoverage extends LocusWalker(Arrays.asList(bams)),new ArrayList<>(Arrays.asList(intervals))) + " --omitIntervalStatistics --calculateCoverageOverGenes " + refSeqGeneListFile + " -log " + logFileName; + final WalkerTestSpec spec = new WalkerTestSpec(cmd,0, new ArrayList()); + + // output file + final File outputFile = createTempFile("DepthOfCoverageIncompatibleArgs",".tmp"); + spec.setOutputFileLocation(outputFile); + + execute("testIncompatibleArgs",spec); + + // check that only the sample gene summary output file is empty + Assert.assertEquals( createTempFileFromBase(outputFile.getAbsolutePath()+".sample_gene_summary").length(), 0 ); + Assert.assertNotEquals( createTempFileFromBase(outputFile.getAbsolutePath()+".sample_cumulative_coverage_counts").length(), 0 ); + Assert.assertNotEquals( createTempFileFromBase(outputFile.getAbsolutePath()+".sample_cumulative_coverage_proportions").length(), 0 ); + Assert.assertNotEquals( createTempFileFromBase(outputFile.getAbsolutePath()+".sample_statistics").length(), 0 ); + Assert.assertNotEquals( createTempFileFromBase(outputFile.getAbsolutePath()+".sample_summary").length(), 0 ); + + // check the log for the warning message + File file = new File(logFileName); + Assert.assertTrue(FileUtils.readFileToString(file).contains(DepthOfCoverage.incompatibleArgsMsg())); + } }