Commit dd937c3a authored by pjvan_thof's avatar pjvan_thof
Browse files

Merge remote-tracking branch 'remotes/origin/develop' into fix-BIOPET-718

parents 4989de28 9b83c7aa
......@@ -29,7 +29,7 @@ node('local') {
sh 'mkdocs build --clean --strict'
}
if (currentBuild.result == null || "SUCCESS".equals(currentBuild.result)) {
if (currentBuild.result == null || "SUCCESS" == currentBuild.result) {
currentBuild.result = "SUCCESS"
slackSend(color: '#00FF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
} else {
......@@ -37,7 +37,7 @@ node('local') {
}
} catch (e) {
if (currentBuild.result == null || "FAILED".equals(currentBuild.result)) {
if (currentBuild.result == null || "FAILED" == currentBuild.result) {
currentBuild.result = "FAILED"
}
slackSend(color: '#FF0000', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
......
......@@ -31,7 +31,7 @@ class Bam2Wig(val parent: Configurable) extends QScript with BiopetQScript {
def this() = this(null)
@Input(doc = "Input bam file", required = true)
var bamFile: File = null
var bamFile: File = _
def init(): Unit = {
inputFiles :+= new InputFile(bamFile)
......
......@@ -32,7 +32,7 @@ class BamToChromSizesTest extends TestNGSuite with Matchers {
}
@Test
def testChromSizes: Unit = {
def testChromSizes(): Unit = {
val bamFile = new File(resourcePath("/empty.bam"))
val bamToChromSizes = new BamToChromSizes(null)
bamToChromSizes.bamFile = bamFile
......
......@@ -13,8 +13,8 @@
<tr><th>Version</th><td>${run.version}</td></tr>
<tr><th>Last commit hash</th><td>${run.commitHash}</td></tr>
<tr><th>Output directory</th><td>${run.outputDir}</td></tr>
<tr><th>Sample</th><td>${allSamples.filter(_.id == sampleId.get).headOption.map(_.name)}</td></tr>
<tr><th>Library</th><td>${allLibraries.filter(_.id == libId.get).headOption.map(_.name)}</td></tr>
<tr><th>Sample</th><td>${allSamples.find(_.id == sampleId.get).map(_.name)}</td></tr>
<tr><th>Library</th><td>${allLibraries.find(_.id == libId.get).map(_.name)}</td></tr>
</tbody>
</table>
<br/>
......
......@@ -48,7 +48,7 @@ class BamMetrics(val parent: Configurable)
override def defaults = Map("bedtoolscoverage" -> Map("sorted" -> true))
/** returns files to store in summary */
def summaryFiles =
def summaryFiles: Map[String, File] =
Map("reference" -> referenceFasta(), "input_bam" -> inputBam) ++
ampliconBedFile.map("amplicon" -> _).toMap ++
ampliconBedFile.map(x => "roi_" + x.getName.stripSuffix(".bed") -> x).toMap
......@@ -58,7 +58,7 @@ class BamMetrics(val parent: Configurable)
Map("amplicon_name" -> ampliconBedFile.collect { case x => x.getName.stripSuffix(".bed") },
"roi_name" -> roiBedFiles.map(_.getName.stripSuffix(".bed")))
override def reportClass = {
override def reportClass: Some[BammetricsReport] = {
val bammetricsReport = new BammetricsReport(this)
bammetricsReport.outputDir = new File(outputDir, "report")
bammetricsReport.summaryDbFile = summaryDbFile
......
......@@ -487,7 +487,7 @@ object BammetricsReport extends ReportBuilder {
}
def writeTableToTsv(tsvFile: File, table: Map[String, Array[Any]], firstColumn: String): Unit = {
require(table.map(_._2.size).toList.distinct.size == 1,
require(table.map(_._2.length).toList.distinct.size == 1,
"Not all values has the same number or rows")
val keys = table.keys.filterNot(_ == firstColumn).toList.sorted
val writer = new PrintWriter(tsvFile)
......
......@@ -44,7 +44,7 @@ class BamMetricsTest extends TestNGSuite with Matchers {
}
@DataProvider(name = "bammetricsOptions")
def bammetricsOptions = {
def bammetricsOptions: Array[Array[AnyVal]] = {
val rois = Array(0, 1, 2, 3)
val bool = Array(true, false)
......@@ -57,7 +57,7 @@ class BamMetricsTest extends TestNGSuite with Matchers {
private var dirs: List[File] = Nil
@Test(dataProvider = "bammetricsOptions")
def testBamMetrics(rois: Int, amplicon: Boolean, rna: Boolean, wgs: Boolean) = {
def testBamMetrics(rois: Int, amplicon: Boolean, rna: Boolean, wgs: Boolean): Unit = {
val outputDir = Files.createTempDir()
dirs :+= outputDir
val map = ConfigUtils.mergeMaps(Map("output_dir" -> outputDir,
......@@ -74,8 +74,6 @@ class BamMetricsTest extends TestNGSuite with Matchers {
bammetrics.libId = Some("1")
bammetrics.script()
var regions: Int = rois + (if (amplicon) 1 else 0)
bammetrics.functions.count(_.isInstanceOf[CollectRnaSeqMetrics]) shouldBe (if (rna) 1 else 0)
bammetrics.functions.count(_.isInstanceOf[CollectWgsMetrics]) shouldBe (if (wgs) 1 else 0)
bammetrics.functions.count(_.isInstanceOf[CollectMultipleMetrics]) shouldBe 1
......@@ -86,13 +84,13 @@ class BamMetricsTest extends TestNGSuite with Matchers {
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
@AfterClass def removeTempOutputDir(): Unit = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object BamMetricsTest {
val inputDir = Files.createTempDir()
val inputDir: File = Files.createTempDir()
val bam = new File(inputDir, "bla.bam")
Files.touch(bam)
......@@ -100,7 +98,7 @@ object BamMetricsTest {
Files.touch(ampliconBed)
def roi(i: Int): File = {
val roi = new File(inputDir, s"roi${i}.bed")
val roi = new File(inputDir, s"roi$i.bed")
Files.touch(roi)
roi
}
......
......@@ -42,7 +42,7 @@ class Basty(val parent: Configurable) extends QScript with MultiSampleQScript {
def variantcallers = List("unifiedgenotyper")
val numBoot = config("boot_runs", default = 100, namespace = "raxml").asInt
val numBoot: Int = config("boot_runs", default = 100, namespace = "raxml").asInt
override def defaults = Map(
"ploidy" -> 1,
......
......@@ -48,7 +48,7 @@ class BastyTest extends TestNGSuite with Matchers {
}
@DataProvider(name = "bastyOptions")
def bastyOptions = {
def bastyOptions: Array[Array[Any]] = {
for (s1 <- sample1; s2 <- sample2) yield Array("", s1, s2)
}
......@@ -114,7 +114,7 @@ class BastyTest extends TestNGSuite with Matchers {
numberSamples
else 0)
pipeline.functions.count(_.isInstanceOf[BaseRecalibrator]) shouldBe (if (dbsnp && baseRecalibration)
(numberLibs * 2)
numberLibs * 2
else 0)
pipeline.functions.count(_.isInstanceOf[PrintReads]) shouldBe (if (dbsnp && baseRecalibration)
numberLibs
......@@ -125,7 +125,7 @@ class BastyTest extends TestNGSuite with Matchers {
pipeline.summaryFiles shouldBe Map()
pipeline.samples foreach {
case (sampleId, sample) =>
case (_, sample) =>
sample.summarySettings shouldBe Map()
sample.summaryFiles.get("variants_fasta") should not be None
sample.summaryFiles.get("consensus_fasta") should not be None
......@@ -135,7 +135,7 @@ class BastyTest extends TestNGSuite with Matchers {
sample.summaryFiles.get("snps_only_consensus_variants_fasta") should not be None
sample.summaryStats shouldBe Map()
sample.libraries.foreach {
case (libId, lib) =>
case (_, lib) =>
lib.summarySettings shouldBe Map()
lib.summaryFiles shouldBe Map()
lib.summaryStats shouldBe Map()
......@@ -154,14 +154,14 @@ class BastyTest extends TestNGSuite with Matchers {
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
@AfterClass def removeTempOutputDir(): Unit = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object BastyTest {
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
def outputDir: File = Files.createTempDir()
val inputDir: File = Files.createTempDir()
def inputTouch(name: String): String = {
val file = new File(inputDir, name)
......
......@@ -150,10 +150,9 @@ body {
float:right;
width:0;
height:0;
border-color:transparent;
border-style:solid;
border-width:5px 0 5px 5px;
border-left-color:#cccccc;
border: 5px solid transparent;
border-right-width: 0;
border-left-color: #cccccc;
margin-top:5px;
margin-right:-10px;
}
......
......@@ -46,9 +46,7 @@ table[data-sortable] th:after {
vertical-align: inherit;
height: 0;
width: 0;
border-width: 5px;
border-style: solid;
border-color: transparent;
border: 5px solid transparent;
margin-right: 1px;
margin-left: 10px;
float: right;
......
......@@ -31,9 +31,9 @@
<tbody>
#for (file <- files)
<tr><td>${allPipelines.find(_.id == file.pipelineId).map(_.name)}</td>
<td>${file.moduleId.map(id => allModules.find(x => x.pipelineId == file.pipelineId && file.moduleId == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.sampleId.map(id => allSamples.find(_.id == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.libraryId.map(id => allLibraries.find(_.id == id).map(_.name)).flatten.getOrElse(("-"))}</td>
<td>${file.moduleId.flatMap(id => allModules.find(x => x.pipelineId == file.pipelineId && file.moduleId == id).map(_.name)).getOrElse("-")}</td>
<td>${file.sampleId.flatMap(id => allSamples.find(_.id == id).map(_.name)).getOrElse("-")}</td>
<td>${file.libraryId.flatMap(id => allLibraries.find(_.id == id).map(_.name)).getOrElse("-")}</td>
<td>${file.key}</td>
<td>${file.path}</td>
<td>${file.md5}</td></tr>
......
......@@ -42,7 +42,7 @@
val tabIndex = if (first) " tabindex='-1'" else ""
// val listGroupA = if(subPage._2.subPages.nonEmpty) "list-group-item" else ""
var menuItem: String = "<li class='%s'>".format(listSubmenu) +
val menuItem: String = "<li class='%s'>".format(listSubmenu) +
"<a href='%s' class='%s'%s>".format(href, "", tabIndex) +
"%s".format(subPageName) +
"</a>" +
......@@ -93,7 +93,7 @@
<script language="JavaScript">
<!--
$(document).ready(function() {
Sortable.init()
Sortable.init();
$('body').scrollspy({
target: '.bs-sidebar'
......@@ -135,14 +135,14 @@
<a href="${rootPath}index.html">Home
#if (iPage.subPages.nonEmpty) <b class="caret"></b> #end
</a>
${unescape(createMenu(iPage, Nil, false))}
${unescape(createMenu(iPage, Nil, first = false))}
</li>
#else
<li class="root #if (t == path.size) active #end">
<a href="${rootPath}${path.slice(0,t).mkString("", "/", "/")}index.html">${path( t - 1 )}
#if (getSubPage(path.slice(0, t)).subPages.nonEmpty) <b class="caret"></b> #end
</a>
${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t), false))}
${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t), first = false))}
</li>
#end
#end
......
......@@ -60,10 +60,10 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
/**
* This value is used to let you job wait a x number of second after it finish.
* This is ionly used when having storage delay issues
* This value is used to let you job wait a x number of second after it finish.
* This is ionly used when having storage delay issues
*/
var jobDelayTime: Option[Int] = config("job_delay_time")
val jobDelayTime: Option[Int] = config("job_delay_time")
// This overrides the default "sh" from queue. For Biopet the default is "bash"
updateJobRun = {
......@@ -147,9 +147,9 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
private[core] var _inputAsStdin = false
def inputAsStdin = _inputAsStdin
def inputAsStdin: Boolean = _inputAsStdin
private[core] var _outputAsStdout = false
def outputAsStdout = _outputAsStdout
def outputAsStdout: Boolean = _outputAsStdout
/**
* This operator sends stdout to `that` and combine this into 1 command line function
......@@ -212,13 +212,13 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
maxGroups: Int = 0): String = {
if (values.size % groupSize != 0)
Logging.addError(
s"Arg '${argName}' values: '${values}' does not fit to a groupSize of ${groupSize}")
s"Arg '$argName' values: '$values' does not fit to a groupSize of $groupSize")
val groups = values.size / groupSize
if (groups < minGroups)
Logging.addError(s"Args '${argName}' need atleast $minGroups with size $groupSize")
Logging.addError(s"Args '$argName' need atleast $minGroups with size $groupSize")
if (maxGroups > 0 && groups > maxGroups)
Logging.addError(s"Args '${argName}' may only have $maxGroups with size $groupSize")
if (values.nonEmpty) required(argName) + values.map(required(_)).mkString
Logging.addError(s"Args '$argName' may only have $maxGroups with size $groupSize")
if (values.nonEmpty) required(argName) + values.map(required).mkString
else ""
}
......@@ -251,7 +251,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
private[core] var _pipesJobs: List[BiopetCommandLineFunction] = Nil
def pipesJobs = _pipesJobs
def pipesJobs: List[BiopetCommandLineFunction] = _pipesJobs
def addPipeJob(job: BiopetCommandLineFunction) {
_pipesJobs :+= job
_pipesJobs = _pipesJobs.distinct
......
......@@ -30,7 +30,7 @@ trait BiopetJavaCommandLineFunction
override def defaultVmemFactor: Double = 2.0
/** Constructs java opts, this adds scala threads */
override def javaOpts =
override def javaOpts: String =
super.javaOpts +
optional("-Dscala.concurrent.context.numThreads=", threads, spaceSeparated = false) +
optional("-Dscala.concurrent.context.maxThreads=", threads, spaceSeparated = false)
......
......@@ -30,14 +30,14 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo
lazy val input: List[File] = try {
commands.flatMap(_.inputs)
} catch {
case e: Exception => Nil
case _: Exception => Nil
}
@Output
lazy val output: List[File] = try {
commands.flatMap(_.outputs)
} catch {
case e: Exception => Nil
case _: Exception => Nil
}
_pipesJobs :::= commands
......@@ -74,7 +74,7 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo
override def defaultThreads = 0
val parent: Configurable = commands.head.parent
override def configNamespace = commands.map(_.configNamespace).mkString("-")
override def configNamespace: String = commands.map(_.configNamespace).mkString("-")
def cmdLine: String = {
"(" + commands.head.cmdLine + (if (commands.head.stdinFile.isDefined) {
" < " + required(
......@@ -90,4 +90,4 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo
super.freezeFieldValues()
commands.foreach(_.qSettings = qSettings)
}
}
}
\ No newline at end of file
......@@ -221,7 +221,7 @@ object BiopetQScript {
try {
Some(function.inputs)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......@@ -229,7 +229,7 @@ object BiopetQScript {
try {
Some(function.outputs)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......@@ -237,7 +237,7 @@ object BiopetQScript {
try {
Some(function.doneOutputs)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......@@ -245,7 +245,7 @@ object BiopetQScript {
try {
Some(function.failOutputs)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......@@ -253,7 +253,7 @@ object BiopetQScript {
try {
Some(function.isDone)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......@@ -261,7 +261,7 @@ object BiopetQScript {
try {
Some(function.isFail)
} catch {
case e: NullPointerException => None
case _: NullPointerException => None
}
}
......
......@@ -32,7 +32,7 @@ trait CommandLineResources extends CommandLineFunction with Configurable {
def defaultThreads = 1
/** This method will get and set the cores requested */
final def threads = nCoresRequest match {
final def threads: Int = nCoresRequest match {
case Some(i) => i
case _ =>
val t = getThreads
......@@ -47,14 +47,15 @@ trait CommandLineResources extends CommandLineFunction with Configurable {
def defaultCoreMemory: Double = 2.0
def defaultVmemFactor: Double = 1.4
def defaultResidentFactor: Double = 1.2
var vmemFactor: Double = config("vmem_factor", default = defaultVmemFactor)
val vmemFactor: Double = config("vmem_factor", default = defaultVmemFactor)
val useSge: Boolean = config("use_sge", default = true)
var residentFactor: Double = config("resident_factor", default = defaultResidentFactor)
val residentFactor: Double = config("resident_factor", default = defaultResidentFactor)
private var _coreMemory: Double = 2.0
def coreMemory = _coreMemory
def coreMemory: Double = _coreMemory
/** This value is for SGE and is defined in seconds */
wallTime = config("max_walltime")
......@@ -92,7 +93,7 @@ trait CommandLineResources extends CommandLineFunction with Configurable {
val firstOutput = try {
this.firstOutput
} catch {
case e: NullPointerException => null
case _: NullPointerException => null
}
nCoresRequest = Option(threads)
......
......@@ -25,6 +25,7 @@ import org.broadinstitute.gatk.queue.QScript
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.matching.Regex
/** This trait creates a structured way of use multisample pipelines */
trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
......@@ -84,7 +85,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
namespace = libId,
path = List("samples", sampleId, "libraries"))
def sampleId = sample.sampleId
def sampleId: String = sample.sampleId
lazy val libGroups: List[String] = libTags.get("groups") match {
case Some(g: List[_]) => g.map(_.toString)
......@@ -109,42 +110,46 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
namespace = sampleId,
path = List("samples"))
lazy val gender = {
lazy val gender: MultiSampleQScript.Gender.Value = {
val g: Option[String] = sampleTags.get("gender").map(_.toString)
g.map(_.toLowerCase) match {
case Some("male") => Gender.Male
case Some("female") => Gender.Female
case Some(s) =>
case Some(_) =>
logger.warn(s"Could not convert '$g' to a gender")
Gender.Unknown
case _ => Gender.Unknown
}
}
lazy val father = {
lazy val father: Option[String] = {
val g: Option[String] = sampleTags.get("father").map(_.toString)
g.foreach { father =>
if (sampleId != father) Logging.addError(s"Father for $sampleId can not be itself")
if (samples.contains(father))
if (samples(father).gender == Gender.Male)
Logging.addError(s"Father of $sampleId is not a female")
else logger.warn(s"For sample '$sampleId' is father '$father' not found in config")
if (sampleId == father) Logging.addError(s"Father for $sampleId can not be itself")
if (samples.contains(father)) {
if (samples(father).gender != Gender.Male)
Logging.addError(s"Father of $sampleId is not a male")
} else logger.warn(s"For sample '$sampleId', its father '$father' not found in config")
}
g
}
lazy val mother = {
lazy val mother: Option[String] = {
val g: Option[String] = sampleTags.get("mother").map(_.toString)
g.foreach { mother =>
if (sampleId != mother) Logging.addError(s"mother for $sampleId can not be itself")
if (samples.contains(mother))
if (samples(mother).gender == Gender.Female)
if (sampleId == mother) Logging.addError(s"mother for $sampleId can not be itself")
if (samples.contains(mother)) {
if (samples(mother).gender != Gender.Female)
Logging.addError(s"Mother of $sampleId is not a female")
else logger.warn(s"For sample '$sampleId' is mother '$mother' not found in config")
} else logger.warn(s"For sample '$sampleId', its mother '$mother' not found in config")
}
g
}
lazy val family: Option[String] = {
sampleTags.get("family").map(_.toString)
}
lazy val sampleGroups: List[String] = sampleTags.get("groups") match {
case Some(g: List[_]) => g.map(_.toString)
case Some(g: String) => List(g)
......@@ -195,7 +200,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
/** function add all libraries in one call */
protected final def addPerLibJobs(): Unit = {
for ((libId, library) <- libraries) {
for ((_, library) <- libraries) {
library.addAndTrackJobs()
}
}
......@@ -224,8 +229,8 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
protected def sampleIds: Set[String] =
ConfigUtils.any2map(globalConfig.map.getOrElse("samples", Map())).keySet
protected lazy val nameRegex = """^[a-zA-Z0-9][a-zA-Z0-9-_]+[a-zA-Z0-9]$""".r
protected lazy val nameError = "has an invalid name. " +
protected lazy val nameRegex: Regex = """^[a-zA-Z0-9][a-zA-Z0-9-_]+[a-zA-Z0-9]$""".r
protected lazy val nameError: String = "has an invalid name. " +
"Sample names must have at least 3 characters, " +
"must begin and end with an alphanumeric character, " +
"and must not have whitespace and special characters. " +
......@@ -277,7 +282,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
sample ::: lib ::: super.configFullPath
}
def initSummaryDb: Unit = {
def initSummaryDb(): Unit = {
val db = SummaryDb.openSqliteSummary(summaryDbFile)
val namesOld = Await.result(db.getSamples(runId = Some(summaryRunId)).map(_.map(_.name).toSet),
Duration.Inf)
......@@ -312,4 +317,4 @@ object MultiSampleQScript {
val Male, Female, Unknown = Value
}
}
}
\ No newline at end of file
package nl.lumc.sasc.biopet.core
import java.io.PrintWriter
import nl.lumc.sasc.biopet.core.PedigreeQscript.PedMergeStrategy
import nl.lumc.sasc.biopet.utils.Logging
import org.broadinstitute.gatk.queue.QScript
import scala.io.Source
/**
* Cr