diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala index c0046d0535ccb5c429b2fa8b5707868c74f71f41..a413c8bad83199c38a1b156a67118d2e7262b50c 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala @@ -83,13 +83,14 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** Set default output file, threads and vmem for current job */ final def internalBeforeGraph(): Unit = { - pipesJobs.foreach(_.beforeGraph()) - pipesJobs.foreach(_.internalBeforeGraph()) + _pipesJobs.foreach(_.beforeGraph()) + _pipesJobs.foreach(_.internalBeforeGraph()) } /** * Can override this value is executable may not be converted to CanonicalPath + * * @deprecated */ val executableToCanonicalPath = true @@ -121,6 +122,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** * This operator sends stdout to `that` and combine this into 1 command line function + * * @param that Function that will read from stdin * @return BiopetPipe function */ @@ -141,6 +143,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** * This operator can be used to give a program a file as stdin + * * @param file File that will become stdin for this program * @return It's own class */ @@ -152,6 +155,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** * This operator can be used to give a program a file write it's atdout + * * @param file File that will become stdout for this program * @return It's own class */ @@ -169,6 +173,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** * This function needs to be implemented to define the command that is executed + * * @return Command to run */ protected[core] def cmdLine: String @@ -176,6 +181,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => /** * implementing a final version of the commandLine from org.broadinstitute.gatk.queue.function.CommandLineFunction * User needs to implement cmdLine instead + * * @return Command to run */ override final def commandLine: String = { @@ -187,10 +193,11 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction => cmd } - private[core] var pipesJobs: List[BiopetCommandLineFunction] = Nil + private[core] var _pipesJobs: List[BiopetCommandLineFunction] = Nil + def pipesJobs = _pipesJobs def addPipeJob(job: BiopetCommandLineFunction) { - pipesJobs :+= job - pipesJobs = pipesJobs.distinct + _pipesJobs :+= job + _pipesJobs = _pipesJobs.distinct } } diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetFifoPipe.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetFifoPipe.scala index 8b4f1f801681f8ead4a58e2e02264acf8680c57d..287064130a8a055b7457a2e583517c8e60a1b5df 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetFifoPipe.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetFifoPipe.scala @@ -67,8 +67,8 @@ class BiopetFifoPipe(val root: Configurable, deps :::= inputs.values.toList.flatten.filter(!fifoFiles.contains(_)) deps = deps.distinct - pipesJobs :::= commands - pipesJobs = pipesJobs.distinct + _pipesJobs :::= commands + _pipesJobs = _pipesJobs.distinct } override def beforeCmd(): Unit = { diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetPipe.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetPipe.scala index f7be2d57f1c3cb6a724a9c89acb51592f8045432..af98f00969a0c0b0b77c59db903f7b3346ce3274 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetPipe.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetPipe.scala @@ -41,7 +41,7 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo case e: Exception => Nil } - pipesJobs :::= commands + _pipesJobs :::= commands override def beforeGraph() { super.beforeGraph() @@ -61,7 +61,7 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo } override def setResources(): Unit = { - combineResources(pipesJobs) + combineResources(_pipesJobs) } override def setupRetry(): Unit = { diff --git a/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTest.scala b/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTest.scala index 44c3d60cf762325cbbbe8207b9b7a977a0398791..b1699c7b97132b1df20c88d49c6202164fa89227 100644 --- a/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTest.scala +++ b/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTest.scala @@ -18,16 +18,17 @@ package nl.lumc.sasc.biopet.pipelines.shiva import java.io.{ File, FileOutputStream } import com.google.common.io.Files -import nl.lumc.sasc.biopet.utils.config.Config +import nl.lumc.sasc.biopet.core.BiopetPipe import nl.lumc.sasc.biopet.extensions.Freebayes +import nl.lumc.sasc.biopet.extensions.bcftools.{ BcftoolsCall, BcftoolsMerge } import nl.lumc.sasc.biopet.extensions.gatk.CombineVariants -import nl.lumc.sasc.biopet.extensions.tools.VcfFilter +import nl.lumc.sasc.biopet.extensions.tools.{ MpileupToVcf, VcfFilter } import nl.lumc.sasc.biopet.utils.ConfigUtils -import org.apache.commons.io.FileUtils +import nl.lumc.sasc.biopet.utils.config.Config import org.broadinstitute.gatk.queue.QSettings import org.scalatest.Matchers import org.scalatest.testng.TestNGSuite -import org.testng.annotations.{ AfterClass, DataProvider, Test } +import org.testng.annotations.{ DataProvider, Test } import scala.collection.mutable.ListBuffer @@ -88,11 +89,13 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers { pipeline.init() pipeline.script() + val pipesJobs = pipeline.functions.filter(_.isInstanceOf[BiopetPipe]).flatMap(_.asInstanceOf[BiopetPipe].pipesJobs) + pipeline.functions.count(_.isInstanceOf[CombineVariants]) shouldBe (1 + (if (raw) 1 else 0) + (if (varscanCnsSinglesample) 1 else 0)) - //pipeline.functions.count(_.isInstanceOf[Bcftools]) shouldBe (if (bcftools) 1 else 0) - //FIXME: Can not check for bcftools because of piping - pipeline.functions.count(_.isInstanceOf[Freebayes]) shouldBe (if (freebayes) 1 else 0) - //pipeline.functions.count(_.isInstanceOf[MpileupToVcf]) shouldBe (if (raw) bams else 0) + pipesJobs.count(_.isInstanceOf[BcftoolsCall]) shouldBe (if (bcftools) 1 else 0) + (if (bcftoolsSinglesample) bams else 0) + pipeline.functions.count(_.isInstanceOf[BcftoolsMerge]) shouldBe (if (bcftoolsSinglesample && bams > 1) 1 else 0) + pipesJobs.count(_.isInstanceOf[Freebayes]) shouldBe (if (freebayes) 1 else 0) + pipesJobs.count(_.isInstanceOf[MpileupToVcf]) shouldBe (if (raw) bams else 0) pipeline.functions.count(_.isInstanceOf[VcfFilter]) shouldBe (if (raw) bams else 0) } }