Commit 11c11c41 authored by bow's avatar bow

Merge branch 'feature-more_unit_tests' into 'develop'

More unit tests



See merge request !403
parents 7eb9af74 26a7681c
......@@ -132,7 +132,7 @@ trait ReportBuilder extends ToolCommand {
logger.info("Start")
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
require(cmdArgs.outputDir.exists(), "Output dir does not exist")
require(cmdArgs.outputDir.isDirectory, "Output dir is not a directory")
......
......@@ -80,7 +80,7 @@ object AnnotateVcfWithBed extends ToolCommand {
logger.info("Start")
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val fieldType = cmdArgs.fieldType match {
case "Integer" => VCFHeaderLineType.Integer
......
......@@ -53,7 +53,7 @@ object BaseCounter extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
//Sets picard logging level
htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.valueOf(logger.getLevel.toString))
......
......@@ -113,7 +113,7 @@ object BastyGenerateFasta extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
cmdArgs = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (cmdArgs.outputVariants != null) {
writeVariantsOnly()
......
......@@ -47,7 +47,7 @@ object BedToInterval extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val writer = new PrintWriter(commandArgs.outputFile)
......
......@@ -39,7 +39,7 @@ object BedtoolsCoverageToCounts extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
......@@ -50,7 +50,7 @@ object BiopetFlagstat extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val inputSam = SamReaderFactory.makeDefault.open(commandArgs.inputFile)
val iterSam = if (commandArgs.region.isEmpty) inputSam.iterator else {
......
......@@ -71,7 +71,7 @@ object CheckAllelesVcfInBam extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (commandArgs.bamFiles.size != commandArgs.samples.size)
logger.warn("Number of samples is different from number of bam files: additional samples or bam files will not be used")
......
......@@ -45,7 +45,7 @@ object FastqSplitter extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val groupSize = 100
val output = for (file <- commandArgs.outputFile) yield new AsyncFastqWriter(new BasicFastqWriter(file), groupSize)
......
......@@ -46,7 +46,7 @@ object FindRepeatsPacBio extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val bamReader = SamReaderFactory.makeDefault
.validationStringency(ValidationStringency.SILENT)
.open(commandArgs.inputBam)
......
......@@ -57,7 +57,7 @@ object GvcfToBed extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
logger.debug("Opening reader")
val reader = new VCFFileReader(cmdArgs.inputVcf, false)
......
......@@ -50,7 +50,7 @@ object MergeAlleles extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val readers = commandArgs.inputFiles.map(new VCFFileReader(_, true))
val referenceFile = new FastaSequenceFile(commandArgs.reference, true)
......
......@@ -41,7 +41,7 @@ object MergeOtuMaps extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
var map: Map[Long, String] = Map()
......
......@@ -62,7 +62,7 @@ object MpileupToVcf extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (commandArgs.input != null && !commandArgs.input.exists) throw new IllegalStateException("Input file does not exist")
val writer = new PrintWriter(commandArgs.output)
......
......@@ -52,7 +52,7 @@ object PrefixFastq extends ToolCommand {
logger.info("Start")
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val writer = new AsyncFastqWriter(new BasicFastqWriter(cmdArgs.output), 3000)
val reader = new FastqReader(cmdArgs.input)
......
......@@ -49,7 +49,7 @@ object RegionAfCount extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
logger.info("Start")
logger.info("Reading bed file")
......
......@@ -41,7 +41,7 @@ object SageCountFastq extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
......@@ -74,7 +74,7 @@ object SageCreateLibrary extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
......@@ -52,7 +52,7 @@ object SageCreateTagCounts extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (!commandArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + commandArgs.input)
......
......@@ -46,7 +46,7 @@ object SamplesTsvToJson extends ToolCommand {
/** Executes SamplesTsvToJson */
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val jsonString = stringFromInputs(cmdArgs.inputFiles, cmdArgs.tagFiles)
cmdArgs.outputFile match {
......
......@@ -46,7 +46,7 @@ object SquishBed extends ToolCommand {
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
if (!cmdArgs.input.exists) throw new IllegalStateException("Input file not found, file: " + cmdArgs.input)
......
......@@ -61,7 +61,7 @@ object SummaryToTsv extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val summary = new Summary(cmdArgs.summary)
......
......@@ -51,7 +51,7 @@ object ValidateFastq extends ToolCommand {
//parse all possible options into OptParser
val argsParser = new OptParser
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
//read in fastq file 1 and if present fastq file 2
val readFq1 = new FastqReader(cmdArgs.input)
......
......@@ -137,7 +137,7 @@ object VcfFilter extends ToolCommand {
def main(args: Array[String]): Unit = {
logger.info("Start")
val argsParser = new OptParser
val cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val cmdArgs = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val reader = new VCFFileReader(cmdArgs.inputVcf, false)
val header = reader.getFileHeader
......
......@@ -206,7 +206,7 @@ object VcfStats extends ToolCommand {
def main(args: Array[String]): Unit = {
logger.info("Started")
val argsParser = new OptParser
cmdArgs = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
cmdArgs = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
val reader = new VCFFileReader(cmdArgs.inputFile, true)
val header = reader.getFileHeader
......
......@@ -72,7 +72,7 @@ object VcfToTsv extends ToolCommand {
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse(throw new IllegalArgumentException)
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse (throw new IllegalArgumentException)
// Throw exception if separator and listSeparator are identical
if (commandArgs.separator == commandArgs.listSeparator) throw new IllegalArgumentException(
......
......@@ -43,7 +43,7 @@ trait MultisampleMappingTrait extends MultiSampleQScript
/** With this method the merge strategy for libraries to samples is defined. This can be overriden to fix the merge strategy. */
def mergeStrategy: MergeStrategy.Value = {
val value: String = config("merge_strategy", default = "preprocessmarkduplicates")
MergeStrategy.values.find(_.toString.toLowerCase == value) match {
MergeStrategy.values.find(_.toString.toLowerCase == value.toLowerCase) match {
case Some(v) => v
case _ => throw new IllegalArgumentException(s"merge_strategy '$value' does not exist")
}
......@@ -151,10 +151,9 @@ trait MultisampleMappingTrait extends MultiSampleQScript
try {
header.getSequenceDictionary.assertSameDictionary(referenceFile.getSequenceDictionary)
} catch {
case e: AssertionError => {
case e: AssertionError =>
logger.error(e.getMessage)
oke = false
}
}
oke
}
......@@ -172,8 +171,7 @@ trait MultisampleMappingTrait extends MultiSampleQScript
"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")
if (!dictOke) Logging.addError(
"Sequence dictionary in the bam file is not the same as the reference, file: " + bamFile +
"\nPlease note that it is possible to set 'correct_dict' to true in the config to automatic fix this")
"Sequence dictionary in the bam file is not the same as the reference, file: " + bamFile)
if (!readGroupOke && correctReadgroups) {
logger.info("Correcting readgroups, file:" + inputBam.get)
......
@HD VN:1.5 SO:coordinate
@SQ SN:chr1 LN:9 UR:file:/home/pjvan_thof/pipelines/biopet/public/mapping/src/test/resources/ref.fa M5:fe15dbbd0900310caf32827f6da57550
@RG ID:001 SM:sample3 LB:lib1
r02 0 chr1 210 60 10M * 0 0 TACGTACGTA EEFFGGHHII RG:Z:001
......@@ -18,6 +18,7 @@ package nl.lumc.sasc.biopet.pipelines.mapping
import java.io.{ File, FileOutputStream }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.kraken.Kraken
import nl.lumc.sasc.biopet.pipelines.flexiprep.Fastqc
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
......@@ -25,7 +26,7 @@ import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.{ BeforeClass, AfterClass, DataProvider, Test }
import org.testng.annotations.{ AfterClass, BeforeClass, DataProvider, Test }
/**
* Test class for [[Mapping]]
......@@ -42,14 +43,15 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with
}
}
def paired = Array(true, false)
def chunks = Array(1, 5)
def skipMarkDuplicates = Array(true, false)
def skipFlexipreps = Array(true, false)
def zipped = Array(true, false)
def unmappedToGears = false
@DataProvider(name = "mappingOptions")
def mappingOptions = {
val paired = Array(true, false)
val chunks = Array(1, 5)
val skipMarkDuplicates = Array(true, false)
val skipFlexipreps = Array(true, false)
val zipped = Array(true, false)
for (
pair <- paired;
chunk <- chunks;
......@@ -68,7 +70,8 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with
"aligner" -> aligner,
"number_chunks" -> chunks,
"skip_markduplicates" -> skipMarkDuplicate,
"skip_flexiprep" -> skipFlexiprep
"skip_flexiprep" -> skipFlexiprep,
"unmapped_to_gears" -> unmappedToGears
), Map(executables.toSeq: _*))
val mapping: Mapping = initPipeline(map)
......@@ -85,6 +88,8 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with
//Flexiprep
mapping.functions.count(_.isInstanceOf[Fastqc]) shouldBe (if (skipFlexiprep) 0 else if (paired) 4 else 2)
mapping.functions.count(_.isInstanceOf[Kraken]) shouldBe (if (unmappedToGears) 1 else 0)
}
val outputDir = Files.createTempDir()
......@@ -133,6 +138,8 @@ abstract class AbstractTestMapping(val aligner: String) extends TestNGSuite with
"bowtie2" -> Map("exe" -> "test"),
"stampy" -> Map("exe" -> "test", "genome" -> "test", "hash" -> "test"),
"samtools" -> Map("exe" -> "test"),
"kraken" -> Map("exe" -> "test", "db" -> "test"),
"krakenreport" -> Map("exe" -> "test", "db" -> "test"),
"md5sum" -> Map("exe" -> "test")
)
......@@ -151,3 +158,13 @@ class MappingBowtie2Test extends AbstractTestMapping("bowtie2")
class MappingStampyTest extends AbstractTestMapping("stampy")
class MappingGsnapTest extends AbstractTestMapping("gsnap")
class MappingTophatTest extends AbstractTestMapping("tophat")
class MappingGearsTest extends AbstractTestMapping("bwa-mem") {
override def unmappedToGears = true
override def paired = Array(true)
override def chunks = Array(1)
override def skipMarkDuplicates = Array(true)
override def skipFlexipreps = Array(true)
override def zipped = Array(true)
}
package nl.lumc.sasc.biopet.pipelines.mapping
import java.io.{ File, FileOutputStream }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.kraken.Kraken
import nl.lumc.sasc.biopet.extensions.picard.{ MarkDuplicates, MergeSamFiles }
import nl.lumc.sasc.biopet.utils.ConfigUtils
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.{ DataProvider, Test }
/**
* Created by pjvanthof on 15/05/16.
*/
trait MultisampleMappingTestTrait extends TestNGSuite with Matchers {
def initPipeline(map: Map[String, Any]): MultisampleMapping = {
new MultisampleMapping() {
override def configNamespace = "multisamplemapping"
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, MultisampleMappingTestTrait.config))
qSettings = new QSettings
qSettings.runName = "test"
}
}
def mergeStrategies = MultisampleMapping.MergeStrategy.values
def bamToFastq = false
def correctReadgroups = false
def unmappedToGears = false
def sample1 = Array(true, false)
def sample2 = Array(true, false)
def sample3 = false
def sample4 = false
@DataProvider(name = "mappingOptions")
def mappingOptions = {
for (
merge <- mergeStrategies.toArray; s1 <- sample1; s2 <- sample2
) yield Array(merge, s1, s2)
}
@Test(dataProvider = "mappingOptions")
def testMultisampleMapping(merge: MultisampleMapping.MergeStrategy.Value, sample1: Boolean, sample2: Boolean): Unit = {
val map: Map[String, Any] = {
var m: Map[String, Any] = MultisampleMappingTestTrait.config
if (sample1) m = ConfigUtils.mergeMaps(MultisampleMappingTestTrait.sample1, m)
if (sample2) m = ConfigUtils.mergeMaps(MultisampleMappingTestTrait.sample2, m)
if (sample3) m = ConfigUtils.mergeMaps(MultisampleMappingTestTrait.sample3, m)
if (sample4) m = ConfigUtils.mergeMaps(MultisampleMappingTestTrait.sample4, m)
m ++ Map(
"merge_strategy" -> merge.toString,
"bam_to_fastq" -> bamToFastq,
"correct_readgroups" -> correctReadgroups,
"unmapped_to_gears" -> unmappedToGears
)
}
if (!sample1 && !sample2 && !sample3 && !sample4) { // When no samples
intercept[IllegalArgumentException] {
initPipeline(map).script()
}
} else if (sample4 && !bamToFastq && !correctReadgroups) {
intercept[IllegalStateException] {
initPipeline(map).script()
}
} else {
val pipeline = initPipeline(map)
pipeline.script()
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)
import MultisampleMapping.MergeStrategy
pipeline.functions.count(_.isInstanceOf[MarkDuplicates]) shouldBe (numberFastqLibs +
(if (sample2 && (merge == MergeStrategy.MarkDuplicates || merge == MergeStrategy.PreProcessMarkDuplicates)) 1 else 0))
pipeline.functions.count(_.isInstanceOf[MergeSamFiles]) shouldBe (
(if (sample2 && (merge == MergeStrategy.MergeSam || merge == MergeStrategy.PreProcessMergeSam)) 1 else 0))
pipeline.samples.foreach {
case (sampleName, sample) =>
if (merge == MergeStrategy.None) sample.bamFile shouldBe None
sample.summaryStats shouldBe Map()
sample.libraries.foreach {
case (libraryId, library) =>
library.summaryStats shouldBe Map()
}
}
pipeline.functions.count(_.isInstanceOf[Kraken]) shouldBe (if (unmappedToGears) (numberFastqLibs + numberSamples) else 0)
pipeline.summarySettings.get("merge_strategy") shouldBe Some(merge.toString)
}
}
}
class MultisampleMappingTest extends MultisampleMappingTestTrait {
override def sample1 = Array(true)
}
class MultisampleMappingNoSamplesTest extends MultisampleMappingTestTrait {
override def sample1 = Array(false)
override def sample2 = Array(false)
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
class MultisampleMappingGearsTest extends MultisampleMappingTestTrait {
override def sample1 = Array(true)
override def sample2 = Array(false)
override def unmappedToGears = true
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
class MultisampleMappingBamTest extends MultisampleMappingTestTrait {
override def sample1 = Array(false)
override def sample2 = Array(false)
override def sample3 = true
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
class MultisampleMappingWrongBamTest extends MultisampleMappingTestTrait {
override def sample1 = Array(false)
override def sample2 = Array(false)
override def sample4 = true
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
class MultisampleMappingCorrectBamTest extends MultisampleMappingTestTrait {
override def sample1 = Array(false)
override def sample2 = Array(false)
override def correctReadgroups = true
override def sample4 = true
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
class MultisampleMappingBamToFastqTest extends MultisampleMappingTestTrait {
override def sample1 = Array(false)
override def sample2 = Array(false)
override def bamToFastq = true
override def sample3 = true
override def sample4 = true
override def mergeStrategies = MultisampleMapping.MergeStrategy.values.filter(_ == MultisampleMapping.MergeStrategy.PreProcessMarkDuplicates)
}
object MultisampleMappingTestTrait {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
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)
val os = new FileOutputStream(new File(outputDir, name))
org.apache.commons.io.IOUtils.copy(is, os)
os.close()
}
copyFile("ref.fa")
copyFile("ref.dict")
copyFile("ref.fa.fai")
copyFile("empty.sam")
val config = Map(
"name_prefix" -> "test",
"cache" -> true,
"dir" -> "test",
"vep_script" -> "test",
"output_dir" -> outputDir,
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"fastqc" -> Map("exe" -> "test"),
"input_alleles" -> "test",
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
"cutadapt" -> Map("exe" -> "test"),
"bwa" -> Map("exe" -> "test"),
"samtools" -> Map("exe" -> "test"),
"igvtools" -> Map("exe" -> "test"),
"wigtobigwig" -> Map("exe" -> "test"),
"kraken" -> Map("exe" -> "test", "db" -> "test"),
"krakenreport" -> Map("exe" -> "test", "db" -> "test"),
"md5sum" -> Map("exe" -> "test")
)
val sample1 = Map(
"samples" -> Map("sample1" -> Map("libraries" -> Map(
"lib1" -> Map(
"R1" -> inputTouch("1_1_R1.fq"),
"R2" -> inputTouch("1_1_R2.fq")
)
)
)))
val sample2 = Map(
"samples" -> Map("sample3" -> Map("libraries" -> Map(
"lib1" -> Map(
"R1" -> inputTouch("2_1_R1.fq"),
"R2" -> inputTouch("2_1_R2.fq")
),
"lib2" -> Map(
"R1" -> inputTouch("2_2_R1.fq"),
"R2" -> inputTouch("2_2_R2.fq")
)
)
)))
val sample3 = Map(
"samples" -> Map("sample3" -> Map("libraries" -> Map(
"lib1" -> Map(
"bam" -> (outputDir + File.separator + "empty.sam")
)
)
)))
val sample4 = Map(
"samples" -> Map("sample4" -> Map("libraries" -> Map(
"lib1" -> Map(
"bam" -> (outputDir + File.separator + "empty.sam")
)
)
)))
}
......@@ -179,8 +179,8 @@ class ShivaVariantcalling(val root: Configurable) extends QScript
/** Settings for the summary */
def summarySettings = Map(
"variantcallers" -> configCallers.toList,
"regions_of_interest" -> roiBedFiles.map(_.getName.stripSuffix(".bed")),
"amplicon_bed" -> ampliconBedFile.map(_.getName.stripSuffix(