Commit 52fd8f61 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Adding tool to merge jobreports

parent 90eebdfa
package nl.lumc.sasc.biopet.core.jobreport
import java.io.File
import java.io.{File, PrintStream}
import nl.lumc.sasc.biopet.utils.{AbstractOptParser, ToolCommand}
import org.broadinstitute.gatk.utils.report.{GATKReport, GATKReportTable}
import org.broadinstitute.gatk.utils.report.GATKReport
import scala.collection.JavaConversions._
......@@ -11,15 +11,15 @@ import scala.collection.JavaConversions._
* Created by pjvanthof on 25/07/2017.
*/
object MergeQueueJobReports extends ToolCommand {
case class Args(inputFiles: List[File] = Nil,
outputfile: File = null)
case class Args(inputFiles: List[File] = Nil, outputfile: File = null)
class OptParser extends AbstractOptParser[Args](commandName) {
opt[File]('I', "inputFile") unbounded() required () valueName "<file>" action { (x, c) =>
opt[File]('I', "inputFile") unbounded () required () valueName "<file>" action { (x, c) =>
c.copy(inputFiles = x :: c.inputFiles)
} text "Output directory of the pipeline"
opt[File]('o', "outputFile") unbounded() required () maxOccurs 1 valueName "<file>" action { (x, c) =>
c.copy(outputfile = x)
opt[File]('o', "outputFile") unbounded () required () maxOccurs 1 valueName "<file>" action {
(x, c) =>
c.copy(outputfile = x)
} text "Output directory of this tool"
}
......@@ -28,19 +28,23 @@ object MergeQueueJobReports extends ToolCommand {
val argsParser = new OptParser
val cmdArgs
: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val newReport = new GATKReport
val reports = cmdArgs.inputFiles.map(new GATKReport(_))
val tableNames = reports.map(_.getTables.map(_.getTableName)).flatten.distinct
val tableNames = reports.flatMap(_.getTables.map(_.getTableName)).distinct
for (name <- tableNames; report <- reports if report.hasTable(name)) {
val table = report.getTable(name)
val newTable = table.concat(newReport.getTable(name))
//newReport.addTable(name, table.getTableDescription, newTable)
if (newReport.hasTable(name)) newReport.getTable(name).concat(table)
else newReport.addTable(table)
}
println(tableNames)
val writer = new PrintStream(cmdArgs.outputfile)
newReport.print(writer)
writer.close()
logger.info("Done")
}
}
Supports Markdown
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