Commit face5d0e authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Fixing BIOPET-413 and BIOPET-416

parent 15658350
...@@ -2,7 +2,7 @@ package nl.lumc.sasc.biopet.pipelines.gears ...@@ -2,7 +2,7 @@ package nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.core.SampleLibraryTag import nl.lumc.sasc.biopet.core.SampleLibraryTag
import nl.lumc.sasc.biopet.core.summary.SummaryQScript import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.Gzip import nl.lumc.sasc.biopet.extensions.{ Gzip, Zcat }
import nl.lumc.sasc.biopet.extensions.centrifuge.{ Centrifuge, CentrifugeKreport } import nl.lumc.sasc.biopet.extensions.centrifuge.{ Centrifuge, CentrifugeKreport }
import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
...@@ -27,30 +27,28 @@ class GearsCentrifuge(val root: Configurable) extends QScript with SummaryQScrip ...@@ -27,30 +27,28 @@ class GearsCentrifuge(val root: Configurable) extends QScript with SummaryQScrip
} }
def centrifugeOutput = new File(outputDir, s"$outputName.centrifuge.gz") def centrifugeOutput = new File(outputDir, s"$outputName.centrifuge.gz")
def centrifugeMetOutput = new File(outputDir, s"$outputName.centrifuge.met")
def biopetScript(): Unit = { def biopetScript(): Unit = {
val centrifuge = new Centrifuge(this) val centrifuge = new Centrifuge(this)
centrifuge.inputR1 = fastqR1 centrifuge.inputR1 = fastqR1
centrifuge.inputR2 = fastqR2 centrifuge.inputR2 = fastqR2
centrifuge.output = new File(outputDir, s"$outputName.centrifuge")
centrifuge.report = Some(new File(outputDir, s"$outputName.centrifuge.report")) centrifuge.report = Some(new File(outputDir, s"$outputName.centrifuge.report"))
centrifuge.isIntermediate = true centrifuge.metFile = Some(centrifugeMetOutput)
add(centrifuge) val centrifugeCmd = centrifuge | new Gzip(this) > centrifugeOutput
add(centrifugeCmd)
add(Gzip(this, centrifuge.output, centrifugeOutput)) makeKreport("centrifuge", unique = false)
makeKreport("centrifuge_unique", unique = true)
makeKreport(List(centrifuge.output), "centrifuge", unique = false)
makeKreport(List(centrifuge.output), "centrifuge_unique", unique = true)
addSummaryJobs() addSummaryJobs()
} }
protected def makeKreport(inputFiles: List[File], name: String, unique: Boolean): Unit = { protected def makeKreport(name: String, unique: Boolean): Unit = {
val centrifugeKreport = new CentrifugeKreport(this) val centrifugeKreport = new CentrifugeKreport(this)
centrifugeKreport.centrifugeOutputFiles = inputFiles
centrifugeKreport.output = new File(outputDir, s"$outputName.$name.kreport") centrifugeKreport.output = new File(outputDir, s"$outputName.$name.kreport")
centrifugeKreport.onlyUnique = unique centrifugeKreport.onlyUnique = unique
add(centrifugeKreport) add(centrifugeOutput :<: Zcat(this) | centrifugeKreport)
val krakenReportJSON = new KrakenReportToJson(this) val krakenReportJSON = new KrakenReportToJson(this)
krakenReportJSON.inputReport = centrifugeKreport.output krakenReportJSON.inputReport = centrifugeKreport.output
...@@ -72,5 +70,4 @@ class GearsCentrifuge(val root: Configurable) extends QScript with SummaryQScrip ...@@ -72,5 +70,4 @@ class GearsCentrifuge(val root: Configurable) extends QScript with SummaryQScrip
case Some(file) => Map("input_R2" -> file) case Some(file) => Map("input_R2" -> file)
case _ => Map() case _ => Map()
}) })
} }
...@@ -129,8 +129,8 @@ abstract class TestGearsSingle extends TestNGSuite with Matchers { ...@@ -129,8 +129,8 @@ abstract class TestGearsSingle extends TestNGSuite with Matchers {
gears.functions.count(_.isInstanceOf[KrakenReportToJson]) shouldBe gears.functions.count(_.isInstanceOf[KrakenReportToJson]) shouldBe
((if (kraken.getOrElse(false)) 1 else 0) + (if (centrifuge) 2 else 0)) ((if (kraken.getOrElse(false)) 1 else 0) + (if (centrifuge) 2 else 0))
gears.functions.count(_.isInstanceOf[Centrifuge]) shouldBe (if (centrifuge) 1 else 0) pipesJobs.count(_.isInstanceOf[Centrifuge]) shouldBe (if (centrifuge) 1 else 0)
gears.functions.count(_.isInstanceOf[CentrifugeKreport]) shouldBe (if (centrifuge) 2 else 0) pipesJobs.count(_.isInstanceOf[CentrifugeKreport]) shouldBe (if (centrifuge) 2 else 0)
} }
} }
} }
......
...@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.mapping ...@@ -17,6 +17,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 com.google.common.io.Files
import nl.lumc.sasc.biopet.core.BiopetPipe
import nl.lumc.sasc.biopet.extensions.centrifuge.Centrifuge import nl.lumc.sasc.biopet.extensions.centrifuge.Centrifuge
import nl.lumc.sasc.biopet.extensions.kraken.Kraken import nl.lumc.sasc.biopet.extensions.kraken.Kraken
import nl.lumc.sasc.biopet.pipelines.flexiprep.Fastqc import nl.lumc.sasc.biopet.pipelines.flexiprep.Fastqc
...@@ -86,10 +87,12 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with ...@@ -86,10 +87,12 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with
mapping.libId = Some("1") mapping.libId = Some("1")
mapping.script() mapping.script()
val pipesJobs = mapping.functions.filter(_.isInstanceOf[BiopetPipe]).flatMap(_.asInstanceOf[BiopetPipe].pipesJobs)
//Flexiprep //Flexiprep
mapping.functions.count(_.isInstanceOf[Fastqc]) shouldBe (if (skipFlexiprep) 0 else if (paired) 4 else 2) mapping.functions.count(_.isInstanceOf[Fastqc]) shouldBe (if (skipFlexiprep) 0 else if (paired) 4 else 2)
mapping.functions.count(_.isInstanceOf[Centrifuge]) shouldBe (if (unmappedToGears) 1 else 0) pipesJobs.count(_.isInstanceOf[Centrifuge]) shouldBe (if (unmappedToGears) 1 else 0)
} }
val outputDir = Files.createTempDir() val outputDir = Files.createTempDir()
......
...@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.mapping ...@@ -17,6 +17,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 com.google.common.io.Files
import nl.lumc.sasc.biopet.core.BiopetPipe
import nl.lumc.sasc.biopet.extensions.centrifuge.Centrifuge import nl.lumc.sasc.biopet.extensions.centrifuge.Centrifuge
import nl.lumc.sasc.biopet.extensions.kraken.Kraken import nl.lumc.sasc.biopet.extensions.kraken.Kraken
import nl.lumc.sasc.biopet.extensions.picard.{MarkDuplicates, MergeSamFiles} import nl.lumc.sasc.biopet.extensions.picard.{MarkDuplicates, MergeSamFiles}
...@@ -88,6 +89,8 @@ trait MultisampleMappingTestTrait extends TestNGSuite with Matchers { ...@@ -88,6 +89,8 @@ trait MultisampleMappingTestTrait extends TestNGSuite with Matchers {
val numberFastqLibs = (if (sample1) 1 else 0) + (if (sample2) 2 else 0) + (if (sample3 && bamToFastq) 1 else 0) + (if (sample4 && bamToFastq) 1 else 0) val numberFastqLibs = (if (sample1) 1 else 0) + (if (sample2) 2 else 0) + (if (sample3 && bamToFastq) 1 else 0) + (if (sample4 && bamToFastq) 1 else 0)
val numberSamples = (if (sample1) 1 else 0) + (if (sample2) 1 else 0) val numberSamples = (if (sample1) 1 else 0) + (if (sample2) 1 else 0)
val pipesJobs = pipeline.functions.filter(_.isInstanceOf[BiopetPipe]).flatMap(_.asInstanceOf[BiopetPipe].pipesJobs)
import MultisampleMapping.MergeStrategy import MultisampleMapping.MergeStrategy
pipeline.functions.count(_.isInstanceOf[MarkDuplicates]) shouldBe (numberFastqLibs + pipeline.functions.count(_.isInstanceOf[MarkDuplicates]) shouldBe (numberFastqLibs +
(if (sample2 && (merge == MergeStrategy.MarkDuplicates || merge == MergeStrategy.PreProcessMarkDuplicates)) 1 else 0)) (if (sample2 && (merge == MergeStrategy.MarkDuplicates || merge == MergeStrategy.PreProcessMarkDuplicates)) 1 else 0))
...@@ -103,7 +106,7 @@ trait MultisampleMappingTestTrait extends TestNGSuite with Matchers { ...@@ -103,7 +106,7 @@ trait MultisampleMappingTestTrait extends TestNGSuite with Matchers {
} }
} }
pipeline.functions.count(_.isInstanceOf[Centrifuge]) shouldBe (if (unmappedToGears) (numberFastqLibs + numberSamples) else 0) pipesJobs.count(_.isInstanceOf[Centrifuge]) shouldBe (if (unmappedToGears) (numberFastqLibs + numberSamples) else 0)
pipeline.summarySettings.get("merge_strategy") shouldBe Some(merge.toString) pipeline.summarySettings.get("merge_strategy") shouldBe Some(merge.toString)
} }
......
Supports Markdown
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