Commit 1621e5cd authored by Peter van 't Hof's avatar Peter van 't Hof

Added freebayes

parent e7aa783e
package nl.lumc.sasc.biopet.extensions
import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
/**
* Created by pjvan_thof on 3/3/15.
*/
class Freebayes(val root: Configurable) extends BiopetCommandLineFunction {
@Input(required = true)
var bamfiles: List[File] = Nil
@Input(required = true)
var reference: File = config("reference")
@Output(required = true)
var outputVcf: File = null
var ploidy: Option[Int] = config("ploidy")
executable = config("exe", default = "freebayes")
override val versionRegex = """version: (.*)""".r
override def versionCommand = executable + " --version"
def cmdLine = executable +
required("--fasta-reference", reference) +
repeat("--bam", bamfiles) +
optional("--vcf", outputVcf) +
optional("--ploidy", ploidy)
}
......@@ -77,7 +77,7 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
addSummaryJobs
}
protected def callersList: List[Variantcaller] = List(new RawVcf, new Bcftools)
protected def callersList: List[Variantcaller] = List(new Freebayes, new RawVcf, new Bcftools)
trait Variantcaller {
val name: String
......@@ -88,6 +88,20 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag {
def outputFile: File
}
class Freebayes extends Variantcaller {
val name = "freebayes"
protected val defaultPrio = 7
def outputFile = new File(outputDir, namePrefix + ".freebayes.vcf")
def addJobs() {
val fb = new nl.lumc.sasc.biopet.extensions.Freebayes(qscript)
fb.bamfiles = inputBams
fb.outputVcf = outputFile
add(fb)
}
}
class Bcftools extends Variantcaller {
val name = "bcftools"
protected val defaultPrio = 8
......
......@@ -4,6 +4,7 @@ import java.io.File
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.config.Config
import nl.lumc.sasc.biopet.extensions.Freebayes
import nl.lumc.sasc.biopet.extensions.gatk.CombineVariants
import nl.lumc.sasc.biopet.tools.{ VcfFilter, MpileupToVcf }
import nl.lumc.sasc.biopet.utils.ConfigUtils
......@@ -31,20 +32,21 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
@DataProvider(name = "shivaVariantcallingOptions")
def shivaVariantcallingOptions = {
val bool = Array(true, false)
(for (bams <- 0 to 3; raw <- bool; bcftools <- bool) yield Array(bams, raw, bcftools)).toArray
(for (bams <- 0 to 3; raw <- bool; bcftools <- bool; freebayes <- bool) yield Array(bams, raw, bcftools, freebayes)).toArray
}
@Test(dataProvider = "shivaVariantcallingOptions")
def testShivaVariantcalling(bams: Int, raw: Boolean, bcftools: Boolean) = {
def testShivaVariantcalling(bams: Int, raw: Boolean, bcftools: Boolean, freebayes: Boolean) = {
val callers: ListBuffer[String] = ListBuffer()
if (raw) callers.append("raw")
if (bcftools) callers.append("bcftools")
if (freebayes) callers.append("freebayes")
val map = Map("variantcallers" -> callers.toList)
val pipeline = initPipeline(map)
pipeline.inputBams = (for (n <- 1 to bams) yield new File("bam_" + n + ".bam")).toList
val illegalArgumentException = pipeline.inputBams.isEmpty || (!raw && !bcftools)
val illegalArgumentException = pipeline.inputBams.isEmpty || (!raw && !bcftools && !freebayes)
if (illegalArgumentException) intercept[IllegalArgumentException] {
pipeline.script()
......@@ -56,6 +58,7 @@ class ShivaVariantcallingTest extends TestNGSuite with Matchers {
pipeline.functions.count(_.isInstanceOf[CombineVariants]) shouldBe 1 + (if (raw) 1 else 0)
//pipeline.functions.count(_.isInstanceOf[Bcftools]) shouldBe (if (bcftools) 1 else 0)
//FIXME: Can not check for bcftools because of piping
pipeline.functions.count(_.isInstanceOf[Freebayes]) shouldBe (if (freebayes) 1 else 0)
pipeline.functions.count(_.isInstanceOf[MpileupToVcf]) shouldBe (if (raw) bams else 0)
pipeline.functions.count(_.isInstanceOf[VcfFilter]) shouldBe (if (raw) bams else 0)
}
......@@ -75,6 +78,7 @@ object ShivaVariantcallingTest {
"reference" -> "test",
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"bcftools" -> Map("exe" -> "test")
"bcftools" -> Map("exe" -> "test"),
"freebayes" -> Map("exe" -> "test")
)
}
\ No newline at end of file
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