Commit 15522284 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Switch unit tests to reference module

parent ab5e1c96
@HD VN:1.4 SO:unsorted
@SQ SN:chr1 LN:9 UR:file:/home/pjvan_thof/pipelines/biopet/public/mapping/src/test/resources/ref.fa M5:fe15dbbd0900310caf32827f6da57550
package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.File
import java.io.{ FileOutputStream, File }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.config.Config
......@@ -81,9 +81,20 @@ class BamMetricsTest extends TestNGSuite with Matchers {
object BamMetricsTest {
val outputDir = Files.createTempDir()
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")
val executables = Map(
"refFlat" -> "bla.refFlat",
"reference" -> "reference.fa",
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"samtools" -> Map("exe" -> "test"),
"bedtools" -> Map("exe" -> "test")
)
......
......@@ -2,20 +2,21 @@ package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
/**
* Created by pjvan_thof on 4/15/15.
*/
class BedToIntervalList(val root: Configurable) extends Picard {
class BedToIntervalList(val root: Configurable) extends Picard with Reference {
javaMainClass = new picard.util.BedToIntervalList().getClass.getName
@Input(doc = "Input bed file", required = true)
var input: File = null
@Input(doc = "Reference dict file", required = true)
var dict: File = new File(config("reference").asString.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
var dict: File = new File(referenceFasta().toString.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
@Output(doc = "Output interval list", required = true)
var output: File = null
......
......@@ -16,12 +16,13 @@
package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
/** Extension for picard CalculateHsMetrics */
class CalculateHsMetrics(val root: Configurable) extends Picard with Summarizable {
class CalculateHsMetrics(val root: Configurable) extends Picard with Summarizable with Reference {
javaMainClass = new picard.analysis.directed.CalculateHsMetrics().getClass.getName
@Input(doc = "The input SAM or BAM files to analyze. Must be coordinate sorted.", required = true)
......@@ -40,7 +41,7 @@ class CalculateHsMetrics(val root: Configurable) extends Picard with Summarizabl
var perTargetCoverage: File = _
@Argument(doc = "Reference file", required = false)
var reference: File = config("reference")
var reference: File = null
@Argument(doc = "METRIC_ACCUMULATION_LEVEL", required = false)
var metricAccumulationLevel: List[String] = config("metricaccumulationlevel", default = Nil)
......@@ -48,6 +49,11 @@ class CalculateHsMetrics(val root: Configurable) extends Picard with Summarizabl
@Argument(doc = "BAIT_SET_NAME", required = false)
var baitSetName: String = _
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
/** Returns command to execute */
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
......
......@@ -2,6 +2,7 @@ package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.summary.Summarizable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Output, Input }
......@@ -9,7 +10,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Argument, Output, Input }
/**
* Created by pjvan_thof on 4/16/15.
*/
class CollectTargetedPcrMetrics(val root: Configurable) extends Picard with Summarizable {
class CollectTargetedPcrMetrics(val root: Configurable) extends Picard with Summarizable with Reference {
javaMainClass = new picard.analysis.directed.CollectTargetedPcrMetrics().getClass.getName
......@@ -17,7 +18,7 @@ class CollectTargetedPcrMetrics(val root: Configurable) extends Picard with Summ
var input: File = _
@Input(doc = "Reference", required = true)
var reference: File = config("reference")
var reference: File = null
@Input(doc = "AMPLICON_INTERVALS", required = true)
var ampliconIntervals: File = _
......@@ -37,6 +38,11 @@ class CollectTargetedPcrMetrics(val root: Configurable) extends Picard with Summ
@Argument(doc = "CUSTOM_AMPLICON_SET_NAME", required = false)
var customAmpliconSetName: Option[String] = config("custom_amplicon_set_name")
override def beforeGraph {
super.beforeGraph
if (reference == null) reference = referenceFasta()
}
override def commandLine = super.commandLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false) +
......
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