diff --git a/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaTest.scala b/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaTest.scala index 767b655e4156a0f94f304391dde4fe66471b07eb..1d015a49c3b467cb129c6e059ef572c0162ecb3d 100644 --- a/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaTest.scala +++ b/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaTest.scala @@ -87,6 +87,12 @@ class ShivaTest extends TestNGSuite with Matchers { object ShivaTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): String = { + val file = new File(outputDir, "input" + File.separator + name) + Files.touch(file) + file.getAbsolutePath + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) @@ -130,8 +136,8 @@ object ShivaTest { val sample1 = Map( "samples" -> Map("sample1" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "1_1_R1.fq", - "R2" -> "1_1_R2.fq" + "R1" -> inputTouch("1_1_R1.fq"), + "R2" -> inputTouch("1_1_R2.fq") ) ) ))) @@ -139,12 +145,12 @@ object ShivaTest { val sample2 = Map( "samples" -> Map("sample3" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "3_1_R1.fq", - "R2" -> "3_1_R2.fq" + "R1" -> inputTouch("2_1_R1.fq"), + "R2" -> inputTouch("2_1_R2.fq") ), "lib2" -> Map( - "R1" -> "3_2_R1.fq", - "R2" -> "3_2_R2.fq" + "R1" -> inputTouch("2_2_R1.fq"), + "R2" -> inputTouch("2_2_R2.fq") ) ) ))) diff --git a/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcallingTest.scala b/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcallingTest.scala index 2c60207a82fae9da823eb02d7a860b5dd8be1834..8e8a1eddf9e5d6b5aab36c4c6fea7d35ea2da82e 100644 --- a/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcallingTest.scala +++ b/protected/biopet-gatk-pipelines/src/test/scala/nl/lumc/sasc/biopet/pipelines/gatk/ShivaVariantcallingTest.scala @@ -73,7 +73,7 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers { val map = Map("variantcallers" -> callers.toList) val pipeline = initPipeline(map) - pipeline.inputBams = (for (n <- 1 to bams) yield new File("bam_" + n + ".bam")).toList + pipeline.inputBams = (for (n <- 1 to bams) yield ShivaVariantcallingTest.inputTouch("bam_" + n + ".bam")).toList val illegalArgumentException = pipeline.inputBams.isEmpty || (!raw && !bcftools && @@ -107,6 +107,12 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers { object ShivaVariantcallingTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): File = { + val file = new File(outputDir, "input" + File.separator + name).getAbsoluteFile + Files.touch(file) + file + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) diff --git a/public/bam2wig/src/main/scala/nl/lumc/sasc/biopet/pipelines/bamtobigwig/Bam2Wig.scala b/public/bam2wig/src/main/scala/nl/lumc/sasc/biopet/pipelines/bamtobigwig/Bam2Wig.scala index 451350227e5620ae612212eb341e0acae49ad958..fb9e39611fd861f9158503581f17d4bd12e6cb30 100644 --- a/public/bam2wig/src/main/scala/nl/lumc/sasc/biopet/pipelines/bamtobigwig/Bam2Wig.scala +++ b/public/bam2wig/src/main/scala/nl/lumc/sasc/biopet/pipelines/bamtobigwig/Bam2Wig.scala @@ -35,6 +35,7 @@ class Bam2Wig(val root: Configurable) extends QScript with BiopetQScript { var bamFile: File = null def init(): Unit = { + inputFiles :+= new InputFile(bamFile) } def biopetScript(): Unit = { diff --git a/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala b/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala index defb8361c68974ccffdddcba26dbe7700d58fea2..f6a6dc090defdb238f76b68f21189faf38fd207c 100644 --- a/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala +++ b/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala @@ -71,7 +71,8 @@ class BamMetrics(val root: Configurable) extends QScript with SummaryQScript wit } /** executed before script */ - def init() { + def init(): Unit = { + inputFiles :+= new InputFile(inputBam) } /** Script to add jobs */ diff --git a/public/bammetrics/src/test/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetricsTest.scala b/public/bammetrics/src/test/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetricsTest.scala index 7e97b4a78e1176b1603a7ae5aec10057c4bd0175..33304cb198807f46d3801ddfc9b05eaa7d555fe4 100644 --- a/public/bammetrics/src/test/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetricsTest.scala +++ b/public/bammetrics/src/test/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetricsTest.scala @@ -69,7 +69,7 @@ class BamMetricsTest extends TestNGSuite with Matchers { Map("regions_of_interest" -> (1 to rois).map("roi_" + _ + ".bed").toList) val bammetrics: BamMetrics = initPipeline(map) - bammetrics.inputBam = new File("input.bam") + bammetrics.inputBam = BamMetricsTest.bam bammetrics.sampleId = Some("1") bammetrics.libId = Some("1") bammetrics.script() @@ -98,6 +98,10 @@ class BamMetricsTest extends TestNGSuite with Matchers { object BamMetricsTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + + val bam = new File(outputDir, "input" + File.separator + "bla.bam") + Files.touch(bam) private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) diff --git a/public/basty/src/main/scala/nl/lumc/sasc/biopet/pipelines/basty/BastyTrait.scala b/public/basty/src/main/scala/nl/lumc/sasc/biopet/pipelines/basty/BastyTrait.scala index 1990085cef63fc60c637e04bb17811a20b837f85..a2a1f832843072d5abc9d46fb0280ba3b2c19ea4 100644 --- a/public/basty/src/main/scala/nl/lumc/sasc/biopet/pipelines/basty/BastyTrait.scala +++ b/public/basty/src/main/scala/nl/lumc/sasc/biopet/pipelines/basty/BastyTrait.scala @@ -89,6 +89,8 @@ trait BastyTrait extends MultiSampleQScript { addAll(shiva.functions) addSummaryQScript(shiva) + inputFiles :::= shiva.inputFiles + addSamplesJobs() } diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala index f35c07a0a4497fa4a36e0b34a1b640cf8f03364c..fa714c9423707456f1f6d1cfa6f2617c44318218 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala @@ -48,6 +48,10 @@ trait BiopetQScript extends Configurable with GatkLogging { var outputFiles: Map[String, File] = Map() + type InputFile = BiopetQScript.InputFile + + var inputFiles: List[InputFile] = Nil + /** Get implemented from org.broadinstitute.gatk.queue.QScript */ var qSettings: QSettings @@ -86,7 +90,16 @@ trait BiopetQScript extends Configurable with GatkLogging { globalConfig.writeReport(qSettings.runName, new File(outputDir, ".log/" + qSettings.runName)) else Logging.addError("Parent of output dir: '" + outputDir.getParent + "' is not writeable, outputdir can not be created") - reportClass.foreach(add(_)) + inputFiles.foreach { i => + if (!i.file.exists()) Logging.addError(s"Input file does not exist: ${i.file}") + else if (!i.file.canRead()) Logging.addError(s"Input file can not be read: ${i.file}") + } + + this match { + case q: MultiSampleQScript if q.onlySamples.nonEmpty && !q.samples.forall(x => q.onlySamples.contains(x._1)) => + logger.info("Write report is skipped because sample flag is used") + case _ => reportClass.foreach(add(_)) + } Logging.checkErrors() } @@ -103,3 +116,7 @@ trait BiopetQScript extends Configurable with GatkLogging { add(function) } } + +object BiopetQScript { + protected case class InputFile(file: File, md5: Option[String] = None) +} \ No newline at end of file diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala index d8756c7b91cd27b330b4697aab0d94c9f436c98a..17631709f12db8a3e3b25253afc49fadd3820e32 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala @@ -26,7 +26,7 @@ trait MultiSampleQScript extends SummaryQScript { qscript => @Argument(doc = "Only Sample", shortName = "s", required = false, fullName = "sample") - private val onlySamples: List[String] = Nil + private[core] val onlySamples: List[String] = Nil require(globalConfig.map.contains("samples"), "No Samples found in config") @@ -131,7 +131,7 @@ trait MultiSampleQScript extends SummaryQScript { /** Runs addAndTrackJobs method for each sample */ final def addSamplesJobs() { - if (onlySamples.isEmpty) { + if (onlySamples.isEmpty || samples.forall(x => onlySamples.contains(x._1))) { samples.foreach { case (sampleId, sample) => sample.addAndTrackJobs() } addMultiSampleJobs() } else onlySamples.foreach(sampleId => samples.get(sampleId) match { diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/extensions/CheckChecksum.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/extensions/CheckChecksum.scala new file mode 100644 index 0000000000000000000000000000000000000000..0ae2587f7928bb8d8cfe3e157f79fec7afff031a --- /dev/null +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/extensions/CheckChecksum.scala @@ -0,0 +1,40 @@ +package nl.lumc.sasc.biopet.core.extensions + +import java.io.File + +import nl.lumc.sasc.biopet.core.summary.WriteSummary +import org.broadinstitute.gatk.queue.function.InProcessFunction +import org.broadinstitute.gatk.utils.commandline.{ Argument, Input } + +/** + * This class checks md5sums and give an exit code 1 when md5sum is not the same + * + * Created by pjvanthof on 16/08/15. + */ +class CheckChecksum extends InProcessFunction { + @Input(required = true) + var inputFile: File = _ + + @Input(required = true) + var checksumFile: File = _ + + @Argument(required = true) + var checksum: String = _ + + override def freezeFieldValues(): Unit = { + super.freezeFieldValues() + jobOutputFile = new File(checksumFile.getParentFile, checksumFile.getName + ".check.out") + } + + /** Exits whenever the input md5sum is not the same as the output md5sum */ + def run: Unit = { + val outputChecksum = WriteSummary.parseChecksum(checksumFile).toLowerCase + + if (outputChecksum != checksum.toLowerCase) { + logger.error(s"Input file: '$inputFile' md5sum is not as expected, aborting pipeline") + + // 130 Simulates a ctr-C + Runtime.getRuntime.halt(130) + } + } +} \ No newline at end of file diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala index 6c1bc388153f37d746cbf8a173a5ecc85c7201d5..344a6139c88340fe96b6ef92bc49f9d5637615f1 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala @@ -231,6 +231,7 @@ object ReportBuilder { case Some(template) => template case _ => val tempFile = File.createTempFile("ssp-template", new File(location).getName) + tempFile.deleteOnExit() IoUtils.copyStreamToFile(getClass.getResourceAsStream(location), tempFile) templateCache += location -> tempFile tempFile diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala index 52c77fe8a63a090f2c4bb776da39647f9a35379e..6eaae5391f4712b427cc0307d7a480d1aee1e712 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala @@ -18,7 +18,7 @@ package nl.lumc.sasc.biopet.core.summary import java.io.File import nl.lumc.sasc.biopet.core._ -import nl.lumc.sasc.biopet.core.extensions.Md5sum +import nl.lumc.sasc.biopet.core.extensions.{ CheckChecksum, Md5sum } import scala.collection.mutable @@ -27,7 +27,7 @@ import scala.collection.mutable * * Created by pjvan_thof on 2/14/15. */ -trait SummaryQScript extends BiopetQScript { +trait SummaryQScript extends BiopetQScript { qscript => /** Key is sample/library, None is sample or library is not applicable */ private[summary] var summarizables: Map[(String, Option[String], Option[String]), List[Summarizable]] = Map() @@ -116,6 +116,20 @@ trait SummaryQScript extends BiopetQScript { //TODO: add more checksums types } + for (inputFile <- inputFiles) { + inputFile.md5 match { + case Some(checksum) => { + val checkMd5 = new CheckChecksum + checkMd5.inputFile = inputFile.file + require(SummaryQScript.md5sumCache.contains(inputFile.file), "Md5 job is not executed, checksum file can't be found") + checkMd5.checksumFile = SummaryQScript.md5sumCache(inputFile.file) + checkMd5.checksum = checksum + add(checkMd5) + } + case _ => + } + } + for ((_, summarizableList) <- summarizables; summarizable <- summarizableList) { summarizable match { case f: BiopetCommandLineFunctionTrait => f.beforeGraph() @@ -135,7 +149,11 @@ trait SummaryQScript extends BiopetQScript { for ((_, file) <- this.summaryFiles) addChecksum(file) - add(writeSummary) + this match { + case q: MultiSampleQScript if q.onlySamples.nonEmpty && !q.samples.forall(x => q.onlySamples.contains(x._1)) => + logger.info("Write summary is skipped because sample flag is used") + case _ => add(writeSummary) + } } } diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala index 3db4607d6288f84b204033ee3db186ee76771935..3530e4d0ad05f1916ccf344e625bbe5b097c0f65 100644 --- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala +++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/WriteSummary.scala @@ -153,10 +153,11 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config def parseFile(file: File): Map[String, Any] = { val map: mutable.Map[String, Any] = mutable.Map() map += "path" -> file.getAbsolutePath - if (md5sum) map += "md5" -> parseChecksum(SummaryQScript.md5sumCache(file)) + if (md5sum) map += "md5" -> WriteSummary.parseChecksum(SummaryQScript.md5sumCache(file)) map.toMap } - +} +object WriteSummary { /** Retrive checksum from file */ def parseChecksum(checksumFile: File): String = { Source.fromFile(checksumFile).getLines().toList.head.split(" ")(0) diff --git a/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/MpileupToVcf.scala b/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/MpileupToVcf.scala index 5a3e1e3f26588c103a4bf5e0a190aa223d064450..e5ba10717a5e32b3baf4dbe059d64dccfdcdcc61 100644 --- a/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/MpileupToVcf.scala +++ b/public/biopet-tools-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/tools/MpileupToVcf.scala @@ -57,7 +57,7 @@ class MpileupToVcf(val root: Configurable) extends ToolCommandFuntion with Refer } override def beforeCmd(): Unit = { - if (sample == null && inputBam.exists()) { + if (sample == null && inputBam.exists() && inputBam.length() > 0) { val inputSam = SamReaderFactory.makeDefault.open(inputBam) val readGroups = inputSam.getFileHeader.getReadGroups val samples = readGroups.map(readGroup => readGroup.getSample).distinct diff --git a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala index 960c4921debd6e58f45fa00bbb9dc0864dd11c60..62b04375f630ab59fea18d9c1d974bdf038cb767 100644 --- a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala +++ b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfStats.scala @@ -625,6 +625,7 @@ object VcfStats extends ToolCommand { def executeRscript(resource: String, args: Array[String]): Unit = { val is = getClass.getResourceAsStream(resource) val file = File.createTempFile("script.", "." + resource) + file.deleteOnExit() val os = new FileOutputStream(file) org.apache.commons.io.IOUtils.copy(is, os) os.close() diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala index ebe393bfab7bdb8fedec024319e99a5b0ec29a07..d9d8c1bee6bf96bcc98a372585b5a89454775e08 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala @@ -31,6 +31,7 @@ class BastyGenerateFastaTest extends TestNGSuite with MockitoSugar with Matchers @Test def testMainVcf = { val tmp = File.createTempFile("basty_out", ".fa") + tmp.deleteOnExit() val tmppath = tmp.getAbsolutePath tmp.deleteOnExit() @@ -40,6 +41,7 @@ class BastyGenerateFastaTest extends TestNGSuite with MockitoSugar with Matchers @Test def testMainVcfAndBam = { val tmp = File.createTempFile("basty_out", ".fa") + tmp.deleteOnExit() val tmppath = tmp.getAbsolutePath tmp.deleteOnExit() @@ -49,6 +51,7 @@ class BastyGenerateFastaTest extends TestNGSuite with MockitoSugar with Matchers @Test def testMainVcfAndBamMore = { val tmp = File.createTempFile("basty_out", ".fa") + tmp.deleteOnExit() val tmppath = tmp.getAbsolutePath tmp.deleteOnExit() diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala index 758cb6be6d6aa0a75c2ec1830e0fa3334beb7626..d919fe400154683f5fef7a061ce76c60aab5f5e7 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala @@ -56,6 +56,7 @@ class BiopetFlagstatTest extends TestNGSuite with MockitoSugar with Matchers { def testMain() = { //TODO: Test output file val output = File.createTempFile("testMain", ".biopetflagstat") + output.deleteOnExit() main(Array("-I", bam.getAbsolutePath, "-o", output.toString)) } diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FastqSplitterTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FastqSplitterTest.scala index ffa8be0bcb6c2cf15bf0ad00efeeb54e903eb3df..dd66b204fab38a4fd26fb011ffe6739faf304009 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FastqSplitterTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FastqSplitterTest.scala @@ -23,7 +23,7 @@ class FastqSplitterTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testMain() = { val temp = File.createTempFile("out", ".fastq") - + temp.deleteOnExit() val args = Array("-I", fq, "-o", temp.getAbsolutePath) main(args) } @@ -31,6 +31,7 @@ class FastqSplitterTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testManyOutMain() = { val files = (0 until 10).map(_ => File.createTempFile("out", ".fastq")) + files.foreach(_.deleteOnExit()) var args = Array("-I", fq) files.foreach(x => args ++= Array("-o", x.getAbsolutePath)) main(args) diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala index b6de2f8bcca896e8979c2e21fc5bb8651524610a..907270b8c31f3eb152766f03a612101f754ba6c9 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala @@ -29,6 +29,7 @@ class FindRepeatsPacBioTest extends TestNGSuite with MockitoSugar with Matchers def testMain() = { val outputFile = File.createTempFile("repeats", ".tsv") + outputFile.deleteOnExit() val args = Array("-I", bam, "-b", bed, "-o", outputFile.toString) main(args) } diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MpileupToVcfTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MpileupToVcfTest.scala index 032f9a913373c0f3be617e45cc26a928ca69821d..e708bc654b3c81699dcab85bfc07a7e21cd3ea94 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MpileupToVcfTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MpileupToVcfTest.scala @@ -28,6 +28,7 @@ class MpileupToVcfTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testMain() = { val tmp = File.createTempFile("mpileup", ".vcf") + tmp.deleteOnExit() val args = Array("-I", pileup, "--sample", "test", "-o", tmp.getAbsolutePath) main(args) @@ -36,6 +37,7 @@ class MpileupToVcfTest extends TestNGSuite with MockitoSugar with Matchers { @Test def validateOutVcf() = { val tmp = File.createTempFile("mpileup", ".vcf") + tmp.deleteOnExit() val args = Array("-I", pileup, "--sample", "test", "-o", tmp.getAbsolutePath, "--minDP", "1", "--minAP", "1") main(args) @@ -51,6 +53,7 @@ class MpileupToVcfTest extends TestNGSuite with MockitoSugar with Matchers { @Test def extraValidateOutVcf() = { val tmp = File.createTempFile("mpileup", ".vcf") + tmp.deleteOnExit() val args = Array("-I", pileup, "--sample", "test", "-o", tmp.getAbsolutePath, "--minDP", "1", "--minAP", "1") main(args) diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/PrefixFastqTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/PrefixFastqTest.scala index 41db9e3ae268a62860fd3fbe9a27e4430165429e..611557d836636aebc71f90e70707035033df6b97 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/PrefixFastqTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/PrefixFastqTest.scala @@ -26,6 +26,7 @@ class PrefixFastqTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testMain() = { val temp = File.createTempFile("out", ".fastq") + temp.deleteOnExit() val args = Array("-i", fq, "-o", temp.getAbsolutePath, "-s", "AAA") main(args) @@ -34,6 +35,7 @@ class PrefixFastqTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testOutput() = { val temp = File.createTempFile("out", ".fastq") + temp.deleteOnExit() val args = Array("-i", fq, "-o", temp.getAbsolutePath, "-s", "AAA") main(args) diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCountFastqTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCountFastqTest.scala index 15d3074c95313c6f2a084c41b4d0a4787bdedddb..5c7731c6dd2ec60b7c8cd01f84c6929026d7e007 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCountFastqTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCountFastqTest.scala @@ -22,6 +22,7 @@ class SageCountFastqTest extends TestNGSuite with MockitoSugar with Matchers { @Test def testMain() = { val temp = File.createTempFile("out", ".fastq") + temp.deleteOnExit() val args = Array("-I", fq, "-o", temp.getAbsolutePath) main(args) diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateLibaryTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateLibaryTest.scala index 48038ea6f476fd89a945f53cf3d3608661fbcc9c..c86c1ba5a9787c0cdcce00293309500d6f6e4b86 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateLibaryTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateLibaryTest.scala @@ -29,9 +29,13 @@ class SageCreateLibaryTest extends TestNGSuite with MockitoSugar with Matchers { val input = resourcePath("/mini.transcriptome.fa") val output = File.createTempFile("sageCreateLibrary", ".tsv") + output.deleteOnExit() val noTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv") + noTagsOutput.deleteOnExit() val antiTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv") + antiTagsOutput.deleteOnExit() val allGenesOutput = File.createTempFile("sageCreateLibrary", ".tsv") + allGenesOutput.deleteOnExit() val args = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG", "--length", "17", "--noTagsOutput", noTagsOutput.getAbsolutePath, "--noAntiTagsOutput", @@ -52,9 +56,13 @@ class SageCreateLibaryTest extends TestNGSuite with MockitoSugar with Matchers { def testOutPut = { val input = resourcePath("/mini.transcriptome.fa") val output = File.createTempFile("sageCreateLibrary", ".tsv") + output.deleteOnExit() val noTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv") + noTagsOutput.deleteOnExit() val antiTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv") + antiTagsOutput.deleteOnExit() val allGenesOutput = File.createTempFile("sageCreateLibrary", ".tsv") + allGenesOutput.deleteOnExit() val args = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG", "--length", "17", "--noTagsOutput", noTagsOutput.getAbsolutePath, "--noAntiTagsOutput", diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateTagCountsTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateTagCountsTest.scala index b47c507856ec251878057a3823d47d57160045e9..ecd1dae87d5c43a88e722cbb12f7eb18ece3a9b8 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateTagCountsTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SageCreateTagCountsTest.scala @@ -26,9 +26,13 @@ class SageCreateTagCountsTest extends TestNGSuite with MockitoSugar with Matcher val tagLib = resourcePath("/sageTest.tsv") val sense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + sense.deleteOnExit() val allSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + allSense.deleteOnExit() val antiSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + antiSense.deleteOnExit() val allAntiSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + allAntiSense.deleteOnExit() noException should be thrownBy main(Array("-I", input, "--tagLib", tagLib, "--countSense", sense.getAbsolutePath, "--countAllSense", allSense.getAbsolutePath, @@ -50,9 +54,13 @@ class SageCreateTagCountsTest extends TestNGSuite with MockitoSugar with Matcher val tagLib = resourcePath("/sageTest.tsv") val sense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + sense.deleteOnExit() val allSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + allSense.deleteOnExit() val antiSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + antiSense.deleteOnExit() val allAntiSense = File.createTempFile("SageCreateTagCountsTEst", ".tsv") + allAntiSense.deleteOnExit() main(Array("-I", input, "--tagLib", tagLib, "--countSense", sense.getAbsolutePath, "--countAllSense", allSense.getAbsolutePath, "--countAntiSense", antiSense.getAbsolutePath, diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala index 9866ad47a8efbfad5f34868b82fe415f6e6b8c28..e8a09a9d7cb9af569f2084c95a1b6c2e7f1e1aad 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJsonTest.scala @@ -21,6 +21,7 @@ class SamplesTsvToJsonTest extends TestNGSuite with MockitoSugar with Matchers { def testCorrectSampleTsv = { val tsv = resourcePath("/sample.tsv") val output = File.createTempFile("testCorrectSampleTsv", ".json") + output.deleteOnExit() noException should be thrownBy main(Array("-i", tsv, "-o", output.toString)) } @@ -29,6 +30,7 @@ class SamplesTsvToJsonTest extends TestNGSuite with MockitoSugar with Matchers { def testNoSampleColumn() = { val tsv = resourcePath("/no_sample.tsv") val output = File.createTempFile("testNoSampleColumn", ".json") + output.deleteOnExit() val thrown = the[IllegalStateException] thrownBy main(Array("-i", tsv, "-o", output.toString)) thrown.getMessage should equal("Sample column does not exist in: " + tsv) } @@ -37,6 +39,7 @@ class SamplesTsvToJsonTest extends TestNGSuite with MockitoSugar with Matchers { def testNumberInLibs = { val tsv = resourcePath("/number.tsv") val output = File.createTempFile("testNumberInLibs", ".json") + output.deleteOnExit() val thrown = the[IllegalStateException] thrownBy main(Array("-i", tsv, "-o", output.toString)) thrown.getMessage should equal("Sample or library may not start with a number") } @@ -45,6 +48,7 @@ class SamplesTsvToJsonTest extends TestNGSuite with MockitoSugar with Matchers { def testSampleIDs = { val tsv = resourcePath("/same.tsv") val output = File.createTempFile("testSampleIDs", ".json") + output.deleteOnExit() val thrown = the[IllegalStateException] thrownBy main(Array("-i", tsv, "-o", output.toString)) thrown.getMessage should equal("Combination of Sample_ID_1 and Lib_ID_1 is found multiple times") diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SummaryToTsvTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SummaryToTsvTest.scala index 6071fceaaed85a943a4f973ac713d24e8b708952..4f921affbc090031b83c0ee5fea3c64b9c9bdf4c 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SummaryToTsvTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SummaryToTsvTest.scala @@ -24,6 +24,7 @@ class SummaryToTsvTest extends TestNGSuite with MockitoSugar with Matchers { def testMain = { val tsv = resourcePath("/test.summary.json") val output = File.createTempFile("main", "tsv") + output.deleteOnExit() noException should be thrownBy main(Array("-s", tsv, "-p", "something=flexiprep:settings:skip_trim", "-m", "root", "-o", output.toString)) diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfWithVcfTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfWithVcfTest.scala index af8ff6267d5c73dad9eaa10762b1d356a2641626..a6a70881012480a8e92b9aac1c689e4456f9f8c7 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfWithVcfTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfWithVcfTest.scala @@ -47,50 +47,57 @@ class VcfWithVcfTest extends TestNGSuite with MockitoSugar with Matchers { val rand = new Random() @Test def testOutputTypeVcf() = { - val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath - val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ") + val tmpFile = File.createTempFile("VcfWithVcf_", ".vcf") + tmpFile.deleteOnExit() + val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ") main(arguments) } @Test def testOutputTypeVcfGz() = { - val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf.gz").getAbsolutePath - val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ") + val tmpFile = File.createTempFile("VcfWithVcf_", ".vcf.gz") + tmpFile.deleteOnExit() + val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ") main(arguments) } @Test def testOutputTypeBcf() = { - val tmpPath = File.createTempFile("VcfWithVcf_", ".bcf").getAbsolutePath - val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ") + val tmpFile = File.createTempFile("VcfWithVcf_", ".bcf") + tmpFile.deleteOnExit() + val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ") main(arguments) } @Test def testOutputFieldException = { - val tmpPath = File.createTempFile("VCFWithVCf", ".vcf").getAbsolutePath - val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:AC") + val tmpFile = File.createTempFile("VCFWithVCf", ".vcf") + tmpFile.deleteOnExit() + val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ:AC") an[IllegalArgumentException] should be thrownBy main(args) val thrown = the[IllegalArgumentException] thrownBy main(args) thrown.getMessage should equal("Field 'AC' already exists in input vcf") } @Test def testInputFieldException = { - val tmpPath = File.createTempFile("VCFWithVCf", ".vcf").getAbsolutePath - val args = Array("-I", unveppedPath, "-s", unveppedPath, "-o", tmpPath, "-f", "CSQ:NEW_CSQ") + val tmpFile = File.createTempFile("VCFWithVCf", ".vcf") + tmpFile.deleteOnExit() + val args = Array("-I", unveppedPath, "-s", unveppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ:NEW_CSQ") an[IllegalArgumentException] should be thrownBy main(args) val thrown = the[IllegalArgumentException] thrownBy main(args) thrown.getMessage should equal("Field 'CSQ' does not exist in secondary vcf") } @Test def testMinMethodException = { - val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath - val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:CSQ:min") + val tmpFile = File.createTempFile("VcfWithVcf_", ".vcf") + tmpFile.deleteOnExit() + val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ:CSQ:min") an[IllegalArgumentException] should be thrownBy main(args) val thrown = the[IllegalArgumentException] thrownBy main(args) thrown.getMessage should equal("Type of field CSQ is not numeric") } @Test def testMaxMethodException = { - val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath - val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:CSQ:max") + val tmpFile = File.createTempFile("VcfWithVcf_", ".vcf") + tmpFile.deleteOnExit() + val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpFile.getAbsolutePath, "-f", "CSQ:CSQ:max") an[IllegalArgumentException] should be thrownBy main(args) val thrown = the[IllegalArgumentException] thrownBy main(args) thrown.getMessage should equal("Type of field CSQ is not numeric") diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VepNormalizerTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VepNormalizerTest.scala index 5a12e9b579296b58a2764fdaa0b5b916717e384f..53aeddfaf1d6ba87f9e89ac29b31edff8fc5e01b 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VepNormalizerTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VepNormalizerTest.scala @@ -47,38 +47,44 @@ class VepNormalizerTest extends TestNGSuite with MockitoSugar with Matchers { val rand = new Random() @Test def testGzOutputExplode(): Unit = { - val tmpPath = File.createTempFile("VepNormalizer_", ".vcf.gz").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpPath, "-m", "explode") + val tmpFile = File.createTempFile("VepNormalizer_", ".vcf.gz") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "explode") main(arguments) } @Test def testVcfOutputExplode(): Unit = { - val tmpPath = File.createTempFile("VepNormalizer_", ".vcf").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpPath, "-m", "explode") + val tmpFile = File.createTempFile("VepNormalizer_", ".vcf") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "explode") main(arguments) } @Test def testBcfOutputExplode(): Unit = { - val tmp_path = File.createTempFile("VepNormalizer_", ".bcf").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmp_path, "-m", "explode") + val tmpFile = File.createTempFile("VepNormalizer_", ".bcf") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "explode") main(arguments) } @Test def testGzOutputStandard(): Unit = { - val tmp_path = File.createTempFile("VepNormalizer_", ".vcf.gz").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmp_path, "-m", "standard") + val tmpFile = File.createTempFile("VepNormalizer_", ".vcf.gz") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "standard") main(arguments) } @Test def testVcfOutputStandard(): Unit = { - val tmp_path = File.createTempFile("VepNormalizer_", ".vcf").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmp_path, "-m", "standard") + val tmpFile = File.createTempFile("VepNormalizer_", ".vcf") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "standard") main(arguments) } @Test def testBcfOutputStandard(): Unit = { - val tmp_path = File.createTempFile("VepNormalizer_", ".bcf").getAbsolutePath - val arguments: Array[String] = Array("-I", vepped_path, "-O", tmp_path, "-m", "standard") + val tmpFile = File.createTempFile("VepNormalizer_", ".bcf") + tmpFile.deleteOnExit() + val arguments: Array[String] = Array("-I", vepped_path, "-O", tmpFile.getAbsolutePath, "-m", "standard") main(arguments) } diff --git a/public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/Rscript.scala b/public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/Rscript.scala index 685108d0cb7f31cebfcc4b998017ae0a4c91726f..3dfac894eeb591a84a31b3fd5bcfa88c34619192 100644 --- a/public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/Rscript.scala +++ b/public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/rscript/Rscript.scala @@ -28,7 +28,11 @@ trait Rscript extends Configurable { } else { val rScript: File = dir match { case Some(dir) => new File(dir, script.getName) - case _ => File.createTempFile(script.getName, ".R") + case _ => { + val file = File.createTempFile(script.getName, ".R") + file.deleteOnExit() + file + } } if (!rScript.getParentFile.exists) rScript.getParentFile.mkdirs diff --git a/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala b/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala index ad8ff00ee2e8a09026168efbf99f5926b4583c50..6bac74cdf9f3bf6148a78b05271593242d9b2d07 100644 --- a/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala +++ b/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala @@ -228,6 +228,7 @@ class ConfigUtilsTest extends TestNGSuite with Matchers { object ConfigUtilsTest { def writeTemp(text: String, extension: String): File = { val file = File.createTempFile("TestConfigUtils.", extension) + file.deleteOnExit() val w = new PrintWriter(file) w.write(text) w.close() diff --git a/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordListTest.scala b/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordListTest.scala index b748006c2800d5e86aad9e5f918a3d4bf5894c2c..0490b28db7dbf199a9b01c1b48c6783f11720f7d 100644 --- a/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordListTest.scala +++ b/public/biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordListTest.scala @@ -39,6 +39,7 @@ class BedRecordListTest extends TestNGSuite with Matchers { records.header shouldBe Nil val tempFile = File.createTempFile("region", ".bed") + tempFile.deleteOnExit() records.writeToFile(tempFile) BedRecordList.fromFile(tempFile) shouldBe records tempFile.delete() @@ -50,6 +51,7 @@ class BedRecordListTest extends TestNGSuite with Matchers { records.header shouldBe BedRecordListTest.ucscHeader.split("\n").toList val tempFile = File.createTempFile("region", ".bed") + tempFile.deleteOnExit() records.writeToFile(tempFile) BedRecordList.fromFile(tempFile) shouldBe records tempFile.delete() @@ -129,13 +131,6 @@ class BedRecordListTest extends TestNGSuite with Matchers { list.scatter(100).allRecords.size shouldBe 15 list.scatter(100).length shouldBe 1500 } - - @AfterClass - def end: Unit = { - BedRecordListTest.bedFile.delete() - BedRecordListTest.corruptBedFile.delete() - BedRecordListTest.bedFileUcscHeader.delete() - } } object BedRecordListTest { @@ -149,6 +144,9 @@ object BedRecordListTest { |chr22 2000 6000 cloneB 900 - 2000 6000 0 2 433,399 0,3601""".stripMargin val bedFile = File.createTempFile("regions", ".bed") + bedFile.deleteOnExit() val corruptBedFile = File.createTempFile("regions", ".bed") + corruptBedFile.deleteOnExit() val bedFileUcscHeader = File.createTempFile("regions", ".bed") + bedFileUcscHeader.deleteOnExit() } \ No newline at end of file diff --git a/public/carp/src/main/scala/nl/lumc/sasc/biopet/pipelines/carp/Carp.scala b/public/carp/src/main/scala/nl/lumc/sasc/biopet/pipelines/carp/Carp.scala index 195718d5de9f0b708c2bcbc64faaf927109c176f..f8b4dc6db0ff771d046ffe320a24a7c0d294b832 100644 --- a/public/carp/src/main/scala/nl/lumc/sasc/biopet/pipelines/carp/Carp.scala +++ b/public/carp/src/main/scala/nl/lumc/sasc/biopet/pipelines/carp/Carp.scala @@ -78,6 +78,10 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with if (config.contains("R1")) { mapping.input_R1 = config("R1") if (config.contains("R2")) mapping.input_R2 = config("R2") + + inputFiles :+= new InputFile(mapping.input_R1, config("R1_md5")) + mapping.input_R2.foreach(inputFiles :+= new InputFile(_, config("R2_md5"))) + mapping.init() mapping.biopetScript() addAll(mapping.functions) diff --git a/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala index c361908fa1110ef7133639e91912acab5cce0da9..407b6fb415a4dbce63a80228241b7a81df29cf36 100644 --- a/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala +++ b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala @@ -97,6 +97,12 @@ class CarpTest extends TestNGSuite with Matchers { object CarpTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): String = { + val file = new File(outputDir, "input" + File.separator + name) + Files.touch(file) + file.getAbsolutePath + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) @@ -127,8 +133,8 @@ object CarpTest { val sample1 = Map( "samples" -> Map("sample1" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "1_1_R1.fq", - "R2" -> "1_1_R2.fq" + "R1" -> inputTouch("1_1_R1.fq"), + "R2" -> inputTouch("1_1_R2.fq") ) ) ))) @@ -136,8 +142,8 @@ object CarpTest { val sample2 = Map( "samples" -> Map("sample2" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "2_1_R1.fq", - "R2" -> "2_1_R2.fq" + "R1" -> inputTouch("2_1_R1.fq"), + "R2" -> inputTouch("2_1_R2.fq") ) ) ))) @@ -145,12 +151,12 @@ object CarpTest { val sample3 = Map( "samples" -> Map("sample3" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "3_1_R1.fq", - "R2" -> "3_1_R2.fq" + "R1" -> inputTouch("3_1_R1.fq"), + "R2" -> inputTouch("3_1_R2.fq") ), "lib2" -> Map( - "R1" -> "3_2_R1.fq", - "R2" -> "3_2_R2.fq" + "R1" -> inputTouch("3_2_R1.fq"), + "R2" -> inputTouch("3_2_R2.fq") ) ) ))) @@ -158,8 +164,8 @@ object CarpTest { val threatment1 = Map( "samples" -> Map("threatment" -> Map("control" -> "control1", "libraries" -> Map( "lib1" -> Map( - "R1" -> "threatment_1_R1.fq", - "R2" -> "threatment_1_R2.fq" + "R1" -> inputTouch("threatment_1_R1.fq"), + "R2" -> inputTouch("threatment_1_R2.fq") ) ) ))) @@ -167,8 +173,8 @@ object CarpTest { val control1 = Map( "samples" -> Map("control1" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "control_1_R1.fq", - "R2" -> "control_1_R2.fq" + "R1" -> inputTouch("control_1_R1.fq"), + "R2" -> inputTouch("control_1_R2.fq") ) ) ))) diff --git a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala index 07c356b7a894d5797002751d264a4b24e3ba5e7e..7ae2730c2bd92c3c06e10ecb2452cc3d1e823933 100644 --- a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala +++ b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala @@ -85,6 +85,9 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with paired = input_R2.isDefined + inputFiles :+= new InputFile(input_R1) + input_R2.foreach(inputFiles :+= new InputFile(_)) + if (input_R1.endsWith(".gz")) R1_name = input_R1.getName.substring(0, input_R1.getName.lastIndexOf(".gz")) else if (input_R1.endsWith(".gzip")) R1_name = input_R1.getName.substring(0, input_R1.getName.lastIndexOf(".gzip")) else R1_name = input_R1.getName diff --git a/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala b/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala index 2cb3f0e7b36175d9bf7633d7d639e6b03612976f..7b6716024963be03f256eb31bfad2bf5bcdf769e 100644 --- a/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala +++ b/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala @@ -67,8 +67,8 @@ class FlexiprepTest extends TestNGSuite with Matchers { ), Map(FlexiprepTest.executables.toSeq: _*)) val flexiprep: Flexiprep = initPipeline(map) - flexiprep.input_R1 = new File(flexiprep.outputDir, "bla_R1.fq" + (if (zipped) ".gz" else "")) - if (paired) flexiprep.input_R2 = Some(new File(flexiprep.outputDir, "bla_R2.fq" + (if (zipped) ".gz" else ""))) + flexiprep.input_R1 = (if (zipped) FlexiprepTest.r1Zipped else FlexiprepTest.r1) + if (paired) flexiprep.input_R2 = Some((if (zipped) FlexiprepTest.r2Zipped else FlexiprepTest.r2)) flexiprep.sampleId = Some("1") flexiprep.libId = Some("1") flexiprep.script() @@ -95,6 +95,16 @@ class FlexiprepTest extends TestNGSuite with Matchers { object FlexiprepTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + + val r1 = new File(outputDir, "input" + File.separator + "R1.fq") + Files.touch(r1) + val r2 = new File(outputDir, "input" + File.separator + "R2.fq") + Files.touch(r2) + val r1Zipped = new File(outputDir, "input" + File.separator + "R1.fq.gz") + Files.touch(r1Zipped) + val r2Zipped = new File(outputDir, "input" + File.separator + "R2.fq.gz") + Files.touch(r2Zipped) val executables = Map( "seqstat" -> Map("exe" -> "test"), diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala index c500757088d3c313190cb4a9b0eca65bfc48f9a4..d033594c6e42663427108baf12038b7eed6fb3f6 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala @@ -844,6 +844,8 @@ class Gentrap(val root: Configurable) extends QScript def addJobs(): Unit = { // create per-library alignment file addAll(mappingJob.functions) + // Input file checking + inputFiles :::= mappingJob.inputFiles // add bigwig track addAll(bam2wigModule.functions) qscript.addSummaryQScript(mappingJob) diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/extensions/CustomVarScan.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/extensions/CustomVarScan.scala index 1ce8465cae9c75dbcbed9c85374074202ff9b393..8871f481f3075d7eef52784583ccb5aadaa5b715 100644 --- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/extensions/CustomVarScan.scala +++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/extensions/CustomVarScan.scala @@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.gentrap.extensions import java.io.File -import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction +import nl.lumc.sasc.biopet.core.{ Reference, BiopetCommandLineFunction } import nl.lumc.sasc.biopet.core.extensions.PythonCommandLineFunction import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsMpileup @@ -28,16 +28,13 @@ import org.broadinstitute.gatk.utils.commandline.{ Input, Output } /** Ad-hoc extension for VarScan variant calling that involves 6-command pipe */ // FIXME: generalize piping instead of building something by hand like this! // Better to do everything quick and dirty here rather than something half-implemented with the objects -class CustomVarScan(val root: Configurable) extends BiopetCommandLineFunction { wrapper => +class CustomVarScan(val root: Configurable) extends BiopetCommandLineFunction with Reference { wrapper => override def configName = "customvarscan" @Input(doc = "Input BAM file", required = true) var input: File = null - @Input(doc = "Reference FASTA file", required = true) - var reference: File = config("reference") - @Output(doc = "Output VCF file", required = true) var output: File = null @@ -49,7 +46,6 @@ class CustomVarScan(val root: Configurable) extends BiopetCommandLineFunction { this.input = List(wrapper.input) override def configName = wrapper.configName disableBaq = true - reference = config("reference") depth = Option(1000000) outputMappingQuality = true } @@ -92,7 +88,9 @@ class CustomVarScan(val root: Configurable) extends BiopetCommandLineFunction { } override def beforeGraph(): Unit = { + super.beforeGraph() require(output.toString.endsWith(".gz"), "Output must have a .gz file extension") + deps :+= referenceFasta() } def cmdLine: String = { diff --git a/public/gentrap/src/test/scala/nl/lumc/sasc/biopet/pipelines/gentrap/GentrapTest.scala b/public/gentrap/src/test/scala/nl/lumc/sasc/biopet/pipelines/gentrap/GentrapTest.scala index 140db66fd62dd850365b27137cc3df0891bd38a7..2b2ddaf259e8fa5ad382ef1aca1337826ecf0ad8 100644 --- a/public/gentrap/src/test/scala/nl/lumc/sasc/biopet/pipelines/gentrap/GentrapTest.scala +++ b/public/gentrap/src/test/scala/nl/lumc/sasc/biopet/pipelines/gentrap/GentrapTest.scala @@ -43,8 +43,8 @@ class GentrapTest extends TestNGSuite with Matchers { /** Convenience method for making library config */ private def makeLibConfig(idx: Int, paired: Boolean = true) = { - val files = Map("R1" -> "test_R1.fq") - if (paired) (s"lib_$idx", files ++ Map("R2" -> "test_R2.fq")) + val files = Map("R1" -> GentrapTest.inputTouch("test_R1.fq")) + if (paired) (s"lib_$idx", files ++ Map("R2" -> GentrapTest.inputTouch("test_R2.fq"))) else (s"lib_$idx", files) } @@ -179,6 +179,12 @@ class GentrapTest extends TestNGSuite with Matchers { object GentrapTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): String = { + val file = new File(outputDir, "input" + File.separator + name) + Files.touch(file) + file.getAbsolutePath + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) diff --git a/public/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala b/public/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala index 9d508b12ce727acb0bdfdf52fc485b8e353e5dae..3c886ee3a7c04544953e02a29d960a9436559bcb 100644 --- a/public/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala +++ b/public/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala @@ -137,6 +137,9 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S require(sampleId.isDefined, "Missing sample ID on mapping module") require(libId.isDefined, "Missing library ID on mapping module") + inputFiles :+= new InputFile(input_R1) + input_R2.foreach(inputFiles :+= new InputFile(_)) + paired = input_R2.isDefined if (readgroupId == null) readgroupId = sampleId.get + "-" + libId.get diff --git a/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala b/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala index 849bffcb6998f31e8d527af465de68775b6e11a4..3c28181101a75eafa1518e441fb457a5ae197099 100644 --- a/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala +++ b/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala @@ -79,11 +79,11 @@ class MappingTest extends TestNGSuite with Matchers { val mapping: Mapping = initPipeline(map) if (zipped) { - mapping.input_R1 = new File(mapping.outputDir, "bla_R1.fq.gz") - if (paired) mapping.input_R2 = Some(new File(mapping.outputDir, "bla_R2.fq.gz")) + mapping.input_R1 = MappingTest.r1Zipped + if (paired) mapping.input_R2 = Some(MappingTest.r2Zipped) } else { - mapping.input_R1 = new File(mapping.outputDir, "bla_R1.fq") - if (paired) mapping.input_R2 = Some(new File(mapping.outputDir, "bla_R2.fq")) + mapping.input_R1 = MappingTest.r1 + if (paired) mapping.input_R2 = Some(MappingTest.r2) } mapping.sampleId = Some("1") mapping.libId = Some("1") @@ -131,6 +131,16 @@ class MappingTest extends TestNGSuite with Matchers { object MappingTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + + val r1 = new File(outputDir, "input" + File.separator + "R1.fq") + Files.touch(r1) + val r2 = new File(outputDir, "input" + File.separator + "R2.fq") + Files.touch(r2) + val r1Zipped = new File(outputDir, "input" + File.separator + "R1.fq.gz") + Files.touch(r1Zipped) + val r2Zipped = new File(outputDir, "input" + File.separator + "R2.fq.gz") + Files.touch(r2Zipped) private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) diff --git a/public/sage/src/main/scala/nl/lumc/sasc/biopet/pipelines/sage/Sage.scala b/public/sage/src/main/scala/nl/lumc/sasc/biopet/pipelines/sage/Sage.scala index 4aaee19c295de32dbc306a94cf6fecf63d1ba754..2ee8c3b1930aff553234f6f3860d7c13e0818783 100644 --- a/public/sage/src/main/scala/nl/lumc/sasc/biopet/pipelines/sage/Sage.scala +++ b/public/sage/src/main/scala/nl/lumc/sasc/biopet/pipelines/sage/Sage.scala @@ -88,6 +88,8 @@ class Sage(val root: Configurable) extends QScript with MultiSampleQScript { mapping.sampleId = Some(sampleId) protected def addJobs(): Unit = { + inputFiles :+= new InputFile(inputFastq, config("R1_md5")) + flexiprep.outputDir = new File(libDir, "flexiprep/") flexiprep.input_R1 = inputFastq flexiprep.init() diff --git a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala index 3f65bf2a20864e2017f512981daa0d37aca52772..dafb2e1ccc5a72807aa37cc6858711afbfe78c23 100644 --- a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala +++ b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTrait.scala @@ -136,51 +136,56 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript with Reference { case (true, _) => mapping.foreach(mapping => { mapping.input_R1 = config("R1") mapping.input_R2 = config("R2") + inputFiles :+= new InputFile(mapping.input_R1, config("R1_md5")) + mapping.input_R2.foreach(inputFiles :+= new InputFile(_, config("R2_md5"))) }) - case (false, true) => config("bam_to_fastq", default = false).asBoolean match { - case true => - val samToFastq = SamToFastq(qscript, config("bam"), - new File(libDir, sampleId + "-" + libId + ".R1.fastq"), - new File(libDir, sampleId + "-" + libId + ".R2.fastq")) - samToFastq.isIntermediate = true - qscript.add(samToFastq) - mapping.foreach(mapping => { - mapping.input_R1 = samToFastq.fastqR1 - mapping.input_R2 = Some(samToFastq.fastqR2) - }) - case false => - val inputSam = SamReaderFactory.makeDefault.open(config("bam")) - val readGroups = inputSam.getFileHeader.getReadGroups - - val readGroupOke = readGroups.forall(readGroup => { - if (readGroup.getSample != sampleId) logger.warn("Sample ID readgroup in bam file is not the same") - if (readGroup.getLibrary != libId) logger.warn("Library ID readgroup in bam file is not the same") - readGroup.getSample == sampleId && readGroup.getLibrary == libId - }) - inputSam.close() - - if (!readGroupOke) { - if (config("correct_readgroups", default = false).asBoolean) { - logger.info("Correcting readgroups, file:" + config("bam")) - val aorrg = AddOrReplaceReadGroups(qscript, config("bam"), bamFile.get) - aorrg.RGID = sampleId + "-" + libId - aorrg.RGLB = libId - aorrg.RGSM = sampleId - aorrg.isIntermediate = true - qscript.add(aorrg) - } else throw new IllegalStateException("Sample readgroup and/or library of input bamfile is not correct, file: " + bamFile + - "\nPlease note that it is possible to set 'correct_readgroups' to true in the config to automatic fix this") - } else { - val oldBamFile: File = config("bam") - val oldIndex: File = new File(oldBamFile.getAbsolutePath.stripSuffix(".bam") + ".bai") - val newIndex: File = new File(libDir, oldBamFile.getName.stripSuffix(".bam") + ".bai") - val baiLn = Ln(qscript, oldIndex, newIndex) - add(baiLn) - - val bamLn = Ln(qscript, oldBamFile, bamFile.get) - bamLn.deps :+= baiLn.output - add(bamLn) - } + case (false, true) => { + inputFiles :+= new InputFile(config("bam"), config("bam_md5")) + config("bam_to_fastq", default = false).asBoolean match { + case true => + val samToFastq = SamToFastq(qscript, config("bam"), + new File(libDir, sampleId + "-" + libId + ".R1.fastq"), + new File(libDir, sampleId + "-" + libId + ".R2.fastq")) + samToFastq.isIntermediate = true + qscript.add(samToFastq) + mapping.foreach(mapping => { + mapping.input_R1 = samToFastq.fastqR1 + mapping.input_R2 = Some(samToFastq.fastqR2) + }) + case false => + val inputSam = SamReaderFactory.makeDefault.open(config("bam")) + val readGroups = inputSam.getFileHeader.getReadGroups + + val readGroupOke = readGroups.forall(readGroup => { + if (readGroup.getSample != sampleId) logger.warn("Sample ID readgroup in bam file is not the same") + if (readGroup.getLibrary != libId) logger.warn("Library ID readgroup in bam file is not the same") + readGroup.getSample == sampleId && readGroup.getLibrary == libId + }) + inputSam.close() + + if (!readGroupOke) { + if (config("correct_readgroups", default = false).asBoolean) { + logger.info("Correcting readgroups, file:" + config("bam")) + val aorrg = AddOrReplaceReadGroups(qscript, config("bam"), bamFile.get) + aorrg.RGID = sampleId + "-" + libId + aorrg.RGLB = libId + aorrg.RGSM = sampleId + aorrg.isIntermediate = true + qscript.add(aorrg) + } else throw new IllegalStateException("Sample readgroup and/or library of input bamfile is not correct, file: " + bamFile + + "\nPlease note that it is possible to set 'correct_readgroups' to true in the config to automatic fix this") + } else { + val oldBamFile: File = config("bam") + val oldIndex: File = new File(oldBamFile.getAbsolutePath.stripSuffix(".bam") + ".bai") + val newIndex: File = new File(libDir, oldBamFile.getName.stripSuffix(".bam") + ".bai") + val baiLn = Ln(qscript, oldIndex, newIndex) + add(baiLn) + + val bamLn = Ln(qscript, oldBamFile, bamFile.get) + bamLn.deps :+= baiLn.output + add(bamLn) + } + } } case _ => logger.warn("Sample: " + sampleId + " Library: " + libId + ", no reads found") } @@ -294,7 +299,7 @@ trait ShivaTrait extends MultiSampleQScript with SummaryQScript with Reference { addAll(vc.functions) addSummaryQScript(vc) - if (config("annotation", default = true).asBoolean) { + if (config("annotation", default = false).asBoolean) { val toucan = new Toucan(this) toucan.outputDir = new File(outputDir, "annotation") toucan.inputVCF = vc.finalFile diff --git a/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala b/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala index 56b6bf172b2d122b2ccd70818d3f9f92161e270d..cff186c29e8776f4457ceb6787ea75efc61a8885 100644 --- a/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala +++ b/public/shiva/src/test/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaTest.scala @@ -88,6 +88,12 @@ class ShivaTest extends TestNGSuite with Matchers { object ShivaTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): String = { + val file = new File(outputDir, "input" + File.separator + name) + Files.touch(file) + file.getAbsolutePath + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) @@ -131,8 +137,8 @@ object ShivaTest { val sample1 = Map( "samples" -> Map("sample1" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "1_1_R1.fq", - "R2" -> "1_1_R2.fq" + "R1" -> inputTouch("1_1_R1.fq"), + "R2" -> inputTouch("1_1_R2.fq") ) ) ))) @@ -140,8 +146,8 @@ object ShivaTest { val sample2 = Map( "samples" -> Map("sample2" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "2_1_R1.fq", - "R2" -> "2_1_R2.fq" + "R1" -> inputTouch("2_1_R1.fq"), + "R2" -> inputTouch("2_1_R2.fq") ) ) ))) @@ -149,12 +155,12 @@ object ShivaTest { val sample3 = Map( "samples" -> Map("sample3" -> Map("libraries" -> Map( "lib1" -> Map( - "R1" -> "3_1_R1.fq", - "R2" -> "3_1_R2.fq" + "R1" -> inputTouch("3_1_R1.fq"), + "R2" -> inputTouch("3_1_R2.fq") ), "lib2" -> Map( - "R1" -> "3_2_R1.fq", - "R2" -> "3_2_R2.fq" + "R1" -> inputTouch("3_2_R1.fq"), + "R2" -> inputTouch("3_2_R2.fq") ) ) ))) 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 0281d33f678804d7edd1620d204a0830d4f3201f..caeea0326d46e4b7673dae4a3d07f27c3cbd5f4e 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 @@ -61,7 +61,7 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers { val map = Map("variantcallers" -> callers.toList) val pipeline = initPipeline(map) - pipeline.inputBams = (for (n <- 1 to bams) yield new File("bam_" + n + ".bam")).toList + pipeline.inputBams = (for (n <- 1 to bams) yield ShivaVariantcallingTest.inputTouch("bam_" + n + ".bam")).toList val illegalArgumentException = pipeline.inputBams.isEmpty || (!raw && !bcftools && !freebayes) @@ -88,6 +88,12 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers { object ShivaVariantcallingTest { val outputDir = Files.createTempDir() + new File(outputDir, "input").mkdirs() + def inputTouch(name: String): File = { + val file = new File(outputDir, "input" + File.separator + name).getAbsoluteFile + Files.touch(file) + file + } private def copyFile(name: String): Unit = { val is = getClass.getResourceAsStream("/" + name) diff --git a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/Toucan.scala b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/Toucan.scala index 606853f933f6cd1263a0f44193e5ae0e615812df..7c3cc327858be60bb3d299e550c0f4244b656560 100644 --- a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/Toucan.scala +++ b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/Toucan.scala @@ -35,6 +35,7 @@ class Toucan(val root: Configurable) extends QScript with BiopetQScript with Sum var inputVCF: File = _ def init(): Unit = { + inputFiles :+= new InputFile(inputVCF) } override def defaults = ConfigUtils.mergeMaps(Map(