Commit 09fa0b3f authored by bow's avatar bow

Merge branch 'fix-exit_calls' into 'develop'

Changes arg parser with getOrElse(throw new IllegalArgumentException)

Fixes #342 

See merge request !402
parents 29a84a74 c97f4ed7
...@@ -132,7 +132,7 @@ trait ReportBuilder extends ToolCommand { ...@@ -132,7 +132,7 @@ trait ReportBuilder extends ToolCommand {
logger.info("Start") logger.info("Start")
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
require(cmdArgs.outputDir.exists(), "Output dir does not exist") require(cmdArgs.outputDir.exists(), "Output dir does not exist")
require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory") require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory")
......
...@@ -80,7 +80,7 @@ object AnnotateVcfWithBed extends ToolCommand { ...@@ -80,7 +80,7 @@ object AnnotateVcfWithBed extends ToolCommand {
logger.info("Start") logger.info("Start")
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val fieldType = cmdArgs.fieldType match { val fieldType = cmdArgs.fieldType match {
case "Integer" => VCFHeaderLineType.Integer case "Integer" => VCFHeaderLineType.Integer
......
...@@ -53,10 +53,7 @@ object BaseCounter extends ToolCommand { ...@@ -53,10 +53,7 @@ object BaseCounter extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) match { val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
case Some(x) => x
case _ => throw new IllegalArgumentException
}
//Sets picard logging level //Sets picard logging level
htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.valueOf(logger.getLevel.toString)) htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.valueOf(logger.getLevel.toString))
......
...@@ -113,7 +113,7 @@ object BastyGenerateFasta extends ToolCommand { ...@@ -113,7 +113,7 @@ object BastyGenerateFasta extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
cmdArgs = argsParser.parse(args, Args()) getOrElse sys.exit(1) cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (cmdArgs.outputVariants != null) { if (cmdArgs.outputVariants != null) {
writeVariantsOnly() writeVariantsOnly()
......
...@@ -47,7 +47,7 @@ object BedToInterval extends ToolCommand { ...@@ -47,7 +47,7 @@ object BedToInterval extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val writer = new PrintWriter(commandArgs.outputFile) val writer = new PrintWriter(commandArgs.outputFile)
......
...@@ -39,7 +39,7 @@ object BedtoolsCoverageToCounts extends ToolCommand { ...@@ -39,7 +39,7 @@ object BedtoolsCoverageToCounts extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input) if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
...@@ -50,7 +50,7 @@ object BiopetFlagstat extends ToolCommand { ...@@ -50,7 +50,7 @@ object BiopetFlagstat extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val inputSam = SamReaderFactory.makeDefault.open(commandArgs.inputFile) val inputSam = SamReaderFactory.makeDefault.open(commandArgs.inputFile)
val iterSam = if (commandArgs.region.isEmpty) inputSam.iterator else { val iterSam = if (commandArgs.region.isEmpty) inputSam.iterator else {
......
...@@ -71,7 +71,7 @@ object CheckAllelesVcfInBam extends ToolCommand { ...@@ -71,7 +71,7 @@ object CheckAllelesVcfInBam extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (commandArgs.bamFiles.size != commandArgs.samples.size) if (commandArgs.bamFiles.size != commandArgs.samples.size)
logger.warn("Number of samples is different from number of bam files: additional samples or bam files will not be used") logger.warn("Number of samples is different from number of bam files: additional samples or bam files will not be used")
......
...@@ -242,7 +242,7 @@ object ExtractAlignedFastq extends ToolCommand { ...@@ -242,7 +242,7 @@ object ExtractAlignedFastq extends ToolCommand {
def parseArgs(args: Array[String]): Args = def parseArgs(args: Array[String]): Args =
new OptParser() new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
......
...@@ -45,7 +45,7 @@ object FastqSplitter extends ToolCommand { ...@@ -45,7 +45,7 @@ object FastqSplitter extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val groupSize = 100 val groupSize = 100
val output = for (file <- commandArgs.outputFile) yield new AsyncFastqWriter(new BasicFastqWriter(file), groupSize) val output = for (file <- commandArgs.outputFile) yield new AsyncFastqWriter(new BasicFastqWriter(file), groupSize)
......
...@@ -151,7 +151,7 @@ object FastqSync extends ToolCommand { ...@@ -151,7 +151,7 @@ object FastqSync extends ToolCommand {
*/ */
def parseArgs(args: Array[String]): Args = new OptParser() def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
......
...@@ -46,7 +46,7 @@ object FindRepeatsPacBio extends ToolCommand { ...@@ -46,7 +46,7 @@ object FindRepeatsPacBio extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val bamReader = SamReaderFactory.makeDefault val bamReader = SamReaderFactory.makeDefault
.validationStringency(ValidationStringency.SILENT) .validationStringency(ValidationStringency.SILENT)
.open(commandArgs.inputBam) .open(commandArgs.inputBam)
......
...@@ -57,7 +57,7 @@ object GvcfToBed extends ToolCommand { ...@@ -57,7 +57,7 @@ object GvcfToBed extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
logger.debug("Opening reader") logger.debug("Opening reader")
val reader = new VCFFileReader(cmdArgs.inputVcf, false) val reader = new VCFFileReader(cmdArgs.inputVcf, false)
......
...@@ -90,7 +90,7 @@ object KrakenReportToJson extends ToolCommand { ...@@ -90,7 +90,7 @@ object KrakenReportToJson extends ToolCommand {
*/ */
def parseArgs(args: Array[String]): Args = new OptParser() def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
/** /**
* Takes a line from the kraken report, converts into Map with taxonID and * Takes a line from the kraken report, converts into Map with taxonID and
......
...@@ -50,7 +50,7 @@ object MergeAlleles extends ToolCommand { ...@@ -50,7 +50,7 @@ object MergeAlleles extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val readers = commandArgs.inputFiles.map(new VCFFileReader(_, true)) val readers = commandArgs.inputFiles.map(new VCFFileReader(_, true))
val referenceFile = new FastaSequenceFile(commandArgs.reference, true) val referenceFile = new FastaSequenceFile(commandArgs.reference, true)
......
...@@ -41,7 +41,7 @@ object MergeOtuMaps extends ToolCommand { ...@@ -41,7 +41,7 @@ object MergeOtuMaps extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
var map: Map[Long, String] = Map() var map: Map[Long, String] = Map()
......
...@@ -188,7 +188,7 @@ object MergeTables extends ToolCommand { ...@@ -188,7 +188,7 @@ object MergeTables extends ToolCommand {
/** Parses the command line argument */ /** Parses the command line argument */
def parseArgs(args: Array[String]): Args = new OptParser() def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
/** Transforms the input file seq into a seq of [[InputTable]] objects */ /** Transforms the input file seq into a seq of [[InputTable]] objects */
def prepInput(inFiles: Seq[File], ext: String, columnNames: Option[Seq[String]]): Seq[InputTable] = { def prepInput(inFiles: Seq[File], ext: String, columnNames: Option[Seq[String]]): Seq[InputTable] = {
......
...@@ -62,7 +62,7 @@ object MpileupToVcf extends ToolCommand { ...@@ -62,7 +62,7 @@ object MpileupToVcf extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (commandArgs.input != null && !commandArgs.input.exists) throw new IllegalStateException("Input file does not exist") if (commandArgs.input != null && !commandArgs.input.exists) throw new IllegalStateException("Input file does not exist")
val writer = new PrintWriter(commandArgs.output) val writer = new PrintWriter(commandArgs.output)
......
...@@ -52,7 +52,7 @@ object PrefixFastq extends ToolCommand { ...@@ -52,7 +52,7 @@ object PrefixFastq extends ToolCommand {
logger.info("Start") logger.info("Start")
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val writer = new AsyncFastqWriter(new BasicFastqWriter(cmdArgs.output), 3000) val writer = new AsyncFastqWriter(new BasicFastqWriter(cmdArgs.output), 3000)
val reader = new FastqReader(cmdArgs.input) val reader = new FastqReader(cmdArgs.input)
......
...@@ -49,7 +49,7 @@ object RegionAfCount extends ToolCommand { ...@@ -49,7 +49,7 @@ object RegionAfCount extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
logger.info("Start") logger.info("Start")
logger.info("Reading bed file") logger.info("Reading bed file")
......
...@@ -41,7 +41,7 @@ object SageCountFastq extends ToolCommand { ...@@ -41,7 +41,7 @@ object SageCountFastq extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input) if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
...@@ -74,7 +74,7 @@ object SageCreateLibrary extends ToolCommand { ...@@ -74,7 +74,7 @@ object SageCreateLibrary extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input) if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
...@@ -52,7 +52,7 @@ object SageCreateTagCounts extends ToolCommand { ...@@ -52,7 +52,7 @@ object SageCreateTagCounts extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input) if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
...@@ -46,7 +46,7 @@ object SamplesTsvToJson extends ToolCommand { ...@@ -46,7 +46,7 @@ object SamplesTsvToJson extends ToolCommand {
/** Executes SamplesTsvToJson */ /** Executes SamplesTsvToJson */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val jsonString = stringFromInputs(cmdArgs.inputFiles, cmdArgs.tagFiles) val jsonString = stringFromInputs(cmdArgs.inputFiles, cmdArgs.tagFiles)
cmdArgs.outputFile match { cmdArgs.outputFile match {
......
...@@ -76,7 +76,7 @@ object SeqStat extends ToolCommand { ...@@ -76,7 +76,7 @@ object SeqStat extends ToolCommand {
*/ */
def parseArgs(args: Array[String]): Args = new OptParser() def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
/** /**
* *
......
...@@ -46,7 +46,7 @@ object SquishBed extends ToolCommand { ...@@ -46,7 +46,7 @@ object SquishBed extends ToolCommand {
*/ */
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
if (!cmdArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + cmdArgs.input) if (!cmdArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + cmdArgs.input)
......
...@@ -61,7 +61,7 @@ object SummaryToTsv extends ToolCommand { ...@@ -61,7 +61,7 @@ object SummaryToTsv extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val summary = new Summary(cmdArgs.summary) val summary = new Summary(cmdArgs.summary)
......
...@@ -51,7 +51,7 @@ object ValidateFastq extends ToolCommand { ...@@ -51,7 +51,7 @@ object ValidateFastq extends ToolCommand {
//parse all possible options into OptParser //parse all possible options into OptParser
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
//read in fastq file 1 and if present fastq file 2 //read in fastq file 1 and if present fastq file 2
val readFq1 = new FastqReader(cmdArgs.input) val readFq1 = new FastqReader(cmdArgs.input)
......
...@@ -137,7 +137,7 @@ object VcfFilter extends ToolCommand { ...@@ -137,7 +137,7 @@ object VcfFilter extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
logger.info("Start") logger.info("Start")
val argsParser = new OptParser val argsParser = new OptParser
val cmdArgs = argsParser.parse(args, Args()) getOrElse sys.exit(1) val cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val reader = new VCFFileReader(cmdArgs.inputVcf, false) val reader = new VCFFileReader(cmdArgs.inputVcf, false)
val header = reader.getFileHeader val header = reader.getFileHeader
......
...@@ -206,7 +206,7 @@ object VcfStats extends ToolCommand { ...@@ -206,7 +206,7 @@ object VcfStats extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
logger.info("Started") logger.info("Started")
val argsParser = new OptParser val argsParser = new OptParser
cmdArgs = argsParser.parse(args, Args()) getOrElse sys.exit(1) cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val reader = new VCFFileReader(cmdArgs.inputFile, true) val reader = new VCFFileReader(cmdArgs.inputFile, true)
val header = reader.getFileHeader val header = reader.getFileHeader
......
...@@ -72,7 +72,7 @@ object VcfToTsv extends ToolCommand { ...@@ -72,7 +72,7 @@ object VcfToTsv extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
// Throw exception if separator and listSeparator are identical // Throw exception if separator and listSeparator are identical
if (commandArgs.separator == commandArgs.listSeparator) throw new IllegalArgumentException( if (commandArgs.separator == commandArgs.listSeparator) throw new IllegalArgumentException(
......
...@@ -39,7 +39,7 @@ object VepNormalizer extends ToolCommand { ...@@ -39,7 +39,7 @@ object VepNormalizer extends ToolCommand {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val commandArgs: Args = new OptParser() val commandArgs: Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
val input = commandArgs.inputVCF val input = commandArgs.inputVCF
val output = commandArgs.outputVCF val output = commandArgs.outputVCF
......
...@@ -399,7 +399,7 @@ object WipeReads extends ToolCommand { ...@@ -399,7 +399,7 @@ object WipeReads extends ToolCommand {
/** Parses the command line argument */ /** Parses the command line argument */
def parseArgs(args: Array[String]): Args = new OptParser() def parseArgs(args: Array[String]): Args = new OptParser()
.parse(args, Args()) .parse(args, Args())
.getOrElse(sys.exit(1)) .getOrElse(throw new IllegalArgumentException)
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment