Skip to content

Commit a349bdc

Browse files
authored
Update DownsampleVcf.scala
1 parent bdcee25 commit a349bdc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/main/scala/com/fulcrumgenomics/vcf/DownsampleVcf.scala

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.fulcrumgenomics.commons.io.Io
55
import com.fulcrumgenomics.commons.util.LazyLogging
66
import com.fulcrumgenomics.fasta.SequenceDictionary
77
import com.fulcrumgenomics.sopt.{arg, clp}
8+
import com.fulcrumgenomics.sopt.cmdline.ValidationException
89
import com.fulcrumgenomics.util.{Metric, ProgressLogger}
910
import com.fulcrumgenomics.vcf.api.Allele.NoCallAllele
1011
import com.fulcrumgenomics.vcf.api.{Allele, Genotype, Variant, VcfCount, VcfFieldType, VcfFormatHeader, VcfHeader, VcfSource, VcfWriter}
@@ -241,24 +242,24 @@ class DownsampleVcf
241242
) extends FgBioTool {
242243
Io.assertReadable(input)
243244
Io.assertCanWriteFile(output)
244-
require(windowSize >= 0, "window size must be greater than or equal to zero")
245-
require(0 <= epsilon && epsilon <= 1, "epsilon/error rate must be between 0 and 1")
245+
validate(windowSize >= 0, "window size must be greater than or equal to zero")
246+
validate(0 <= epsilon && epsilon <= 1, "epsilon/error rate must be between 0 and 1")
246247
(proportion, originalBases, metadata, downsampleToBases) match {
247248
case (Some(x), None, None, None) =>
248-
require(x > 0, "proportion must be greater than 0")
249-
require(x < 1, "proportion must be less than 1")
249+
validate(x > 0, "proportion must be greater than 0")
250+
validate(x < 1, "proportion must be less than 1")
250251
case (None, Some(original), None, Some(target)) =>
251-
require(original > 0, "originalBases must be greater than zero")
252-
require(target > 0, "target base count must be greater than zero")
252+
validate(original > 0, "originalBases must be greater than zero")
253+
validate(target > 0, "target base count must be greater than zero")
253254
case (None, None, Some(metadata), Some(target)) =>
254255
Io.assertReadable(metadata)
255256
require(target > 0, "target base count must be greater than zero")
256257
case (None, _, _, None) =>
257-
throw new IllegalArgumentException(
258+
throw new ValidationException(
258259
"exactly one of proportion or downsampleToBases must be specified"
259260
)
260261
case _ =>
261-
throw new IllegalArgumentException(
262+
throw new ValidationException(
262263
"exactly one of proportion, originalBases, or metadata must be specified"
263264
)
264265
}

0 commit comments

Comments
 (0)