Commit 4f2a0f07 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added a skip option in merge otu maps tool

parent bace55eb
......@@ -31,9 +31,14 @@ class MergeOtuMaps(val root: Configurable) extends ToolCommandFunction {
@Output(doc = "Output", shortName = "output", required = true)
var output: File = _
var skipPrefix: List[String] = config("skip_prefix", default = Nil)
override def defaultCoreMemory = 6.0
override def cmdLine = super.cmdLine + repeat("-I", input) + required("-o", output)
override def cmdLine = super.cmdLine +
repeat("-I", input) +
required("-o", output) +
repeat("-p", skipPrefix)
}
......@@ -24,7 +24,9 @@ import scala.io.Source
* Created by pjvan_thof on 12/18/15.
*/
object MergeOtuMaps extends ToolCommand {
case class Args(inputFiles: List[File] = Nil, outputFile: File = null) extends AbstractArgs
case class Args(inputFiles: List[File] = Nil,
outputFile: File = null,
skipPrefix: List[String] = Nil) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('I', "input") minOccurs 2 required () unbounded () valueName "<file>" action { (x, c) =>
......@@ -33,6 +35,9 @@ object MergeOtuMaps extends ToolCommand {
opt[File]('o', "output") required () unbounded () maxOccurs 1 valueName "<file>" action { (x, c) =>
c.copy(outputFile = x)
}
opt[String]('p', "skipPrefix") unbounded () valueName "<text>" action { (x, c) =>
c.copy(skipPrefix = x :: c.skipPrefix)
}
}
/**
......@@ -40,23 +45,24 @@ object MergeOtuMaps extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
var map: Map[Long, String] = Map()
var map: Map[String, String] = Map()
for (inputFile <- commandArgs.inputFiles) {
for (inputFile <- cmdArgs.inputFiles) {
logger.info(s"Start reading $inputFile")
val reader = Source.fromFile(inputFile)
reader.getLines().foreach { line =>
val values = line.split("\t", 2)
val key = values.head.toLong
val key = values.head
if (!cmdArgs.skipPrefix.exists(key.startsWith))
map += key -> (line.stripPrefix(s"$key") + map.getOrElse(key, ""))
}
reader.close()
}
logger.info(s"Start writing to ${commandArgs.outputFile}")
val writer = new PrintWriter(commandArgs.outputFile)
logger.info(s"Start writing to ${cmdArgs.outputFile}")
val writer = new PrintWriter(cmdArgs.outputFile)
map.foreach { case (key, list) => writer.println(key + list) }
writer.close()
}
......
......@@ -37,6 +37,8 @@ class Gears(val root: Configurable) extends QScript with MultiSampleQScript { qs
Some(gearsReport)
}
override def defaults = Map("mergeotumaps" -> Map("skip_prefix" -> "New."))
override def fixedValues = Map("gearssingle" -> Map("skip_flexiprep" -> true))
/** Init for pipeline */
......
......@@ -43,7 +43,6 @@ object GearsReport extends MultisampleReportBuilder {
val qiimeOpenOtuTable = summary.getValue("gears", "files", "pipeline", "qiime_open_otu_table", "path")
.map(x => new File(x.toString))
ReportPage(
(if (krakenExecuted) List("Kraken analysis" -> ReportPage(List(), List(
"Krona plot" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/gears/krakenKrona.ssp"
......
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