Skip to content

Commit f6052af

Browse files
committed
test proportion argument
1 parent 9ccb1e6 commit f6052af

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class DownsampleVcf
194194
@arg(flag='p', doc="Proportion of bases to retain (for single-sample VCF).") val proportion: Option[Double] = None,
195195
@arg(flag='b', doc="Original number of bases (for single-sample VCF).") val originalBases: Option[Double] = None,
196196
@arg(flag='m', doc="Index file with bases per sample.") val metadata: Option[FilePath] = None,
197-
@arg(flag='n', doc="Target number of bases to downsample to.") val downsampleToBases: Option[Double],
197+
@arg(flag='n', doc="Target number of bases to downsample to.") val downsampleToBases: Option[Double] = None,
198198
@arg(flag='o', doc="Output file name.") val output: PathToVcf,
199199
@arg(flag='w', doc="Winnowing window size.") val windowSize: Int = 0,
200200
@arg(flag='e', doc="Sequencing Error rate for genotyping.") val epsilon: Double = 0.01,

src/test/scala/com/fulcrumgenomics/vcf/DownsampleVcfTest.scala

+43-30
Original file line numberDiff line numberDiff line change
@@ -369,22 +369,28 @@ class DownsampleVcfTest extends UnitSpec {
369369
Metric.write(metadata, Seq(Sample(SAMPLE_NAME = sample, BASE_COUNT = 100)))
370370

371371
"DownsampleVcf" should "write a new vcf with downsampled genotypes when provided a vcf" in {
372-
List(true, false).foreach(
373-
use_metdata => {
372+
List("proportion", "number", "metadata").foreach(
373+
kind => {
374374
// Construct the input VCF
375375
val outVcf = makeTempFile("out", ".vcf.gz")
376-
if(use_metdata) {
377-
new DownsampleVcf(input=inVcf,
378-
output=outVcf,
379-
metadata=Some(metadata),
380-
downsampleToBases=Some(1),
381-
windowSize=150).execute()
382-
} else {
383-
new DownsampleVcf(input=inVcf,
384-
output=outVcf,
385-
originalBases=Some(100),
386-
downsampleToBases=Some(1),
387-
windowSize=150).execute()
376+
kind match {
377+
case "proportion" =>
378+
new DownsampleVcf(input=inVcf,
379+
output=outVcf,
380+
proportion=Some(0.01),
381+
windowSize=150).execute()
382+
case "number" =>
383+
new DownsampleVcf(input=inVcf,
384+
output=outVcf,
385+
originalBases=Some(100),
386+
downsampleToBases=Some(1),
387+
windowSize=150).execute()
388+
case "metadata" =>
389+
new DownsampleVcf(input=inVcf,
390+
output=outVcf,
391+
metadata=Some(metadata),
392+
downsampleToBases=Some(1),
393+
windowSize=150).execute()
388394
}
389395

390396
val vs = readVcfRecs(outVcf)
@@ -428,24 +434,31 @@ class DownsampleVcfTest extends UnitSpec {
428434

429435
"DownsampleVcf" should "write a new vcf with downsampled genotypes when provided a vcf, keeping nocalls" in {
430436
// Construct the input VCF
431-
List(true, false).foreach(
432-
use_metdata => {
437+
List("proportion", "number", "metadata").foreach(
438+
kind => {
433439
// Construct the input VCF
434440
val outVcf = makeTempFile("out", ".vcf.gz")
435-
if (use_metdata) {
436-
new DownsampleVcf(input=inVcf,
437-
output=outVcf,
438-
metadata=Some(metadata),
439-
downsampleToBases=Some(1),
440-
writeNoCall=true,
441-
windowSize=150).execute()
442-
} else {
443-
new DownsampleVcf(input=inVcf,
444-
output=outVcf,
445-
originalBases=Some(100),
446-
downsampleToBases=Some(1),
447-
writeNoCall=true,
448-
windowSize=150).execute()
441+
kind match {
442+
case "proportion" =>
443+
new DownsampleVcf(input=inVcf,
444+
output=outVcf,
445+
proportion=Some(0.01),
446+
writeNoCall=true,
447+
windowSize=150).execute()
448+
case "number" =>
449+
new DownsampleVcf(input=inVcf,
450+
output=outVcf,
451+
originalBases=Some(100),
452+
downsampleToBases=Some(1),
453+
writeNoCall=true,
454+
windowSize=150).execute()
455+
case "metadata" =>
456+
new DownsampleVcf(input=inVcf,
457+
output=outVcf,
458+
metadata=Some(metadata),
459+
downsampleToBases=Some(1),
460+
writeNoCall=true,
461+
windowSize=150).execute()
449462
}
450463

451464
val vs = readVcfRecs(outVcf)

0 commit comments

Comments
 (0)