@@ -3,6 +3,7 @@ package kscript.test
33import io.kotlintest.matchers.shouldBe
44import io.kotlintest.specs.StringSpec
55import kscript.DocOpt
6+ import java.io.File
67
78/* *
89 * @author Holger Brandl
@@ -11,27 +12,37 @@ import kscript.DocOpt
1112
1213class DocOptTest : StringSpec () { init {
1314
14- val args = " -n 7 --pc-only --gtf my.gtf a.fastq b.fastq" .split(" " ).toTypedArray()
1515
1616 val usage = """
1717Use star to align fastq files against a genome
1818Usage: star_align.kts [options] <igenome> <fastq_files>...
1919
2020Options:
21- --gtf <gtfFile> Custom gtf file instead of igenome bundled copy
22- --pc-only Use protein coding genes only for mapping and quantification
23- -n --num-fragments Fragment count used for processing [default: 5]
21+ --gtf <gtfFile> Custom gtf file instead of igenome bundled copy
22+ --pc-only Use protein coding genes only for mapping and quantification
23+ -n --num-fragments <num_frags> Fragment count used for processing [default: 5]
2424"""
2525
26+ val args = " -n 7 --pc-only --gtf my.gtf genome.fasta a.fastq b.fastq" .split(" " ).toTypedArray()
27+
28+
2629 val docopt = DocOpt (args, usage)
2730
31+
32+ // optional arg
2833 docopt.getString(" gtf" ) shouldBe " my.gtf"
29- docopt.getStrings(" fastq_files" ) shouldBe arrayOf(" a.fastq" , " b.fastq" )
34+ docopt.getFile(" gtf" ) shouldBe File (" my.gtf" )
35+
36+ // mandatory arg
37+ docopt.getString(" igenome" ) shouldBe " genome.fasta"
38+ docopt.getFile(" igenome" ) shouldBe File (" genome.fasta" )
39+
40+ docopt.getStrings(" fastq_files" ) shouldBe listOf (" a.fastq" , " b.fastq" )
41+ docopt.getFiles(" fastq_files" ) shouldBe listOf (File (" a.fastq" ), File (" b.fastq" ))
42+
3043
31- docopt.getInt(" fastq_files" )
32- docopt.getNumber(" num-fragments" ) shouldBe 7
33- docopt.getNumber(" num-fragments" ) shouldBe 7
34- docopt.getNumber(" -n" )
44+ docopt.getInt(" num-fragments" ) shouldBe 7
45+ docopt.getNumber(" num-fragments" ).toString() shouldBe " 7.0"
3546 docopt.getBoolean(" pc-only" ) shouldBe true
3647}
3748}
0 commit comments