Commit 6f32526d authored by Peter van 't Hof's avatar Peter van 't Hof

Merge branch 'fix-BIOPET-383' into 'develop'

Fix biopet 383



See merge request !473
parents e07f79b0 3951e8b8
......@@ -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 =>
......
......@@ -14,7 +14,7 @@
*/
package nl.lumc.sasc.biopet.pipelines.mapping
import java.io.{File, FileOutputStream}
import java.io.{ File, FileOutputStream }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
......
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