Commit 3a5c0f08 authored by bow's avatar bow

Merge branch 'fix-sample_flexiprep' into 'develop'

Fixed sample and library check

Fixes #357 

See merge request !423
parents 63029298 20d86c78
......@@ -16,11 +16,11 @@ package nl.lumc.sasc.biopet.pipelines.flexiprep
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ BiopetFifoPipe, PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.{ Zcat, Gzip }
import nl.lumc.sasc.biopet.extensions.{ Gzip, Zcat }
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.IoUtils._
import nl.lumc.sasc.biopet.extensions.tools.{ ValidateFastq, SeqStat, FastqSync }
import nl.lumc.sasc.biopet.extensions.tools.{ FastqSync, SeqStat, ValidateFastq }
import nl.lumc.sasc.biopet.utils.Logging
import org.broadinstitute.gatk.queue.QScript
class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with SampleLibraryTag {
......@@ -74,33 +74,37 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
/** Function that's need to be executed before the script is accessed */
def init() {
require(outputDir != null, "Missing output directory on flexiprep module")
require(inputR1 != null, "Missing input R1 on flexiprep module")
require(sampleId != null, "Missing sample ID on flexiprep module")
require(libId != null, "Missing library ID on flexiprep module")
if (inputR1 == null) Logging.addError("Missing input R1 on flexiprep module")
if (sampleId == null || sampleId == None) Logging.addError("Missing sample ID on flexiprep module")
if (libId == null || libId == None) Logging.addError("Missing library ID on flexiprep module")
paired = inputR2.isDefined
if (inputR1 == null) Logging.addError("Missing input R1 on flexiprep module")
else {
paired = inputR2.isDefined
inputFiles :+= new InputFile(inputR1)
inputR2.foreach(inputFiles :+= new InputFile(_))
inputFiles :+= new InputFile(inputR1)
inputR2.foreach(inputFiles :+= new InputFile(_))
R1Name = getUncompressedFileName(inputR1)
inputR2.foreach { fileR2 =>
paired = true
R2Name = getUncompressedFileName(fileR2)
R1Name = getUncompressedFileName(inputR1)
inputR2.foreach { fileR2 =>
paired = true
R2Name = getUncompressedFileName(fileR2)
}
}
}
/** Script to add jobs */
def biopetScript() {
runInitialJobs()
if (inputR1 != null) {
runInitialJobs()
if (paired) runTrimClip(inputR1, inputR2, outputDir)
else runTrimClip(inputR1, outputDir)
if (paired) runTrimClip(inputR1, inputR2, outputDir)
else runTrimClip(inputR1, outputDir)
val R1Files = for ((k, v) <- outputFiles if k.endsWith("output_R1")) yield v
val R2Files = for ((k, v) <- outputFiles if k.endsWith("output_R2")) yield v
runFinalize(R1Files.toList, R2Files.toList)
val R1Files = for ((k, v) <- outputFiles if k.endsWith("output_R1")) yield v
val R2Files = for ((k, v) <- outputFiles if k.endsWith("output_R2")) yield v
runFinalize(R1Files.toList, R2Files.toList)
}
}
/** Add init non chunkable jobs */
......
......@@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.flexiprep
import java.io.File
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.tools.{ ValidateFastq, SeqStat }
import nl.lumc.sasc.biopet.extensions.tools.{ SeqStat, ValidateFastq }
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
......@@ -83,6 +83,18 @@ class FlexiprepTest extends TestNGSuite with Matchers {
}
@Test
def testNoSample: Unit = {
val map = ConfigUtils.mergeMaps(Map(
"output_dir" -> FlexiprepTest.outputDir
), Map(FlexiprepTest.executables.toSeq: _*))
val flexiprep: Flexiprep = initPipeline(map)
intercept[IllegalStateException] {
flexiprep.script()
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
FileUtils.deleteDirectory(FlexiprepTest.outputDir)
......
......@@ -18,6 +18,7 @@ import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.BiopetQScript.InputFile
import nl.lumc.sasc.biopet.core.{ PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.pipelines.flexiprep.Flexiprep
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript
......@@ -48,6 +49,7 @@ class GearsSingle(val root: Configurable) extends QScript with SummaryQScript wi
def init(): Unit = {
require(fastqR1.isDefined || bamFile.isDefined, "Please specify fastq-file(s) or bam file")
require(fastqR1.isDefined != bamFile.isDefined, "Provide either a bam file or a R1/R2 file")
if (sampleId == null || sampleId == None) Logging.addError("Missing sample ID on GearsSingle module")
if (outputName == null) {
if (fastqR1.isDefined) outputName = fastqR1.map(_.getName
......@@ -80,6 +82,8 @@ class GearsSingle(val root: Configurable) extends QScript with SummaryQScript wi
val flexiprep = new Flexiprep(this)
flexiprep.inputR1 = r1
flexiprep.inputR2 = r2
flexiprep.sampleId = if (sampleId.isEmpty) Some("noSampleName") else sampleId
flexiprep.libId = if (libId.isEmpty) Some("noLibName") else libId
flexiprep.outputDir = new File(outputDir, "flexiprep")
add(flexiprep)
(flexiprep.fastqR1Qc, flexiprep.fastqR2Qc)
......
......@@ -80,6 +80,8 @@ class GearsSingleTest extends TestNGSuite with Matchers {
), Map(GearsSingleTest.executables.toSeq: _*))
val gears: GearsSingle = initPipeline(map)
gears.sampleId = Some("sampleName")
gears.libId = Some("libName")
if (fromBam) {
gears.bamFile = Some(GearsSingleTest.bam)
......@@ -113,6 +115,18 @@ class GearsSingleTest extends TestNGSuite with Matchers {
gears.functions.count(_.isInstanceOf[KrakenReportToJson]) shouldBe (if (kraken) 1 else 0)
}
@Test
def testNoSample: Unit = {
val map = ConfigUtils.mergeMaps(Map(
"output_dir" -> GearsSingleTest.outputDir
), Map(GearsSingleTest.executables.toSeq: _*))
val gears: GearsSingle = initPipeline(map)
intercept[IllegalArgumentException] {
gears.script()
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
FileUtils.deleteDirectory(GearsSingleTest.outputDir)
......
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