Merge pull request #862 from broadinstitute/rhl_doc_args_incompatibility

Log a warning if using incompatible arguments in DepthOfCoverage
This commit is contained in:
Geraldine Van der Auwera 2015-03-11 13:08:53 -04:00
commit e1862a04a8
2 changed files with 50 additions and 1 deletions

View File

@ -26,6 +26,7 @@
package org.broadinstitute.gatk.tools.walkers.coverage; package org.broadinstitute.gatk.tools.walkers.coverage;
import htsjdk.samtools.SAMReadGroupRecord; import htsjdk.samtools.SAMReadGroupRecord;
import org.apache.log4j.Logger;
import org.broadinstitute.gatk.engine.walkers.*; import org.broadinstitute.gatk.engine.walkers.*;
import org.broadinstitute.gatk.utils.commandline.*; import org.broadinstitute.gatk.utils.commandline.*;
import org.broadinstitute.gatk.engine.CommandLineGATK; import org.broadinstitute.gatk.engine.CommandLineGATK;
@ -108,7 +109,6 @@ import java.util.*;
* [-ct 4 -ct 6 -ct 10] \ * [-ct 4 -ct 6 -ct 10] \
* [-L my_capture_genes.interval_list] * [-L my_capture_genes.interval_list]
* </pre> * </pre>
*
*/ */
// todo -- cache the map from sample names to means in the print functions, rather than regenerating each time // 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) // 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) @PartitionBy(PartitionType.NONE)
@Downsample(by= DownsampleType.NONE, toCoverage=Integer.MAX_VALUE) @Downsample(by= DownsampleType.NONE, toCoverage=Integer.MAX_VALUE)
public class DepthOfCoverage extends LocusWalker<Map<DoCOutputType.Partition,Map<String,int[]>>, CoveragePartitioner> implements TreeReducible<CoveragePartitioner> { public class DepthOfCoverage extends LocusWalker<Map<DoCOutputType.Partition,Map<String,int[]>>, CoveragePartitioner> implements TreeReducible<CoveragePartitioner> {
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 @Output
@Multiplex(value=DoCOutputMultiplexer.class,arguments={"partitionTypes","refSeqGeneList","omitDepthOutput","omitIntervals","omitSampleSummary","omitLocusTable"}) @Multiplex(value=DoCOutputMultiplexer.class,arguments={"partitionTypes","refSeqGeneList","omitDepthOutput","omitIntervals","omitSampleSummary","omitLocusTable"})
Map<DoCOutputType,PrintStream> out; Map<DoCOutputType,PrintStream> out;
@ -172,6 +179,9 @@ public class DepthOfCoverage extends LocusWalker<Map<DoCOutputType.Partition,Map
/** /**
* Specify a RefSeq file for use in aggregating coverage statistics over genes. * Specify a RefSeq file for use in aggregating coverage statistics over genes.
*
* A warning will be logged and no output file will be produced if --calculateCoverageOverGenes and --omitIntervalStatistics are enabled.
*
*/ */
@Argument(fullName = "calculateCoverageOverGenes", shortName = "geneList", doc = "Calculate coverage statistics over this list of genes", required = false) @Argument(fullName = "calculateCoverageOverGenes", shortName = "geneList", doc = "Calculate coverage statistics over this list of genes", required = false)
File refSeqGeneList = null; File refSeqGeneList = null;
@ -259,8 +269,14 @@ public class DepthOfCoverage extends LocusWalker<Map<DoCOutputType.Partition,Map
public boolean includeReadsWithDeletionAtLoci() { return includeDeletions && ! ignoreDeletionSites; } public boolean includeReadsWithDeletionAtLoci() { return includeDeletions && ! ignoreDeletionSites; }
public static String incompatibleArgsMsg() { return incompatibleArgsMsg; }
public void initialize() { public void initialize() {
if ( omitIntervals && refSeqGeneList != null ){
logger.warn(incompatibleArgsMsg);
}
if ( printBinEndpointsAndExit ) { if ( printBinEndpointsAndExit ) {
int[] endpoints = DepthOfCoverageStats.calculateBinEndpoints(start,stop,nBins); int[] endpoints = DepthOfCoverageStats.calculateBinEndpoints(start,stop,nBins);
System.out.print("[ "); System.out.print("[ ");

View File

@ -27,8 +27,12 @@ package org.broadinstitute.gatk.tools.walkers.coverage;
import org.broadinstitute.gatk.engine.walkers.WalkerTest; import org.broadinstitute.gatk.engine.walkers.WalkerTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.testng.Assert;
import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -178,4 +182,33 @@ public class DepthOfCoverageIntegrationTest extends WalkerTest {
@Test public void testRefNWithNs() { testRefNHandling(true, "24cd2da2e4323ce6fd76217ba6dc2834"); } @Test public void testRefNWithNs() { testRefNHandling(true, "24cd2da2e4323ce6fd76217ba6dc2834"); }
@Test public void testRefNWithoutNs() { testRefNHandling(false, "4fc0f1a2e968f777d693abcefd4fb7af"); } @Test public void testRefNWithoutNs() { testRefNHandling(false, "4fc0f1a2e968f777d693abcefd4fb7af"); }
@Test
public void testIncompatibleArgs() throws IOException {
final String[] intervals = {"/humgen/gsa-hpprojects/GATK/data/Validation_Data/fhs_jhs_30_targts.interval_list"};
final String[] bams = {"/humgen/gsa-hpprojects/GATK/data/Validation_Data/FHS_indexed_subset.bam"};
final String refSeqGeneListFile = privateTestDir + "geneTrackHg18Chr1Interval.refSeq";
final String logFileName = new String("testIncompatibleArgs.log");
final String cmd = buildRootCmd(hg18Reference,new ArrayList<>(Arrays.asList(bams)),new ArrayList<>(Arrays.asList(intervals))) + " --omitIntervalStatistics --calculateCoverageOverGenes " + refSeqGeneListFile + " -log " + logFileName;
final WalkerTestSpec spec = new WalkerTestSpec(cmd,0, new ArrayList<String>());
// 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()));
}
} }