Commit ba931103 authored by Peter van 't Hof's avatar Peter van 't Hof

Change naming

parent 1eada82e
......@@ -5,10 +5,10 @@
*/
package nl.lumc.sasc.biopet.extensions.gatk.broad
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.{ Reference, BiopetJavaCommandLineFunction }
import org.broadinstitute.gatk.queue.extensions.gatk.CommandLineGATK
trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction {
trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction with Reference {
memoryLimit = Option(3)
override def subPath = "gatk" :: super.subPath
......@@ -19,7 +19,7 @@ trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction {
if (config.contains("intervals")) intervals = config("intervals").asFileList
if (config.contains("exclude_intervals")) excludeIntervals = config("exclude_intervals").asFileList
reference_sequence = config("reference")
reference_sequence = referenceFasta()
if (config.contains("gatk_key")) gatk_key = config("gatk_key")
if (config.contains("pedigree")) pedigree = config("pedigree")
}
......@@ -107,7 +107,7 @@ object ShivaTest {
"name_prefix" -> "test",
"output_dir" -> outputDir,
"reference" -> (outputDir + File.separator + "ref.fa"),
"referenceFasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"bcftools" -> Map("exe" -> "test"),
......
......@@ -5,7 +5,7 @@
*/
package nl.lumc.sasc.biopet.pipelines.gatk
import java.io.File
import java.io.{ FileOutputStream, File }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.config.Config
......@@ -106,10 +106,22 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
object ShivaVariantcallingTest {
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 config = Map(
"name_prefix" -> "test",
"output_dir" -> outputDir,
"reference" -> "test",
"reference" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"bcftools" -> Map("exe" -> "test"),
......
......@@ -21,25 +21,34 @@ trait Reference extends Configurable {
var referenceName: String = {
root match {
case r: Reference => r.referenceName
case _ => config("referenceName", default = "unknown_ref")
case _ => config("reference_name", default = "unknown_ref")
}
}
def referenceFasta(): File = {
val file: File = config("referenceFasta", path = List("genomes", referenceSpecies, referenceName))
val file: File = config("reference_fasta", path = List("genomes", referenceSpecies, referenceName))
Reference.checkFasta(file)
val dict = new File(file.getAbsolutePath.stripSuffix(".fa").stripSuffix(".fasta") + ".dict")
val fai = new File(file.getAbsolutePath + ".fai")
this match {
case c: BiopetCommandLineFunctionTrait => c.deps :::= dict :: fai :: Nil
case _ =>
}
file
}
def referenceSummary: Map[String, Any] = {
val file = new IndexedFastaSequenceFile(referenceFasta())
Map(referenceSpecies ->
Map(referenceName ->
(for (seq <- file.getSequenceDictionary.getSequences) yield seq.getSequenceName -> {
val md5 = Option(seq.getAttribute("M5"))
Map("md5" -> md5, "length" -> seq.getSequenceLength)
}).toMap
)
Map("contigs" ->
(for (seq <- file.getSequenceDictionary.getSequences) yield seq.getSequenceName -> {
val md5 = Option(seq.getAttribute("M5"))
Map("md5" -> md5, "length" -> seq.getSequenceLength)
}).toMap,
"species" -> referenceSpecies,
"name" -> referenceName
)
}
}
......
......@@ -17,14 +17,14 @@ package nl.lumc.sasc.biopet.extensions.gatk
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.{ Reference, BiopetJavaCommandLineFunction }
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.Input
/**
* Created by pjvan_thof on 2/26/15.
*/
abstract class Gatk extends BiopetJavaCommandLineFunction {
abstract class Gatk extends BiopetJavaCommandLineFunction with Reference {
override def subPath = "gatk" :: super.subPath
jarFile = config("gatk_jar")
......@@ -34,7 +34,7 @@ abstract class Gatk extends BiopetJavaCommandLineFunction {
override val defaultCoreMemory = 3.0
@Input(required = true)
var reference: File = config("reference")
var reference: File = referenceFasta()
@Input(required = false)
var gatkKey: Option[File] = config("gatk_key")
......
......@@ -110,7 +110,7 @@ object CarpTest {
val executables = Map(
"reference" -> (outputDir + File.separator + "ref.fa"),
"referenceFasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
......
......@@ -143,7 +143,7 @@ object MappingTest {
val executables = Map(
"reference" -> (outputDir + File.separator + "ref.fa"),
"referenceFasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
......
......@@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.shiva
import java.io.File
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.core.{ Reference, BiopetQScript, PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.{ Tabix, Bgzip, Gzip }
import nl.lumc.sasc.biopet.extensions.bcftools.BcftoolsCall
......@@ -33,7 +33,7 @@ import scala.collection.generic.Sorted
/**
* Created by pjvan_thof on 2/26/15.
*/
trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with Reference {
qscript =>
@Input(doc = "Bam files (should be deduped bams)", shortName = "BAM", required = true)
......
......@@ -102,7 +102,7 @@ object ShivaTest {
"name_prefix" -> "test",
"output_dir" -> outputDir,
"reference" -> (outputDir + File.separator + "ref.fa"),
"referenceFasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"bcftools" -> Map("exe" -> "test"),
......
......@@ -15,7 +15,7 @@
*/
package nl.lumc.sasc.biopet.pipelines.shiva
import java.io.File
import java.io.{ FileOutputStream, File }
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.config.Config
......@@ -87,10 +87,22 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
object ShivaVariantcallingTest {
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 config = Map(
"name_prefix" -> "test",
"output_dir" -> outputDir,
"reference" -> "test",
"reference" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"bcftools" -> 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