From 9321181cc53336c67a728053bf5da42bf36c77ae Mon Sep 17 00:00:00 2001 From: tmelman <22672518+tmelman@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:01:55 -0400 Subject: [PATCH] require reference as asserted in documentation (#8067) * require reference as asserted in documentation : * Subbed File.createTempFile for BaseTest.createTempFile * Changed args from list to ArgumentBuilder --- .../utils/MergeAnnotatedRegions.java | 5 ++++ .../MergeAnnotatedRegionsIntegrationTest.java | 27 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegions.java b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegions.java index 44074119279..55074512734 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegions.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegions.java @@ -36,6 +36,11 @@ public class MergeAnnotatedRegions extends GATKTool { final static String DEFAULT_SEPARATOR = "__"; + @Override + public boolean requiresReference() { + return true; + } + @Override public void traverse() { diff --git a/src/test/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegionsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegionsIntegrationTest.java index 6be89bfe56f..624b9e55337 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegionsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/copynumber/utils/MergeAnnotatedRegionsIntegrationTest.java @@ -1,12 +1,15 @@ package org.broadinstitute.hellbender.tools.copynumber.utils; import com.google.common.collect.ImmutableSortedMap; +import org.broadinstitute.barclay.argparser.CommandLineException; import org.broadinstitute.hellbender.CommandLineProgramTest; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; import org.broadinstitute.hellbender.tools.copynumber.arguments.CopyNumberStandardArgument; import org.broadinstitute.hellbender.tools.copynumber.utils.annotatedinterval.AnnotatedInterval; import org.broadinstitute.hellbender.tools.copynumber.utils.annotatedinterval.AnnotatedIntervalCollection; import org.broadinstitute.hellbender.utils.SimpleInterval; +import org.broadinstitute.hellbender.testutils.BaseTest; +import org.broadinstitute.hellbender.testutils.ArgumentsBuilder; import org.testng.Assert; import org.testng.annotations.Test; @@ -23,14 +26,11 @@ public class MergeAnnotatedRegionsIntegrationTest extends CommandLineProgramTest @Test public void basicTest() throws IOException { // This test is a bit more like the real world - final File outputFile = File.createTempFile("mergeannotatedregions", ".seg"); - final List arguments = new ArrayList<>(); - arguments.add("--" + CopyNumberStandardArgument.SEGMENTS_FILE_LONG_NAME); - arguments.add(SIMPLE_TEST_FILE); - arguments.add("--" + StandardArgumentDefinitions.REFERENCE_LONG_NAME); - arguments.add(REF); - arguments.add("-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME); - arguments.add(outputFile.getAbsolutePath()); + final File outputFile = BaseTest.createTempFile("mergeannotatedregions", ".seg"); + final ArgumentsBuilder arguments = new ArgumentsBuilder(); + arguments.add(CopyNumberStandardArgument.SEGMENTS_FILE_LONG_NAME, SIMPLE_TEST_FILE); + arguments.add(StandardArgumentDefinitions.REFERENCE_LONG_NAME, REF); + arguments.add(StandardArgumentDefinitions.OUTPUT_SHORT_NAME, outputFile.getAbsolutePath()); runCommandLine(arguments); final AnnotatedIntervalCollection collection = @@ -50,4 +50,15 @@ public void basicTest() throws IOException { Assert.assertEquals(collection.getRecords().get(4), new AnnotatedInterval(new SimpleInterval("2", 1098, 2305), ImmutableSortedMap.of("Num_Probes", "200", "Segment_Mean", "-0.10", "Segment_Call", "0"))); } + + @Test(expectedExceptions = CommandLineException.class) + public void requiresReferenceTest() throws IOException { + // This test is a bit more like the real world + final File outputFile = BaseTest.createTempFile("mergeannotatedregions", ".seg"); + final ArgumentsBuilder arguments = new ArgumentsBuilder(); + arguments.add(CopyNumberStandardArgument.SEGMENTS_FILE_LONG_NAME, SIMPLE_TEST_FILE); + arguments.add(StandardArgumentDefinitions.OUTPUT_SHORT_NAME, outputFile.getAbsolutePath()); + runCommandLine(arguments); + } + }