diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala index d0134fd845c97d6fc7133739504aedcff392853c..172e12d2bcd192a5ad5e1c6953cdf38312735964 100644 --- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala +++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala @@ -28,7 +28,8 @@ object BiopetExecutable { nl.lumc.sasc.biopet.tools.VcfFilter, nl.lumc.sasc.biopet.tools.FindRepeatsPacBio, nl.lumc.sasc.biopet.tools.BedToInterval, - nl.lumc.sasc.biopet.tools.MpileupToVcf) + nl.lumc.sasc.biopet.tools.MpileupToVcf, + nl.lumc.sasc.biopet.tools.FastqSplitter) ) /** diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSplitter.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSplitter.scala index 66cb83cc5d32c3f597bcf9166a6714d96bbece93..c59d8a2464797f03eca4e0f7b2d6c3e0965ab624 100644 --- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSplitter.scala +++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSplitter.scala @@ -4,6 +4,7 @@ import java.io.{ BufferedInputStream, File, FileInputStream, PrintWriter } import java.util.zip.GZIPInputStream import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction import scala.io.Source +import nl.lumc.sasc.biopet.core.ToolCommand import nl.lumc.sasc.biopet.core.config.Configurable import org.broadinstitute.gatk.utils.commandline.{ Input, Output } @@ -19,24 +20,34 @@ class FastqSplitter(val root: Configurable) extends BiopetJavaCommandLineFunctio override val defaultVmem = "8G" memoryLimit = Option(4.0) - override def commandLine = super.commandLine + required(input) + repeat(output) + override def commandLine = super.commandLine + required("-I", input) + repeat("-o", output) } -object FastqSplitter { +object FastqSplitter extends ToolCommand { + case class Args (inputFile:File = null, outputFile:List[File] = Nil) extends AbstractArgs + + class OptParser extends AbstractOptParser { + opt[File]('I', "inputFile") required() valueName("<file>") action { (x, c) => + c.copy(inputFile = x) } text("out is a required file property") + opt[File]('o', "output") required() unbounded() valueName("<file>") action { (x, c) => + c.copy(outputFile = x :: c.outputFile) } text("out is a required file property") + } + /** * @param args the command line arguments */ def main(args: Array[String]): Unit = { + val argsParser = new OptParser + val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) + val groupsize = 100 - val input = new File(args.head) - val output: Array[PrintWriter] = new Array[PrintWriter](args.tail.size) - for (t <- 1 to args.tail.size) output(t - 1) = new PrintWriter(args(t)) + val output = for (file <- commandArgs.outputFile) yield new PrintWriter(file) val inputStream = { - if (input.getName.endsWith(".gz") || input.getName.endsWith(".gzip")) Source.fromInputStream( + if (commandArgs.inputFile.getName.endsWith(".gz") || commandArgs.inputFile.getName.endsWith(".gzip")) Source.fromInputStream( new GZIPInputStream( new BufferedInputStream( - new FileInputStream(input)))).bufferedReader - else Source.fromFile(input).bufferedReader + new FileInputStream(commandArgs.inputFile)))).bufferedReader + else Source.fromFile(commandArgs.inputFile).bufferedReader } while (inputStream.ready) { for (writter <- output) {