Skip to content
Snippets Groups Projects
Commit 4b6d158f authored by Peter van 't Hof's avatar Peter van 't Hof Committed by bow
Browse files

Added FastqSplitter to exe

parent 410da462
No related branches found
No related tags found
No related merge requests found
......@@ -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)
)
/**
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment