Commit 6778ef3c authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub

Merge pull request #168 from biopet/fix-BIOPET-757

Adding a tool to merge jobreports
parents 0ef2b27c 8f6baa78
package nl.lumc.sasc.biopet.core.jobreport
import java.io.{File, PrintStream}
import nl.lumc.sasc.biopet.utils.{AbstractOptParser, ToolCommand}
import org.broadinstitute.gatk.utils.report.GATKReport
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)
class OptParser extends AbstractOptParser[Args](commandName) {
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)
} text "Output directory of this tool"
}
def main(args: Array[String]): Unit = {
logger.info("Start")
val argsParser = new OptParser
val cmdArgs
: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val newReport = new GATKReport
val reports = cmdArgs.inputFiles.map(new GATKReport(_))
val tableNames = reports.flatMap(_.getTables.map(_.getTableName)).distinct
for (name <- tableNames; report <- reports if report.hasTable(name)) {
val table = report.getTable(name)
if (newReport.hasTable(name)) newReport.getTable(name).concat(table)
else newReport.addTable(table)
}
val writer = new PrintStream(cmdArgs.outputfile)
newReport.print(writer)
writer.close()
logger.info("Done")
}
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
package nl.lumc.sasc.biopet package nl.lumc.sasc.biopet
import nl.lumc.sasc.biopet.core.jobreport.MergeQueueJobReports
import nl.lumc.sasc.biopet.core.pipelinestatus.PipelineStatus import nl.lumc.sasc.biopet.core.pipelinestatus.PipelineStatus
import nl.lumc.sasc.biopet.utils.{BiopetExecutable, MainCommand} import nl.lumc.sasc.biopet.utils.{BiopetExecutable, MainCommand}
...@@ -46,7 +47,8 @@ object BiopetExecutableMain extends BiopetExecutable { ...@@ -46,7 +47,8 @@ object BiopetExecutableMain extends BiopetExecutable {
nl.lumc.sasc.biopet.pipelines.generateindexes.ValidateAnnotations nl.lumc.sasc.biopet.pipelines.generateindexes.ValidateAnnotations
) )
def tools: List[MainCommand] = PipelineStatus :: BiopetToolsExecutable.tools def tools: List[MainCommand] =
MergeQueueJobReports :: PipelineStatus :: BiopetToolsExecutable.tools
def templates: List[MainCommand] = List( def templates: List[MainCommand] = List(
nl.lumc.sasc.biopet.pipelines.mapping.template.MultiSampleMapping, nl.lumc.sasc.biopet.pipelines.mapping.template.MultiSampleMapping,
......
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