From 4dcbb9cd52e92bfb2c4bf366ab3cba5182a72588 Mon Sep 17 00:00:00 2001
From: Sander Bollen <a.h.b.bollen@lumc.nl>
Date: Thu, 22 Oct 2015 16:52:51 +0200
Subject: [PATCH] proper temp files

---
 .../biopet/tools/CheckAllelesVcfInBamTest.scala     | 12 +++++++++---
 .../lumc/sasc/biopet/tools/MergeAllelesTest.scala   | 13 ++++++++++---
 .../nl/lumc/sasc/biopet/tools/VcfFilterTest.scala   | 12 +++++++++---
 .../nl/lumc/sasc/biopet/tools/VcfToTsvTest.scala    | 13 ++++++++++---
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/CheckAllelesVcfInBamTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/CheckAllelesVcfInBamTest.scala
index 476e8e623..1ee6f38d3 100644
--- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/CheckAllelesVcfInBamTest.scala
+++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/CheckAllelesVcfInBamTest.scala
@@ -45,19 +45,25 @@ class CheckAllelesVcfInBamTest extends TestNGSuite with MockitoSugar with Matche
   val rand = new Random()
 
   @Test def testOutputTypeVcf() = {
-    val tmp_path = "/tmp/CheckAllesVcfInBam_" + rand.nextString(10) + ".vcf"
+    val tmp = File.createTempFile("CheckAllelesVcfInBam", ".vcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vcf, "-b", bam, "-s", "sample01", "-o", tmp_path)
     main(arguments)
   }
 
   @Test def testOutputTypeVcfGz() = {
-    val tmp_path = "/tmp/CheckAllesVcfInBam_" + rand.nextString(10) + ".vcf.gz"
+    val tmp = File.createTempFile("CheckAllelesVcfInBam", ".vcf.gz")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vcf, "-b", bam, "-s", "sample01", "-o", tmp_path)
     main(arguments)
   }
 
   @Test def testOutputTypeBcf() = {
-    val tmp_path = "/tmp/CheckAllesVcfInBam_" + rand.nextString(10) + ".bcf"
+    val tmp = File.createTempFile("CheckAllelesVcfInBam", ".bcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vcf, "-b", bam, "-s", "sample01", "-o", tmp_path)
     main(arguments)
   }
diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MergeAllelesTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MergeAllelesTest.scala
index e041679d0..b7ea9bb9c 100644
--- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MergeAllelesTest.scala
+++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/MergeAllelesTest.scala
@@ -15,6 +15,7 @@
  */
 package nl.lumc.sasc.biopet.tools
 
+import java.io.File
 import java.nio.file.Paths
 
 import org.scalatest.Matchers
@@ -48,19 +49,25 @@ class MergeAllelesTest extends TestNGSuite with MockitoSugar with Matchers {
   val rand = new Random()
 
   @Test def testOutputTypeVcf() = {
-    val tmp_path = "/tmp/MergeAlleles_" + rand.nextString(10) + ".vcf"
+    val tmp = File.createTempFile("MergeAlleles", ".vcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vepped_path, "-o", tmp_path, "-R", reference)
     main(arguments)
   }
 
   @Test def testOutputTypeVcfGz() = {
-    val tmp_path = "/tmp/MergeAlleles_" + rand.nextString(10) + ".vcf.gz"
+    val tmp = File.createTempFile("MergeAlleles", ".vcf.gz")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vepped_path, "-o", tmp_path, "-R", reference)
     main(arguments)
   }
 
   @Test def testOutputTypeBcf() = {
-    val tmp_path = "/tmp/MergeAlleles_" + rand.nextString(10) + ".bcf"
+    val tmp = File.createTempFile("MergeAlleles", ".bcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vepped_path, "-o", tmp_path, "-R", reference)
     main(arguments)
   }
diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
index 13d959122..7149ab194 100644
--- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
+++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
@@ -44,19 +44,25 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
   val rand = new Random()
 
   @Test def testOutputTypeVcf() = {
-    val tmp_path = "/tmp/VcfFilter_" + rand.nextString(10) + ".vcf"
+    val tmp = File.createTempFile("VcfFilter", ".vcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments: Array[String] = Array("-I", vepped_path, "-o", tmp_path)
     main(arguments)
   }
 
   @Test def testOutputTypeBcf() = {
-    val tmp_path = "/tmp/VcfFilter_" + rand.nextString(10) + ".bcf"
+    val tmp = File.createTempFile("VcfFilter", ".bcf")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments: Array[String] = Array("-I", vepped_path, "-o", tmp_path)
     main(arguments)
   }
 
   @Test def testOutputTypeVcfGz() = {
-    val tmp_path = "/tmp/VcfFilter_" + rand.nextString(10) + ".vcf.gz"
+    val tmp = File.createTempFile("VcfFilter", ".vcf.gz")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments: Array[String] = Array("-I", vepped_path, "-o", tmp_path)
     main(arguments)
   }
diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfToTsvTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfToTsvTest.scala
index 106562a27..ee327392c 100644
--- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfToTsvTest.scala
+++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfToTsvTest.scala
@@ -15,6 +15,7 @@
  */
 package nl.lumc.sasc.biopet.tools
 
+import java.io.File
 import java.nio.file.Paths
 
 import org.scalatest.Matchers
@@ -41,19 +42,25 @@ class VcfToTsvTest extends TestNGSuite with MockitoSugar with Matchers {
   val unvepped = resourcePath("/unvepped.vcf")
 
   @Test def testAllFields() = {
-    val tmp_path = "/tmp/VcfToTsv_" + rand.nextString(10) + ".tsv"
+    val tmp = File.createTempFile("VcfToTsv", ".tsv")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", unvepped, "-o", tmp_path, "--all_info")
     main(arguments)
   }
 
   @Test def testSpecificField() = {
-    val tmp_path = "/tmp/VcfToTsv_" + rand.nextString(10) + ".tsv"
+    val tmp = File.createTempFile("VcfToTsv", ".tsv")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vepped, "-o", tmp_path, "-i", "CSQ")
     main(arguments)
   }
 
   @Test def testNewSeparators() = {
-    val tmp_path = "/tmp/VcfToTsv_" + rand.nextString(10) + ".tsv"
+    val tmp = File.createTempFile("VcfToTsv", ".tsv")
+    tmp.deleteOnExit()
+    val tmp_path = tmp.getAbsolutePath
     val arguments = Array("-I", vepped, "-o", tmp_path, "--all_info", "--separator", ",", "--list_separator", "|")
     main(arguments)
   }
-- 
GitLab