From 7f2580f2a7f00094e2f3af6c958bc422618d408b Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Wed, 1 Jul 2015 19:11:23 +0200 Subject: [PATCH] Fixing code warning from ide --- .../core/BiopetCommandLineFunction.scala | 4 +- .../core/BiopetCommandLineFunctionTrait.scala | 44 +++++++++---------- .../sasc/biopet/core/BiopetExecutable.scala | 26 +++++------ .../core/BiopetJavaCommandLineFunction.scala | 6 +-- .../lumc/sasc/biopet/core/BiopetQScript.scala | 38 +++++++--------- .../sasc/biopet/core/MultiSampleQScript.scala | 15 +++---- .../sasc/biopet/core/PipelineCommand.scala | 10 ++--- .../nl/lumc/sasc/biopet/core/Reference.scala | 11 ++++- .../lumc/sasc/biopet/core/ToolCommand.scala | 12 +++-- .../biopet/core/summary/Summarizable.scala | 4 +- .../sasc/biopet/core/summary/Summary.scala | 4 +- .../biopet/core/summary/SummaryQScript.scala | 20 ++++----- .../biopet/core/summary/SummaryValue.scala | 7 +-- .../lumc/sasc/biopet/extensions/Fastqc.scala | 4 +- .../extensions/conifer/ConiferExport.scala | 4 +- .../biopet/pipelines/shiva/ShivaReport.scala | 22 +++++----- 16 files changed, 112 insertions(+), 119 deletions(-) diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala index b73f76c7b..30c400bc5 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala @@ -31,9 +31,9 @@ abstract class BiopetCommandLineFunction extends BiopetCommandLineFunctionTrait * @return Command to run */ final def commandLine: String = { - preCmdInternal + preCmdInternal() val cmd = cmdLine addJobReportBinding("command", cmd) - return cmd + cmd } } diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala index e732abbfa..a946349c3 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala @@ -17,9 +17,9 @@ package nl.lumc.sasc.biopet.core import java.io.File import nl.lumc.sasc.biopet.core.config.Configurable -import org.broadinstitute.gatk.queue.QException import org.broadinstitute.gatk.queue.function.CommandLineFunction -import org.broadinstitute.gatk.utils.commandline.{ Input, Argument } +import org.broadinstitute.gatk.utils.commandline.Input +import scala.collection.mutable import scala.sys.process.{ Process, ProcessLogger } import scala.util.matching.Regex import java.io.FileInputStream @@ -50,15 +50,15 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab * Can override this method. This is executed just before the job is ready to run. * Can check on run time files from pipeline here */ - protected[core] def beforeCmd {} + protected[core] def beforeCmd() {} /** Can override this method. This is executed after the script is done en queue starts to generate the graph */ - protected[core] def beforeGraph {} + protected[core] def beforeGraph() {} /** Set default output file, threads and vmem for current job */ override def freezeFieldValues() { - preProcesExecutable - beforeGraph + preProcessExecutable() + beforeGraph() if (jobOutputFile == null) jobOutputFile = new File(firstOutput.getAbsoluteFile.getParent, "." + firstOutput.getName + "." + configName + ".out") if (threads == 0) threads = getThreads(defaultThreads) @@ -95,7 +95,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab /** * Checks executable. Follow full CanonicalPath, checks if it is existing and do a md5sum on it to store in job report */ - protected[core] def preProcesExecutable { + protected[core] def preProcessExecutable() { if (!BiopetCommandLineFunctionTrait.executableMd5Cache.contains(executable)) { try if (executable != null) { if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable)) { @@ -135,10 +135,9 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab } /** executes checkExecutable method and fill job report */ - final protected def preCmdInternal { - preProcesExecutable - - beforeCmd + final protected def preCmdInternal() { + preProcessExecutable() + beforeCmd() addJobReportBinding("cores", nCoresRequest match { case Some(n) if n > 0 => n @@ -157,7 +156,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab protected val versionExitcode = List(0) /** Executes the version command */ - private[core] def getVersionInternal(): Option[String] = { + private[core] def getVersionInternal: Option[String] = { if (versionCommand == null || versionRegex == null) None else getVersionInternal(versionCommand, versionRegex) } @@ -173,7 +172,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab "\n output log: \n stdout: \n" + stdout.toString + "\n stderr: \n" + stderr.toString val process = Process(versionCommand).run(ProcessLogger(stdout append _ + "\n", stderr append _ + "\n")) - if (!versionExitcode.contains(process.exitValue)) { + if (!versionExitcode.contains(process.exitValue())) { logger.warn("getVersion give exit code " + process.exitValue + ", version not found \n" + outputLog) return None } @@ -184,13 +183,13 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab } } logger.warn("getVersion give a exit code " + process.exitValue + " but no version was found, executable correct? \n" + outputLog) - return None + None } /** Get version from cache otherwise execute the version command */ def getVersion: Option[String] = { if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable)) - preProcesExecutable + preProcessExecutable() if (!BiopetCommandLineFunctionTrait.versionCache.contains(versionCommand)) getVersionInternal match { case Some(version) => BiopetCommandLineFunctionTrait.versionCache += versionCommand -> version @@ -207,8 +206,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab def getThreads(default: Int): Int = { val maxThreads: Int = config("maxthreads", default = 8) val threads: Int = config("threads", default = default) - if (maxThreads > threads) return threads - else return maxThreads + if (maxThreads > threads) threads + else maxThreads } /** @@ -220,15 +219,14 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab def getThreads(default: Int, module: String): Int = { val maxThreads: Int = config("maxthreads", default = 8, submodule = module) val threads: Int = config("threads", default = default, submodule = module) - if (maxThreads > threads) return threads - else return maxThreads + if (maxThreads > threads) threads + else maxThreads } } /** stores global caches */ object BiopetCommandLineFunctionTrait { - import scala.collection.mutable.Map - private[core] val versionCache: Map[String, String] = Map() - private[core] val executableMd5Cache: Map[String, String] = Map() - private[core] val executableCache: Map[String, String] = Map() + private[core] val versionCache: mutable.Map[String, String] = mutable.Map() + private[core] val executableMd5Cache: mutable.Map[String, String] = mutable.Map() + private[core] val executableCache: mutable.Map[String, String] = mutable.Map() } diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala index c0febb8fe..83eb2da68 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetExecutable.scala @@ -23,6 +23,9 @@ import org.apache.log4j.Logger import nl.lumc.sasc.biopet.{ FullVersion, LastCommitHash } import nl.lumc.sasc.biopet.core.BiopetExecutable._ +/** + * This is the main trait for the biopet executable + */ trait BiopetExecutable extends Logging { def pipelines: List[MainCommand] @@ -74,7 +77,7 @@ trait BiopetExecutable extends Logging { def getCommand(module: String, name: String): MainCommand = { checkModule(module) val command = modules(module).find(p => p.commandName.toLowerCase == name.toLowerCase) - if (command == None) { + if (command.isEmpty) { System.err.println(s"ERROR: command '$name' does not exist in module '$module'\n" + usage(module)) System.exit(1) } @@ -82,22 +85,20 @@ trait BiopetExecutable extends Logging { } args match { - case Array("version") => { + case Array("version") => println("version: " + FullVersion) - } - case Array("license") => { + case Array("license") => println(getLicense) - } - case Array(module, name, passArgs @ _*) => { + case Array(module, name, passArgs @ _*) => try { getCommand(module, name).main(passArgs.toArray) } catch { - case e: Exception => { + case e: Exception => val sWriter = new StringWriter() val pWriter = new PrintWriter(sWriter) e.printStackTrace(pWriter) pWriter.close() - val trace = (sWriter.toString.split("\n")) + val trace = sWriter.toString.split("\n") if (!logger.isDebugEnabled) { trace.filterNot(_.startsWith("\tat")).foreach(logger.error(_)) @@ -106,20 +107,17 @@ trait BiopetExecutable extends Logging { trace.foreach(logger.debug(_)) } sys.exit(1) - } } - } - case Array(module) => { + case Array(module) => System.err.println(usage(module)) sys.exit(1) - } - case _ => { + case _ => System.err.println(usage()) sys.exit(1) - } } } + /** This function checks if current build is based on a dirty repository (uncommitted changes) */ def checkDirtyBuild(logger: Logger): Unit = if (LastCommitHash.endsWith("-dirty")) { logger.warn("***********************************************************") diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala index 6904cdcd0..c659947d0 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetJavaCommandLineFunction.scala @@ -33,17 +33,17 @@ trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetC /** Creates command to execute extension */ override def commandLine: String = { - preCmdInternal + preCmdInternal() val cmd = super.commandLine val finalCmd = executable + cmd.substring(cmd.indexOf(" ")) - return cmd + cmd } def javaVersionCommand: String = executable + " -version" def getJavaVersion: Option[String] = { if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable)) - preProcesExecutable + preProcessExecutable() if (!BiopetCommandLineFunctionTrait.versionCache.contains(javaVersionCommand)) getVersionInternal(javaVersionCommand, """java version "(.*)"""".r) match { case Some(version) => BiopetCommandLineFunctionTrait.versionCache += javaVersionCommand -> version diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala index 6154e7660..c80ac4ac1 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala @@ -16,14 +16,15 @@ package nl.lumc.sasc.biopet.core import java.io.File -import java.io.PrintWriter -import nl.lumc.sasc.biopet.core.config.{ ConfigValueIndex, Config, Configurable } -import nl.lumc.sasc.biopet.core.report.{ ReportBuilderExtension, ReportBuilder } -import org.broadinstitute.gatk.utils.commandline.Argument + +import nl.lumc.sasc.biopet.core.config.Configurable +import nl.lumc.sasc.biopet.core.report.ReportBuilderExtension import org.broadinstitute.gatk.queue.QSettings import org.broadinstitute.gatk.queue.function.QFunction import org.broadinstitute.gatk.queue.function.scattergather.ScatterGatherableFunction -import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging } +import org.broadinstitute.gatk.queue.util.{Logging => GatkLogging} +import org.broadinstitute.gatk.utils.commandline.Argument + import scala.collection.mutable.ListBuffer /** Base for biopet pipeline */ @@ -53,10 +54,10 @@ trait BiopetQScript extends Configurable with GatkLogging { var functions: Seq[QFunction] /** Init for pipeline */ - def init + def init() /** Pipeline itself */ - def biopetScript + def biopetScript() /** Returns the extension to make the report */ def reportClass: Option[ReportBuilderExtension] = None @@ -65,19 +66,18 @@ trait BiopetQScript extends Configurable with GatkLogging { final def script() { outputDir = config("output_dir") outputDir = outputDir.getAbsoluteFile - init - biopetScript + init() + biopetScript() if (disableScatter) for (function <- functions) function match { case f: ScatterGatherableFunction => f.scatterCount = 1 case _ => } for (function <- functions) function match { - case f: BiopetCommandLineFunctionTrait => { - f.preProcesExecutable - f.beforeGraph + case f: BiopetCommandLineFunctionTrait => + f.preProcessExecutable() + f.beforeGraph() f.commandLine - } case _ => } @@ -87,7 +87,7 @@ trait BiopetQScript extends Configurable with GatkLogging { reportClass.foreach(add(_)) - BiopetQScript.checkErrors + BiopetQScript.checkErrors() } /** Get implemented from org.broadinstitute.gatk.queue.QScript */ @@ -96,11 +96,7 @@ trait BiopetQScript extends Configurable with GatkLogging { /** Get implemented from org.broadinstitute.gatk.queue.QScript */ def addAll(functions: scala.Traversable[org.broadinstitute.gatk.queue.function.QFunction]) - /** - * Function to set isIntermediate and add in 1 line - * @param function - * @param isIntermediate - */ + /** Function to set isIntermediate and add in 1 line */ def add(function: QFunction, isIntermediate: Boolean = false) { function.isIntermediate = isIntermediate add(function) @@ -115,8 +111,8 @@ object BiopetQScript extends Logging { errors.append(new Exception(msg)) } - protected def checkErrors: Unit = { - if (!errors.isEmpty) { + protected def checkErrors(): Unit = { + if (errors.nonEmpty) { logger.error("*************************") logger.error("Biopet found some errors:") if (logger.isDebugEnabled) { diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala index 837fc37a7..f7280dcb4 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala @@ -17,10 +17,9 @@ package nl.lumc.sasc.biopet.core import java.io.File -import nl.lumc.sasc.biopet.core.config.{ Config } import nl.lumc.sasc.biopet.core.summary.{ SummaryQScript, Summarizable } import nl.lumc.sasc.biopet.utils.ConfigUtils -import org.broadinstitute.gatk.utils.commandline.{ Argument } +import org.broadinstitute.gatk.utils.commandline.Argument /** This trait creates a structured way of use multisample pipelines */ trait MultiSampleQScript extends SummaryQScript { @@ -107,11 +106,7 @@ trait MultiSampleQScript extends SummaryQScript { } } - /** - * Creates a sample file with given suffix - * @param suffix - * @return - */ + /** Creates a sample file with given suffix */ def createFile(suffix: String) = new File(sampleDir, sampleId + suffix) /** Returns sample directory */ @@ -158,14 +153,14 @@ trait MultiSampleQScript extends SummaryQScript { /** Prefix full path with sample and library for jobs that's are created in current state */ override protected[core] def configFullPath: List[String] = { - val s = currentSample match { + val sample = currentSample match { case Some(s) => "samples" :: s :: Nil case _ => Nil } - val l = currentLib match { + val lib = currentLib match { case Some(l) => "libraries" :: l :: Nil case _ => Nil } - s ::: l ::: super.configFullPath + sample ::: lib ::: super.configFullPath } } diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala index 3caaf958c..bf55e0595 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala @@ -15,12 +15,12 @@ */ package nl.lumc.sasc.biopet.core -import org.apache.log4j.{ PatternLayout, Appender, WriterAppender, FileAppender } -import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging } -import java.io.{ PrintWriter, File } +import java.io.{File, PrintWriter} + import nl.lumc.sasc.biopet.core.config.Config import nl.lumc.sasc.biopet.core.workaround.BiopetQCommandLine -import scala.collection.JavaConversions._ +import org.apache.log4j.{PatternLayout, WriterAppender} +import org.broadinstitute.gatk.queue.util.{Logging => GatkLogging} /** Wrapper around executable from Queue */ trait PipelineCommand extends MainCommand with GatkLogging { @@ -33,7 +33,7 @@ trait PipelineCommand extends MainCommand with GatkLogging { /** Class can be used directly from java with -cp option */ def main(args: Array[String]): Unit = { - val argsSize = args.size + val argsSize = args.length for (t <- 0 until argsSize) { if (args(t) == "-config" || args(t) == "--config_file") { if (t >= argsSize) throw new IllegalStateException("-config needs a value") diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/Reference.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/Reference.scala index 8420a107a..5a9786df2 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/Reference.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/Reference.scala @@ -7,10 +7,14 @@ import nl.lumc.sasc.biopet.core.config.Configurable import scala.collection.JavaConversions._ /** + * This trait is used for pipelines and extension that use a reference based on one fasta file. + * The fasta file can contain multiple contigs. + * * Created by pjvan_thof on 4/6/15. */ trait Reference extends Configurable { + /** Returns species, default to unknown_species */ def referenceSpecies: String = { root match { case r: Reference if r.referenceSpecies != "unknown_species" => r.referenceSpecies @@ -18,16 +22,17 @@ trait Reference extends Configurable { } } + /** Return referencename, default to unknown_ref */ def referenceName: String = { root match { case r: Reference if r.referenceName != "unknown_ref" => r.referenceName - case _ => { + case _ => val default: String = config("default", default = "unknown_ref", path = List("references", referenceSpecies)) config("reference_name", default = default, path = super.configPath) - } } } + /** All config values will get a prefix */ override def subPath = { referenceConfigPath ::: super.subPath } @@ -37,8 +42,10 @@ trait Reference extends Configurable { List("references", referenceSpecies, referenceName) } + /** When set override this on true the pipeline with raise an exception when fai index is not found */ protected def faiRequired = false + /** When set override this on true the pipeline with raise an exception when dict index is not found */ protected def dictRequired = false /** Returns the fasta file */ diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/ToolCommand.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/ToolCommand.scala index 549b356a1..f0e66c0b0 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/ToolCommand.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/ToolCommand.scala @@ -36,20 +36,18 @@ trait ToolCommand extends MainCommand with Logging { case "error" => logger.setLevel(org.apache.log4j.Level.ERROR) case _ => } - } text ("Log level") validate { x => - x match { - case "debug" | "info" | "warn" | "error" => success - case _ => failure("Log level must be <debug/info/warn/error>") - } + } text "Log level" validate { + case "debug" | "info" | "warn" | "error" => success + case _ => failure("Log level must be <debug/info/warn/error>") } opt[Unit]('h', "help") foreach { _ => System.err.println(this.usage) sys.exit(1) - } text ("Print usage") + } text "Print usage" opt[Unit]('v', "version") foreach { _ => System.err.println("Version: " + FullVersion) sys.exit(1) - } text ("Print version") + } text "Print version" } protected type Args <: AbstractArgs diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summarizable.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summarizable.scala index c9a112282..cca4a9086 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summarizable.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summarizable.scala @@ -17,8 +17,6 @@ package nl.lumc.sasc.biopet.core.summary import java.io.File -import nl.lumc.sasc.biopet.core.config.Configurable - /** * Trait for class to let them accept into a Summary * @@ -40,7 +38,7 @@ trait Summarizable { * @param v1 Value of new map * @param v2 Value of old map * @param key Key of value - * @return + * @return combined value */ def resolveSummaryConflict(v1: Any, v2: Any, key: String): Any = { throw new IllegalStateException("Merge can not have same key by default") diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summary.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summary.scala index 662ec7048..69e6dfeba 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summary.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/Summary.scala @@ -5,6 +5,8 @@ import java.io.File import nl.lumc.sasc.biopet.utils.ConfigUtils /** + * This class can read in a summary and extract values from it + * * Created by pjvan_thof on 3/26/15. */ class Summary(file: File) { @@ -12,7 +14,7 @@ class Summary(file: File) { lazy val samples: Set[String] = { ConfigUtils.getValueFromPath(map, List("samples")) match { - case Some(samples) => ConfigUtils.any2map(samples).keySet + case Some(s) => ConfigUtils.any2map(s).keySet case _ => Set() } } diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala index 68bb4155c..c59438133 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala @@ -23,6 +23,8 @@ import nl.lumc.sasc.biopet.extensions.Md5sum import scala.collection.mutable /** + * This trait is used for qscript / pipelines that will produce a summary + * * Created by pjvan_thof on 2/14/15. */ trait SummaryQScript extends BiopetQScript { @@ -65,7 +67,7 @@ trait SummaryQScript extends BiopetQScript { * * @param summarizable summarizable to add to summary for this pipeline * @param name Name of module - * @param sampleId + * @param sampleId Id of sample */ def addSummarizable(summarizable: Summarizable, name: String, sampleId: Option[String]): Unit = { addSummarizable(summarizable, name, sampleId, None) @@ -76,24 +78,21 @@ trait SummaryQScript extends BiopetQScript { * * @param summarizable summarizable to add to summary for this pipeline * @param name Name of module - * @param sampleId - * @param libraryId + * @param sampleId Id of sample + * @param libraryId Id of libary */ def addSummarizable(summarizable: Summarizable, name: String, sampleId: Option[String], libraryId: Option[String]): Unit = { if (libraryId.isDefined) require(sampleId.isDefined) // Library always require a sample summarizables += (name, sampleId, libraryId) -> (summarizable :: summarizables.getOrElse((name, sampleId, libraryId), Nil)) } - /** - * Add an other qscript to merge in output summary - * @param summaryQScript - */ + /** Add an other qscript to merge in output summary */ def addSummaryQScript(summaryQScript: SummaryQScript): Unit = { summaryQScripts :+= summaryQScript } /** Add jobs to qscript to execute summary, also add checksum jobs */ - def addSummaryJobs: Unit = { + def addSummaryJobs(): Unit = { val writeSummary = new WriteSummary(this) def addChecksum(file: File): Unit = { @@ -119,7 +118,7 @@ trait SummaryQScript extends BiopetQScript { for ((_, summarizableList) <- summarizables; summarizable <- summarizableList) { summarizable match { - case f: BiopetCommandLineFunctionTrait => f.beforeGraph + case f: BiopetCommandLineFunctionTrait => f.beforeGraph() case _ => } } @@ -141,8 +140,7 @@ trait SummaryQScript extends BiopetQScript { } object SummaryQScript { - import scala.collection.mutable.Map /** Cache to have no duplicate jobs */ - protected[summary] val md5sumCache: Map[File, File] = Map() + protected[summary] val md5sumCache: mutable.Map[File, File] = mutable.Map() } \ No newline at end of file diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryValue.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryValue.scala index b4cf349d6..546b699e6 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryValue.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryValue.scala @@ -1,11 +1,11 @@ package nl.lumc.sasc.biopet.core.summary -import java.math.BigDecimal - /** + * This case class is used for easy access and calculations on those values + * * Created by pjvan_thof on 4/23/15. */ -case class SummaryValue(val value: Option[Any]) { +case class SummaryValue(value: Option[Any]) { def this(path: List[String], summary: Summary, @@ -18,6 +18,7 @@ case class SummaryValue(val value: Option[Any]) { }) } + //TODO: Calculations are not yet used somewhere, needs more testing def +(that: SummaryValue): SummaryValue = { (this.value, that.value) match { case (Some(a: Double), Some(b)) => SummaryValue(Some(a + b.toString.toDouble)) diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala index c7b2f7b43..0f573f5af 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala @@ -53,9 +53,9 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction { override val defaultThreads = 4 /** Sets contaminants and adapters when not yet set */ - override def beforeGraph { + override def beforeGraph() { this.jobOutputFile = new File(output.getParentFile, ".fastqc.out") - this.preProcesExecutable + this.preProcessExecutable() val fastqcDir = new File(executable).getParent diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/conifer/ConiferExport.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/conifer/ConiferExport.scala index fc1e0a862..afc22bd86 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/conifer/ConiferExport.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/conifer/ConiferExport.scala @@ -28,8 +28,8 @@ class ConiferExport(val root: Configurable) extends Conifer { @Output(doc = "Output <sample>.svdzrpkm.bed", shortName = "out", required = true) var output: File = _ - override def beforeGraph { - this.preProcesExecutable + override def beforeGraph() { + this.preProcessExecutable() } override def cmdLine = super.cmdLine + diff --git a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala index e3a263489..9755ca13a 100644 --- a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala +++ b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaReport.scala @@ -10,6 +10,8 @@ import nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport import nl.lumc.sasc.biopet.pipelines.flexiprep.FlexiprepReport /** + * With this extension the report is executed within a pipeline + * * Created by pjvan_thof on 3/30/15. */ class ShivaReport(val root: Configurable) extends ReportBuilderExtension { @@ -28,9 +30,9 @@ object ShivaReport extends MultisampleReportBuilder { List("Samples" -> generateSamplesPage(pageArgs)) ++ (if (regions.isDefined) Map(regions.get) else Map()) ++ Map("Files" -> filesPage, - "Versions" -> ReportPage(List(), List(( + "Versions" -> ReportPage(List(), List( "Executables" -> ReportSection("/nl/lumc/sasc/biopet/core/report/executables.ssp" - ))), Map()) + )), Map()) ), List( "Report" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/shiva/shivaFront.ssp"), @@ -67,22 +69,22 @@ object ShivaReport extends MultisampleReportBuilder { } amplicon match { - case Some(x: String) => regionPages += (x + " (Amplicon)") -> createPage(x, true) + case Some(x: String) => regionPages += (x + " (Amplicon)") -> createPage(x, amplicon = true) case _ => } roi match { - case Some(x: String) => regionPages += x -> createPage(x, false) - case Some(x: List[_]) => x.foreach(x => regionPages += x.toString -> createPage(x.toString, false)) + case Some(x: String) => regionPages += x -> createPage(x, amplicon = false) + case Some(x: List[_]) => x.foreach(x => regionPages += x.toString -> createPage(x.toString, amplicon = false)) case _ => } if (regionPages.nonEmpty) Some("Regions" -> ReportPage( List(), - regionPages.map(p => (p._1 -> ReportSection( + regionPages.map(p => p._1 -> ReportSection( "/nl/lumc/sasc/biopet/pipelines/bammetrics/covstatsMultiTable.ssp", Map("target" -> p._1.stripSuffix(" (Amplicon)")) - ))).toList.sortBy(_._1), + )).toList.sortBy(_._1), Map()) ) else None @@ -156,13 +158,13 @@ object ShivaReport extends MultisampleReportBuilder { if (libraryLevel) { for ( - sample <- summary.samples if (sampleId.isEmpty || sample == sampleId.get); + sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get; lib <- summary.libraries(sample) ) { tsvWriter.println(getLine(summary, sample, Some(lib))) } } else { - for (sample <- summary.samples if (sampleId.isEmpty || sample == sampleId.get)) { + for (sample <- summary.samples if sampleId.isEmpty || sample == sampleId.get) { tsvWriter.println(getLine(summary, sample)) } } @@ -175,7 +177,7 @@ object ShivaReport extends MultisampleReportBuilder { plot.ylabel = Some("VCF records") if (libraryLevel) { plot.width = Some(200 + (summary.libraries.filter(s => sampleId.getOrElse(s._1) == s._1).foldLeft(0)(_ + _._2.size) * 10)) - } else plot.width = Some(200 + (summary.samples.filter(s => sampleId.getOrElse(s) == s).size * 10)) + } else plot.width = Some(200 + (summary.samples.count(s => sampleId.getOrElse(s) == s) * 10)) plot.runLocal() } } -- GitLab