@@ -5,6 +5,7 @@ import com.fulcrumgenomics.commons.io.Io
5
5
import com .fulcrumgenomics .commons .util .LazyLogging
6
6
import com .fulcrumgenomics .fasta .SequenceDictionary
7
7
import com .fulcrumgenomics .sopt .{arg , clp }
8
+ import com .fulcrumgenomics .sopt .cmdline .ValidationException
8
9
import com .fulcrumgenomics .util .{Metric , ProgressLogger }
9
10
import com .fulcrumgenomics .vcf .api .Allele .NoCallAllele
10
11
import com .fulcrumgenomics .vcf .api .{Allele , Genotype , Variant , VcfCount , VcfFieldType , VcfFormatHeader , VcfHeader , VcfSource , VcfWriter }
@@ -241,24 +242,24 @@ class DownsampleVcf
241
242
) extends FgBioTool {
242
243
Io .assertReadable(input)
243
244
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" )
246
247
(proportion, originalBases, metadata, downsampleToBases) match {
247
248
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" )
250
251
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" )
253
254
case (None , None , Some (metadata), Some (target)) =>
254
255
Io .assertReadable(metadata)
255
256
require(target > 0 , " target base count must be greater than zero" )
256
257
case (None , _, _, None ) =>
257
- throw new IllegalArgumentException (
258
+ throw new ValidationException (
258
259
" exactly one of proportion or downsampleToBases must be specified"
259
260
)
260
261
case _ =>
261
- throw new IllegalArgumentException (
262
+ throw new ValidationException (
262
263
" exactly one of proportion, originalBases, or metadata must be specified"
263
264
)
264
265
}
0 commit comments