Commit 441b74ac authored by Peter van 't Hof's avatar Peter van 't Hof

Merge remote-tracking branch 'remotes/origin/develop' into feature_annotation_versions

parents 1a85e5ca 6f32526d
......@@ -38,8 +38,6 @@ trait BiopetQScript extends Configurable with GatkLogging { qscript: QScript =>
if (config.contains("output_dir", path = Nil)) config("output_dir", path = Nil).asFile
else new File(".")
}
require(outputDir.canRead, s"No premision to read outputdir: $outputDir")
require(outputDir.canWrite, s"No premision to read outputdir: $outputDir")
@Argument(doc = "Disable all scatters", shortName = "DSC", required = false)
var disableScatter: Boolean = false
......@@ -161,10 +159,10 @@ object BiopetQScript {
def checkOutputDir(outputDir: File): Unit = {
// Sanity checks
require(outputDir.getParentFile.canRead, s"No premision to read parent of outputdir: ${outputDir.getParentFile}")
require(outputDir.getParentFile.canWrite, s"No premision to write parent of outputdir: ${outputDir.getParentFile}")
require(outputDir.getAbsoluteFile.getParentFile.canRead, s"No premision to read parent of outputdir: ${outputDir.getParentFile}")
require(outputDir.getAbsoluteFile.getParentFile.canWrite, s"No premision to write parent of outputdir: ${outputDir.getParentFile}")
outputDir.mkdir()
require(outputDir.canRead, s"No premision to read outputdir: $outputDir")
require(outputDir.canWrite, s"No premision to write outputdir: $outputDir")
require(outputDir.getAbsoluteFile.canRead, s"No premision to read outputdir: $outputDir")
require(outputDir.getAbsoluteFile.canWrite, s"No premision to write outputdir: $outputDir")
}
}
......@@ -52,7 +52,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
/** Adds the library jobs */
final def addAndTrackJobs(): Unit = {
if (nameRegex.findFirstIn(libId) == None)
if (nameRegex.findFirstIn(libId).isEmpty)
Logging.addError(s"Library '$libId' $nameError")
currentSample = Some(sampleId)
currentLib = Some(libId)
......@@ -139,9 +139,13 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
*/
def makeLibrary(id: String): Library
/** returns a set with library names */
/** returns a set with library names or throws error when not found */
protected def libIds: Set[String] = {
ConfigUtils.getMapFromPath(globalConfig.map, List("samples", sampleId, "libraries")).getOrElse(Map()).keySet
val ids = ConfigUtils.getMapFromPath(globalConfig.map, List("samples", sampleId, "libraries")).getOrElse(Map()).keySet
if (ids.isEmpty) {
throw new IllegalStateException(s"No libraries found in config for sample $sampleId")
}
ids
}
/** Name overules the one from qscript */
......@@ -151,7 +155,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
/** Adds sample jobs */
final def addAndTrackJobs(): Unit = {
if (nameRegex.findFirstIn(sampleId) == None)
if (nameRegex.findFirstIn(sampleId).isEmpty)
Logging.addError(s"Sample '$sampleId' $nameError")
currentSample = Some(sampleId)
addJobs()
......
......@@ -15,10 +15,9 @@
package nl.lumc.sasc.biopet.core
import java.io.File
import nl.lumc.sasc.biopet.core.MultiSampleQScript.Gender
import nl.lumc.sasc.biopet.core.extensions.Md5sum
import nl.lumc.sasc.biopet.utils.{ Logging, ConfigUtils }
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.QScript
import org.scalatest.Matchers
......@@ -119,6 +118,11 @@ class MultiSampleQScriptTest extends TestNGSuite with Matchers {
"Dash (-) and underscore (_) are permitted."
}
@Test
def testNoLibSample(): Unit = {
an[IllegalStateException] shouldBe thrownBy(MultiSampleQScriptTest(noLibSample :: Nil))
}
}
object MultiSampleQScriptTest {
......@@ -153,10 +157,48 @@ object MultiSampleQScriptTest {
"lib1" -> Map("test" -> "4-1")
))))
val child = Map("samples" -> Map("child" -> Map("tags" -> Map(
"gender" -> "male", "father" -> "father", "mother" -> "mother"))))
val father = Map("samples" -> Map("father" -> Map("tags" -> Map("gender" -> "male"))))
val mother = Map("samples" -> Map("mother" -> Map("tags" -> Map("gender" -> "female"))))
val child = Map(
"samples" -> Map(
"child" -> Map(
"tags" -> Map(
"gender" -> "male",
"father" -> "father",
"mother" -> "mother"
),
"libraries" -> Map(
"lib1" -> Map("test" -> "child-1")
)
)
)
)
val father = Map(
"samples" -> Map(
"father" -> Map(
"tags" -> Map("gender" -> "male"),
"libraries" -> Map(
"lib1" -> Map("test" -> "father-1")
)
)
)
)
val mother = Map(
"samples" -> Map(
"mother" -> Map(
"tags" -> Map("gender" -> "female"),
"libraries" -> Map(
"lib1" -> Map("test" -> "mother-1")
)
)
)
)
val noLibSample = Map(
"samples" -> Map(
"sample1" -> Map(
"tags" -> Map("gender" -> "female")
)
)
)
def apply(configs: List[Map[String, Any]], only: List[String] = Nil) = {
new QScript with MultiSampleQScript { qscript =>
......
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