Commit 31be1177 authored by Sander Bollen's avatar Sander Bollen Committed by GitHub

Merge pull request #5 from biopet/fix-BIOPET-519

Fix BIOPET-519
parents 24ac7790 3f119436
......@@ -18,9 +18,9 @@ import java.io.File
import nl.lumc.sasc.biopet.core.MultiSampleQScript.Gender
import nl.lumc.sasc.biopet.core.extensions.Md5sum
import nl.lumc.sasc.biopet.utils.{ConfigUtils, Logging}
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.{QScript, QSettings}
import org.broadinstitute.gatk.queue.{ QScript, QSettings }
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
......
package nl.lumc.sasc.biopet.core
import java.io.{File, PrintWriter}
import java.io.{ File, PrintWriter }
import com.google.common.io.Files
import org.scalatest.Matchers
......@@ -11,8 +11,8 @@ import nl.lumc.sasc.biopet.utils.IoUtils._
import org.apache.commons.io.FileUtils
/**
* Created by pjvan_thof on 10-1-17.
*/
* Created by pjvan_thof on 10-1-17.
*/
class PipelineStatusTest extends TestNGSuite with Matchers {
@Test
def testDefault(): Unit = {
......
......@@ -14,7 +14,7 @@
*/
package nl.lumc.sasc.biopet.tools.vcfstats
import java.io.{ File, FileOutputStream, PrintWriter }
import java.io.{ File, FileOutputStream, IOException, PrintWriter }
import htsjdk.samtools.util.Interval
import htsjdk.variant.variantcontext.{ Genotype, VariantContext }
......@@ -557,11 +557,17 @@ object VcfStats extends ToolCommand {
val command: String = "Rscript " + file + " " + args.mkString(" ")
logger.info("Starting: " + command)
val process = Process(command).run(ProcessLogger(x => logger.debug(x), x => logger.debug(x)))
if (process.exitValue() == 0) logger.info("Done: " + command)
else {
logger.warn("Failed: " + command)
if (!logger.isDebugEnabled) logger.warn("Use -l debug for more info")
try {
val process = Process(command).run(ProcessLogger(x => logger.debug(x), x => logger.debug(x)))
if (process.exitValue() == 0) logger.info("Done: " + command)
else {
logger.warn("Failed: " + command)
if (!logger.isDebugEnabled) logger.warn("Use -l debug for more info")
}
} catch {
case e: IOException =>
logger.warn("Failed: " + command)
logger.debug(e)
}
}
}
......@@ -103,7 +103,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testMergeStatsMap = {
def testMergeStatsMap() = {
val m1: mutable.Map[Any, Int] = mutable.Map("a" -> 1)
val m2: mutable.Map[Any, Int] = mutable.Map("b" -> 2)
......@@ -124,7 +124,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testMergeNestedStatsMap = {
def testMergeNestedStatsMap() = {
val m1: mutable.Map[String, mutable.Map[String, mutable.Map[Any, Int]]] = mutable.Map("test" ->
mutable.Map("nested" -> mutable.Map("a" -> 1)))
val m2: Map[String, Map[String, Map[Any, Int]]] = Map("test" ->
......@@ -152,7 +152,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testValueOfTsv = {
def testValueOfTsv() = {
val i = new File(resourcePath("/sample.tsv"))
valueFromTsv(i, "Sample_ID_1", "library") should be(Some("Lib_ID_1"))
......@@ -163,7 +163,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testMain = {
def testMain() = {
val tmp = Files.createTempDirectory("vcfStats")
val vcf = resourcePath("/chrQ.vcf.gz")
val ref = resourcePath("/fake_chrQ.fa")
......@@ -229,7 +229,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testSortAnyAny = {
def testSortAnyAny() = {
//stub
val one: Any = 1
val two: Any = 2
......@@ -245,7 +245,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testCheckGeneral = {
def testCheckGeneral() = {
val record = new VCFFileReader(new File(resourcePath("/chrQ.vcf.gz"))).iterator().next()
val blah = checkGeneral(record, List())
......@@ -253,7 +253,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
blah.get("chrQ") should not be empty
blah.get("total") should not be empty
val chrq = blah.get("chrQ").get
val chrq = blah("chrQ")
chrq.get("SampleDistribution-NonInformative") shouldEqual Some(Map(0 -> 1))
chrq.get("SampleDistribution-Called") shouldEqual Some(Map(3 -> 1))
chrq.get("SampleDistribution-Mixed") shouldEqual Some(Map(0 -> 1))
......@@ -269,7 +269,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
chrq.get("SampleDistribution-Variant") shouldEqual Some(Map(2 -> 1))
chrq.get("general") should not be empty
val general = chrq.get("general").get
val general = chrq("general")
general.get("PolymorphicInSamples") shouldEqual Some(1)
general.get("ComplexIndel") shouldEqual Some(0)
......@@ -291,7 +291,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
general.get("Symbolic") shouldEqual Some(0)
general.get("SimpleInsertion") shouldEqual Some(1)
val total = blah.get("total").get
val total = blah("total")
total.get("SampleDistribution-NonInformative") shouldEqual Some(Map(0 -> 1))
total.get("SampleDistribution-Called") shouldEqual Some(Map(3 -> 1))
total.get("SampleDistribution-Mixed") shouldEqual Some(Map(0 -> 1))
......@@ -307,7 +307,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
total.get("SampleDistribution-Variant") shouldEqual Some(Map(2 -> 1))
chrq.get("general") should not be empty
val totGeneral = total.get("general").get
val totGeneral = total("general")
totGeneral.get("PolymorphicInSamples") shouldEqual Some(1)
totGeneral.get("ComplexIndel") shouldEqual Some(0)
......@@ -331,7 +331,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
}
@Test
def testCheckGenotype = {
def testCheckGenotype() = {
val record = new VCFFileReader(new File(resourcePath("/chrQ.vcf.gz"))).iterator().next()
val genotype = record.getGenotype(0)
......@@ -341,7 +341,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
blah.get("chrQ") should not be empty
blah.get("total") should not be empty
val chrq = blah.get("chrQ").get
val chrq = blah("chrQ")
chrq.get("GQ") shouldEqual Some(Map(99 -> 1))
chrq.get("AD") shouldEqual Some(Map(24 -> 1, 21 -> 1))
chrq.get("AD-used") shouldEqual Some(Map(24 -> 1, 21 -> 1))
......@@ -350,7 +350,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
chrq.get("AD-ref") shouldEqual Some(Map(24 -> 1))
chrq.get("general") should not be empty
val general = chrq.get("general").get
val general = chrq("general")
general.get("Hom") shouldEqual Some(0)
general.get("NoCall") shouldEqual Some(0)
general.get("Variant") shouldEqual Some(1)
......@@ -365,7 +365,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
general.get("Het") shouldEqual Some(1)
general.get("HetNonRef") shouldEqual Some(0)
val total = blah.get("total").get
val total = blah("total")
total.get("GQ") shouldEqual Some(Map(99 -> 1))
total.get("AD") shouldEqual Some(Map(24 -> 1, 21 -> 1))
total.get("AD-used") shouldEqual Some(Map(24 -> 1, 21 -> 1))
......@@ -374,7 +374,7 @@ class VcfStatsTest extends TestNGSuite with Matchers {
total.get("AD-ref") shouldEqual Some(Map(24 -> 1))
total.get("general") should not be empty
val totGeneral = total.get("general").get
val totGeneral = total("general")
totGeneral.get("Hom") shouldEqual Some(0)
totGeneral.get("NoCall") shouldEqual Some(0)
totGeneral.get("Variant") shouldEqual Some(1)
......
......@@ -14,9 +14,10 @@
*/
package nl.lumc.sasc.biopet.utils
import java.io.{ File, FileInputStream, FileOutputStream, InputStream }
import java.io._
import scala.io.Source
import scala.sys.process.Process
/**
* This object contains generic io methods
......@@ -83,4 +84,13 @@ object IoUtils {
reader.close()
lines
}
def executableExist(exe: String): Boolean = {
try {
val process = Process(Seq(exe)).run()
true
} catch {
case e: IOException => false
}
}
}
......@@ -204,6 +204,7 @@ object ShivaTest {
"fastqc" -> Map("exe" -> "test"),
"input_alleles" -> "test",
"variantcallers" -> "raw",
"rscript" -> Map("exe" -> "test"),
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
......
......@@ -129,6 +129,7 @@ object TinyCapTest {
"annotation_refflat" -> annotationRefflat,
"md5sum" -> Map("exe" -> "test"),
"rscript" -> Map("exe" -> "test"),
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
......
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