Commit 02b571a4 authored by bow's avatar bow

Update code style using scalariform

parent 96ccc270
...@@ -2,63 +2,63 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics ...@@ -2,63 +2,63 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
import nl.lumc.sasc.biopet.core.{BiopetQScript, PipelineCommand} import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.apps.{BedToInterval, BiopetFlagstat} import nl.lumc.sasc.biopet.core.apps.{ BedToInterval, BiopetFlagstat }
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.function.bedtools.{BedtoolsCoverage, BedtoolsIntersect} import nl.lumc.sasc.biopet.function.bedtools.{ BedtoolsCoverage, BedtoolsIntersect }
import nl.lumc.sasc.biopet.function.picard.{CollectInsertSizeMetrics, CollectGcBiasMetrics, CalculateHsMetrics, CollectAlignmentSummaryMetrics} import nl.lumc.sasc.biopet.function.picard.{ CollectInsertSizeMetrics, CollectGcBiasMetrics, CalculateHsMetrics, CollectAlignmentSummaryMetrics }
import nl.lumc.sasc.biopet.function.samtools.SamtoolsFlagstat import nl.lumc.sasc.biopet.function.samtools.SamtoolsFlagstat
class BamMetrics(val root:Configurable) extends QScript with BiopetQScript { class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
def this() = this(null) def this() = this(null)
@Input(doc="Bam File", shortName="BAM",required=true) @Input(doc = "Bam File", shortName = "BAM", required = true)
var inputBam: File = _ var inputBam: File = _
@Input(doc="Bed tracks targets", shortName="target",required=false) @Input(doc = "Bed tracks targets", shortName = "target", required = false)
var bedFiles: List[File] = Nil var bedFiles: List[File] = Nil
@Input(doc="Bed tracks bait", shortName="bait",required=false) @Input(doc = "Bed tracks bait", shortName = "bait", required = false)
var baitBedFile: File = _ var baitBedFile: File = _
@Argument(doc="",required=false) @Argument(doc = "", required = false)
var wholeGenome = false var wholeGenome = false
def init() { def init() {
for (file <- configfiles) globalConfig.loadConfigFile(file) for (file <- configfiles) globalConfig.loadConfigFile(file)
if (outputDir == null) throw new IllegalStateException("Missing Output directory on BamMetrics module") if (outputDir == null) throw new IllegalStateException("Missing Output directory on BamMetrics module")
else if (!outputDir.endsWith("/")) outputDir += "/" else if (!outputDir.endsWith("/")) outputDir += "/"
} }
def biopetScript() { def biopetScript() {
add(SamtoolsFlagstat(this, inputBam, outputDir)) add(SamtoolsFlagstat(this, inputBam, outputDir))
add(BiopetFlagstat(this, inputBam, outputDir)) add(BiopetFlagstat(this, inputBam, outputDir))
add(CollectGcBiasMetrics(this, inputBam, outputDir)) add(CollectGcBiasMetrics(this, inputBam, outputDir))
add(CollectInsertSizeMetrics(this, inputBam, outputDir)) add(CollectInsertSizeMetrics(this, inputBam, outputDir))
add(CollectAlignmentSummaryMetrics(this, inputBam, outputDir)) add(CollectAlignmentSummaryMetrics(this, inputBam, outputDir))
val baitIntervalFile = if (baitBedFile != null) new File(outputDir, baitBedFile.getName.stripSuffix(".bed") + ".interval") else null val baitIntervalFile = if (baitBedFile != null) new File(outputDir, baitBedFile.getName.stripSuffix(".bed") + ".interval") else null
if (baitIntervalFile != null) if (baitIntervalFile != null)
add(BedToInterval(this, baitBedFile, inputBam, outputDir), true) add(BedToInterval(this, baitBedFile, inputBam, outputDir), true)
for (bedFile <- bedFiles) { for (bedFile <- bedFiles) {
val targetDir = outputDir + bedFile.getName.stripSuffix(".bed") + "/" val targetDir = outputDir + bedFile.getName.stripSuffix(".bed") + "/"
val targetInterval = BedToInterval(this, bedFile, inputBam, targetDir) val targetInterval = BedToInterval(this, bedFile, inputBam, targetDir)
add(targetInterval, true) add(targetInterval, true)
add(CalculateHsMetrics(this, inputBam, if (baitIntervalFile != null) baitIntervalFile add(CalculateHsMetrics(this, inputBam, if (baitIntervalFile != null) baitIntervalFile
else targetInterval.output, targetInterval.output, targetDir)) else targetInterval.output, targetInterval.output, targetDir))
val strictOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.strict.bam") val strictOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.strict.bam")
add(BedtoolsIntersect(this, inputBam, bedFile, strictOutputBam, minOverlap = config("strictintersectoverlap", default=1.0)), true) add(BedtoolsIntersect(this, inputBam, bedFile, strictOutputBam, minOverlap = config("strictintersectoverlap", default = 1.0)), true)
add(SamtoolsFlagstat(this, strictOutputBam)) add(SamtoolsFlagstat(this, strictOutputBam))
add(BiopetFlagstat(this, strictOutputBam, targetDir)) add(BiopetFlagstat(this, strictOutputBam, targetDir))
val looseOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.loose.bam") val looseOutputBam = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.loose.bam")
add(BedtoolsIntersect(this, inputBam, bedFile, looseOutputBam, minOverlap = config("looseintersectoverlap", default=0.01)), true) add(BedtoolsIntersect(this, inputBam, bedFile, looseOutputBam, minOverlap = config("looseintersectoverlap", default = 0.01)), true)
add(SamtoolsFlagstat(this, looseOutputBam)) add(SamtoolsFlagstat(this, looseOutputBam))
add(BiopetFlagstat(this, looseOutputBam, targetDir)) add(BiopetFlagstat(this, looseOutputBam, targetDir))
val coverageFile = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".coverage") val coverageFile = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".coverage")
add(BedtoolsCoverage(this, inputBam, bedFile, coverageFile, true), true) add(BedtoolsCoverage(this, inputBam, bedFile, coverageFile, true), true)
add(CoverageStats(this, coverageFile, targetDir)) add(CoverageStats(this, coverageFile, targetDir))
...@@ -68,12 +68,12 @@ class BamMetrics(val root:Configurable) extends QScript with BiopetQScript { ...@@ -68,12 +68,12 @@ class BamMetrics(val root:Configurable) extends QScript with BiopetQScript {
object BamMetrics extends PipelineCommand { object BamMetrics extends PipelineCommand {
override val pipeline = "/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.class" override val pipeline = "/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.class"
def apply(root:Configurable, bamFile:File, outputDir:String) : BamMetrics = { def apply(root: Configurable, bamFile: File, outputDir: String): BamMetrics = {
val bamMetrics = new BamMetrics(root) val bamMetrics = new BamMetrics(root)
bamMetrics.inputBam = bamFile bamMetrics.inputBam = bamFile
bamMetrics.outputDir = outputDir bamMetrics.outputDir = outputDir
bamMetrics.init bamMetrics.init
bamMetrics.biopetScript bamMetrics.biopetScript
return bamMetrics return bamMetrics
......
...@@ -2,27 +2,27 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics.scripts ...@@ -2,27 +2,27 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics.scripts
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.function.PythonCommandLineFunction import nl.lumc.sasc.biopet.function.PythonCommandLineFunction
import org.broadinstitute.gatk.utils.commandline.{Input, Output} import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import java.io.File import java.io.File
class CoverageStats(val root:Configurable) extends PythonCommandLineFunction { class CoverageStats(val root: Configurable) extends PythonCommandLineFunction {
setPythonScript("bedtools_cov_stats.py") setPythonScript("bedtools_cov_stats.py")
@Input(doc="Input file") @Input(doc = "Input file")
var input: File = _ var input: File = _
@Output(doc="output File") @Output(doc = "output File")
var output: File = _ var output: File = _
@Output(doc="plot File (png)") @Output(doc = "plot File (png)")
var plot: File = _ var plot: File = _
def cmdLine = getPythonCommand + def cmdLine = getPythonCommand +
required(input) + required("--plot", plot) + " > " + required(output) required(input) + required("--plot", plot) + " > " + required(output)
} }
object CoverageStats { object CoverageStats {
def apply(root:Configurable, input:File, outputDir:String) : CoverageStats = { def apply(root: Configurable, input: File, outputDir: String): CoverageStats = {
val coverageStats = new CoverageStats(root) val coverageStats = new CoverageStats(root)
coverageStats.input = input coverageStats.input = input
coverageStats.output = new File(outputDir, input.getName + ".stats") coverageStats.output = new File(outputDir, input.getName + ".stats")
......
package nl.lumc.sasc.biopet.core package nl.lumc.sasc.biopet.core
abstract class BiopetCommandLineFunction extends BiopetCommandLineFunctionTrait { abstract class BiopetCommandLineFunction extends BiopetCommandLineFunctionTrait {
protected def cmdLine: String protected def cmdLine: String
final def commandLine: String = { final def commandLine: String = {
preCmdInternal preCmdInternal
......
...@@ -10,45 +10,45 @@ import scala.util.matching.Regex ...@@ -10,45 +10,45 @@ import scala.util.matching.Regex
trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurable { trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurable {
analysisName = getClass.getSimpleName analysisName = getClass.getSimpleName
@Input(doc="deps", required=false) @Input(doc = "deps", required = false)
var deps: List[File] = Nil var deps: List[File] = Nil
@Argument(doc="Threads", required=false) @Argument(doc = "Threads", required = false)
var threads = 0 var threads = 0
val defaultThreads = 1 val defaultThreads = 1
@Argument(doc="Vmem", required=false) @Argument(doc = "Vmem", required = false)
var vmem: String = _ var vmem: String = _
val defaultVmem: String = "" val defaultVmem: String = ""
@Argument(doc="Executable") @Argument(doc = "Executable")
var executable: String = _ var executable: String = _
protected def beforeCmd { protected def beforeCmd {
} }
protected def afterGraph { protected def afterGraph {
} }
override def freezeFieldValues() { override def freezeFieldValues() {
checkExecutable checkExecutable
afterGraph afterGraph
jobOutputFile = new File(firstOutput.getParent + "/." + firstOutput.getName + "." + analysisName + ".out") jobOutputFile = new File(firstOutput.getParent + "/." + firstOutput.getName + "." + analysisName + ".out")
if (threads == 0) threads = getThreads(defaultThreads) if (threads == 0) threads = getThreads(defaultThreads)
if (threads > 1) nCoresRequest = Option(threads) if (threads > 1) nCoresRequest = Option(threads)
if (vmem == null) { if (vmem == null) {
vmem = config("vmem") vmem = config("vmem")
if (vmem == null && !defaultVmem.isEmpty) vmem = defaultVmem if (vmem == null && !defaultVmem.isEmpty) vmem = defaultVmem
} }
if (vmem != null) jobResourceRequests :+= "h_vmem=" + vmem if (vmem != null) jobResourceRequests :+= "h_vmem=" + vmem
jobName = this.analysisName + ":" + firstOutput.getName jobName = this.analysisName + ":" + firstOutput.getName
super.freezeFieldValues() super.freezeFieldValues()
} }
protected def checkExecutable { protected def checkExecutable {
try if (executable != null) { try if (executable != null) {
val buffer = new StringBuffer() val buffer = new StringBuffer()
...@@ -66,22 +66,22 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -66,22 +66,22 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe) case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe)
} }
} }
final protected def preCmdInternal { final protected def preCmdInternal {
checkExecutable checkExecutable
//for (input <- this.inputs) if (!input.exists) throw new IllegalStateException("Input: " + input + " for " + analysisName + " is missing") //for (input <- this.inputs) if (!input.exists) throw new IllegalStateException("Input: " + input + " for " + analysisName + " is missing")
//logger.debug("Config for " + analysisName + ": " + localConfig) //logger.debug("Config for " + analysisName + ": " + localConfig)
beforeCmd beforeCmd
addJobReportBinding("cores", if (nCoresRequest.get.toInt > 0) nCoresRequest.get.toInt else 1) addJobReportBinding("cores", if (nCoresRequest.get.toInt > 0) nCoresRequest.get.toInt else 1)
addJobReportBinding("version", getVersion) addJobReportBinding("version", getVersion)
} }
protected def versionCommand: String = null protected def versionCommand: String = null
protected val versionRegex: Regex = null protected val versionRegex: Regex = null
protected val versionExitcode = List(0) // Can select multiple protected val versionExitcode = List(0) // Can select multiple
def getVersion : String = { def getVersion: String = {
if (versionCommand == null || versionRegex == null) return "N/A" if (versionCommand == null || versionRegex == null) return "N/A"
val buffer = new StringBuffer() val buffer = new StringBuffer()
val process = Process(versionCommand).run(ProcessLogger(buffer append _)) val process = Process(versionCommand).run(ProcessLogger(buffer append _))
...@@ -91,25 +91,25 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -91,25 +91,25 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
} }
val lines = versionCommand lines_! ProcessLogger(buffer append _) val lines = versionCommand lines_! ProcessLogger(buffer append _)
for (line <- lines) { for (line <- lines) {
line match { line match {
case versionRegex(m) => return m case versionRegex(m) => return m
case _ => case _ =>
} }
} }
logger.warn("Version command: '" + versionCommand + "' give a exit code " + process.exitValue + " but no version was found, executable oke?") logger.warn("Version command: '" + versionCommand + "' give a exit code " + process.exitValue + " but no version was found, executable oke?")
return "N/A" return "N/A"
} }
def getThreads(default:Int) : Int = { def getThreads(default: Int): Int = {
val maxThreads: Int = config("maxthreads", default=8) val maxThreads: Int = config("maxthreads", default = 8)
val threads: Int = config("threads", default=default) val threads: Int = config("threads", default = default)
if (maxThreads > threads) return threads if (maxThreads > threads) return threads
else return maxThreads else return maxThreads
} }
def getThreads(default:Int, module:String) : Int = { def getThreads(default: Int, module: String): Int = {
val maxThreads: Int = config("maxthreads", default=8, submodule=module) val maxThreads: Int = config("maxthreads", default = 8, submodule = module)
val threads: Int = config("threads", default=default, submodule=module) val threads: Int = config("threads", default = default, submodule = module)
if (maxThreads > threads) return threads if (maxThreads > threads) return threads
else return maxThreads else return maxThreads
} }
......
...@@ -4,12 +4,12 @@ import org.broadinstitute.gatk.queue.function.JavaCommandLineFunction ...@@ -4,12 +4,12 @@ import org.broadinstitute.gatk.queue.function.JavaCommandLineFunction
abstract class BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetCommandLineFunctionTrait { abstract class BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetCommandLineFunctionTrait {
executable = "java" executable = "java"
override def commandLine: String = { override def commandLine: String = {
preCmdInternal preCmdInternal
val cmd = super.commandLine val cmd = super.commandLine
val finalCmd = executable + cmd.substring(cmd.indexOf(" ")) val finalCmd = executable + cmd.substring(cmd.indexOf(" "))
// addJobReportBinding("command", cmd) // addJobReportBinding("command", cmd)
return cmd return cmd
} }
} }
...@@ -32,7 +32,7 @@ import org.broadinstitute.gatk.queue.util._ ...@@ -32,7 +32,7 @@ import org.broadinstitute.gatk.queue.util._
import org.broadinstitute.gatk.queue.QCommandPlugin import org.broadinstitute.gatk.queue.QCommandPlugin
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.QScriptManager import org.broadinstitute.gatk.queue.QScriptManager
import org.broadinstitute.gatk.queue.engine.{QStatusMessenger, QGraphSettings, QGraph} import org.broadinstitute.gatk.queue.engine.{ QStatusMessenger, QGraphSettings, QGraph }
import collection.JavaConversions._ import collection.JavaConversions._
import org.broadinstitute.gatk.utils.classloader.PluginManager import org.broadinstitute.gatk.utils.classloader.PluginManager
import org.broadinstitute.gatk.utils.exceptions.UserException import org.broadinstitute.gatk.utils.exceptions.UserException
...@@ -40,7 +40,7 @@ import org.broadinstitute.gatk.utils.io.IOUtils ...@@ -40,7 +40,7 @@ import org.broadinstitute.gatk.utils.io.IOUtils
import org.broadinstitute.gatk.utils.help.ApplicationDetails import org.broadinstitute.gatk.utils.help.ApplicationDetails
import java.io.FileOutputStream import java.io.FileOutputStream
import java.net.URL import java.net.URL
import java.util.{ResourceBundle, Arrays} import java.util.{ ResourceBundle, Arrays }
import org.broadinstitute.gatk.utils.text.TextFormattingUtils import org.broadinstitute.gatk.utils.text.TextFormattingUtils
import org.apache.commons.io.FilenameUtils import org.apache.commons.io.FilenameUtils
...@@ -84,11 +84,11 @@ object BiopetQCommandLine extends Logging { ...@@ -84,11 +84,11 @@ object BiopetQCommandLine extends Logging {
* Entry point of Queue. Compiles and runs QScripts passed in to the command line. * Entry point of Queue. Compiles and runs QScripts passed in to the command line.
*/ */
class BiopetQCommandLine extends CommandLineProgram with Logging { class BiopetQCommandLine extends CommandLineProgram with Logging {
@Input(fullName="script", shortName="S", doc="QScript scala file", required=false) @Input(fullName = "script", shortName = "S", doc = "QScript scala file", required = false)
@ClassType(classOf[File]) @ClassType(classOf[File])
var scripts: Seq[File] = Nil var scripts: Seq[File] = Nil
var pipelineName: String = _ var pipelineName: String = _
@ArgumentCollection @ArgumentCollection
val settings = new QGraphSettings val settings = new QGraphSettings
...@@ -155,8 +155,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging { ...@@ -155,8 +155,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
// TODO: Default command plugin argument? // TODO: Default command plugin argument?
val remoteFileConverter = ( val remoteFileConverter = (
for (commandPlugin <- allCommandPlugins if (commandPlugin.remoteFileConverter != null)) for (commandPlugin <- allCommandPlugins if (commandPlugin.remoteFileConverter != null))
yield commandPlugin.remoteFileConverter yield commandPlugin.remoteFileConverter).headOption.getOrElse(null)
).headOption.getOrElse(null)
if (remoteFileConverter != null) if (remoteFileConverter != null)
loadArgumentsIntoObject(remoteFileConverter) loadArgumentsIntoObject(remoteFileConverter)
...@@ -267,37 +266,35 @@ class BiopetQCommandLine extends CommandLineProgram with Logging { ...@@ -267,37 +266,35 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
override def getArgumentTypeDescriptors = override def getArgumentTypeDescriptors =
Arrays.asList(new ScalaCompoundArgumentTypeDescriptor) Arrays.asList(new ScalaCompoundArgumentTypeDescriptor)
override def getApplicationDetails : ApplicationDetails = { override def getApplicationDetails: ApplicationDetails = {
new ApplicationDetails(createQueueHeader(), new ApplicationDetails(createQueueHeader(),
Seq.empty[String], Seq.empty[String],
ApplicationDetails.createDefaultRunningInstructions(getClass.asInstanceOf[Class[CommandLineProgram]]), ApplicationDetails.createDefaultRunningInstructions(getClass.asInstanceOf[Class[CommandLineProgram]]),
"") "")
} }
private def createQueueHeader() : Seq[String] = { private def createQueueHeader(): Seq[String] = {
Seq(String.format("Queue v%s, Compiled %s", getQueueVersion, getBuildTimestamp), Seq(String.format("Queue v%s, Compiled %s", getQueueVersion, getBuildTimestamp),
"Copyright (c) 2012 The Broad Institute", "Copyright (c) 2012 The Broad Institute",
"For support and documentation go to http://www.broadinstitute.org/gatk") "For support and documentation go to http://www.broadinstitute.org/gatk")
} }
private def getQueueVersion : String = { private def getQueueVersion: String = {
val stingResources : ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText") val stingResources: ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
if ( stingResources.containsKey("org.broadinstitute.sting.queue.QueueVersion.version") ) { if (stingResources.containsKey("org.broadinstitute.sting.queue.QueueVersion.version")) {
stingResources.getString("org.broadinstitute.sting.queue.QueueVersion.version") stingResources.getString("org.broadinstitute.sting.queue.QueueVersion.version")
} } else {
else {
"<unknown>" "<unknown>"
} }
} }
private def getBuildTimestamp : String = { private def getBuildTimestamp: String = {
val stingResources : ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText") val stingResources: ResourceBundle = TextFormattingUtils.loadResourceBundle("StingText")
if ( stingResources.containsKey("build.timestamp") ) { if (stingResources.containsKey("build.timestamp")) {
stingResources.getString("build.timestamp") stingResources.getString("build.timestamp")
} } else {
else {
"<unknown>" "<unknown>"
} }
} }
......
...@@ -8,19 +8,19 @@ import org.broadinstitute.gatk.queue.QSettings ...@@ -8,19 +8,19 @@ import org.broadinstitute.gatk.queue.QSettings
import org.broadinstitute.gatk.queue.function.QFunction import org.broadinstitute.gatk.queue.function.QFunction
trait BiopetQScript extends Configurable { trait BiopetQScript extends Configurable {
@Argument(doc="Config Json file",shortName="config", required=false) @Argument(doc = "Config Json file", shortName = "config", required = false)
val configfiles: List