Commit 5f206fa7 authored by Peter van 't Hof's avatar Peter van 't Hof

Merge branch 'develop' into feature-licence

parents 7fdfe224 f4576dca
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-5p [%d] [%C{1}] - %m%n
\ No newline at end of file
......@@ -54,29 +54,43 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
}
protected def checkExecutable {
try if (executable != null) {
val buffer = new StringBuffer()
val cmd = Seq("which", executable)
val process = Process(cmd).run(ProcessLogger(buffer.append(_)))
if (process.exitValue == 0) {
executable = buffer.toString
val file = new File(executable)
executable = file.getCanonicalPath
} else {
logger.error("executable: '" + executable + "' not found, please check config")
throw new QException("executable: '" + executable + "' not found, please check config")
if (!BiopetCommandLineFunctionTrait.executableMd5Cache.contains(executable)) {
try if (executable != null) {
if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable)) {
val oldExecutable = executable
val buffer = new StringBuffer()
val cmd = Seq("which", executable)
val process = Process(cmd).run(ProcessLogger(buffer.append(_)))
if (process.exitValue == 0) {
executable = buffer.toString
val file = new File(executable)
executable = file.getCanonicalPath
} else {
logger.error("executable: '" + executable + "' not found, please check config")
throw new QException("executable: '" + executable + "' not found, please check config")
}
BiopetCommandLineFunctionTrait.executableCache += oldExecutable -> executable
BiopetCommandLineFunctionTrait.executableCache += executable -> executable
} else {
executable = BiopetCommandLineFunctionTrait.executableCache(executable)
}
if (!BiopetCommandLineFunctionTrait.executableMd5Cache.contains(executable)) {
val is = new FileInputStream(executable)
val cnt = is.available
val bytes = Array.ofDim[Byte](cnt)
is.read(bytes)
is.close()
val temp = MessageDigest.getInstance("MD5").digest(bytes).map("%02X".format(_)).mkString.toLowerCase
BiopetCommandLineFunctionTrait.executableMd5Cache += executable -> temp
}
addJobReportBinding("md5sum_exe", BiopetCommandLineFunctionTrait.executableMd5Cache(executable))
} catch {
case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe)
}
val is = new FileInputStream(executable)
val cnt = is.available
val bytes = Array.ofDim[Byte](cnt)
is.read(bytes)
is.close()
val md5: String = MessageDigest.getInstance("MD5").digest(bytes).map("%02X".format(_)).mkString.toLowerCase
addJobReportBinding("md5sum_exe", md5)
} catch {
case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe)
} else {
addJobReportBinding("md5sum_exe", BiopetCommandLineFunctionTrait.executableMd5Cache(executable))
}
}
......@@ -138,4 +152,6 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
object BiopetCommandLineFunctionTrait {
import scala.collection.mutable.Map
private val versionCache: Map[String, String] = Map()
private val executableMd5Cache: Map[String, String] = Map()
private val executableCache: Map[String, String] = Map()
}
\ No newline at end of file
package nl.lumc.sasc.biopet.core
import java.io.File
import java.util.Properties
import nl.lumc.sasc.biopet.core.config.Config
import org.apache.log4j.Logger
object BiopetExecutable extends Logging {
......@@ -34,7 +36,10 @@ object BiopetExecutable extends Logging {
nl.lumc.sasc.biopet.tools.BedtoolsCoverageToCounts,
nl.lumc.sasc.biopet.tools.SageCountFastq,
nl.lumc.sasc.biopet.tools.SageCreateLibrary,
nl.lumc.sasc.biopet.tools.SageCreateTagCounts)
nl.lumc.sasc.biopet.tools.SageCreateTagCounts,
nl.lumc.sasc.biopet.tools.BastyGenerateFasta,
nl.lumc.sasc.biopet.tools.MergeAlleles,
nl.lumc.sasc.biopet.tools.SamplesTsvToJson)
)
/**
......@@ -87,6 +92,14 @@ object BiopetExecutable extends Logging {
println("version: " + getVersion)
}
case Array(module, name, passArgs @ _*) => {
// Reading config files
val argsSize = passArgs.size
for (t <- 0 until argsSize) {
if (passArgs(t) == "-config" || args(t) == "--config_file") {
if (t >= argsSize) throw new IllegalStateException("-config needs a value")
Config.global.loadConfigFile(new File(passArgs(t + 1)))
}
}
getCommand(module, name).main(passArgs.toArray)
}
case Array(module) => {
......
......@@ -5,6 +5,12 @@ import org.broadinstitute.gatk.queue.function.JavaCommandLineFunction
trait BiopetJavaCommandLineFunction extends JavaCommandLineFunction with BiopetCommandLineFunctionTrait {
executable = "java"
javaGCThreads = config("java_gc_threads")
javaGCHeapFreeLimit = config("java_gc_heap_freelimit")
javaGCTimeLimit = config("java_gc_timelimit")
override def javaOpts = super.javaOpts + optional("-Dscala.concurrent.context.numThreads=", threads, spaceSeparated = false, escape = false)
override def afterGraph {
memoryLimit = config("memory_limit")
}
......
......@@ -2,7 +2,7 @@ package nl.lumc.sasc.biopet.core
import java.io.File
import java.io.PrintWriter
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.config.{ Config, Configurable }
import org.broadinstitute.gatk.utils.commandline.Argument
import org.broadinstitute.gatk.queue.QSettings
import org.broadinstitute.gatk.queue.function.QFunction
......@@ -25,7 +25,6 @@ trait BiopetQScript extends Configurable {
var functions: Seq[QFunction]
final def script() {
for (file <- configfiles) globalConfig.loadConfigFile(file)
if (!outputDir.endsWith("/")) outputDir += "/"
init
biopetScript
......@@ -33,7 +32,7 @@ trait BiopetQScript extends Configurable {
case f: BiopetCommandLineFunctionTrait => f.afterGraph
case _ =>
}
val configReport = globalConfig.getReport
val configReport = Config.global.getReport
val configReportFile = new File(outputDir + qSettings.runName + ".configreport.txt")
configReportFile.getParentFile.mkdir
val writer = new PrintWriter(configReportFile)
......
package nl.lumc.sasc.biopet.core
import java.text.SimpleDateFormat
import java.util.Calendar
import org.apache.log4j.Logger
import org.apache.log4j.WriterAppender
import org.apache.log4j.helpers.DateLayout
trait Logging {
protected val logger = Logger.getLogger(getClass.getSimpleName.split("\\$").last)
private[core] val logLayout = new DateLayout() {
val ignoresThrowable = false
def format(event: org.apache.log4j.spi.LoggingEvent): String = {
val calendar: Calendar = Calendar.getInstance
calendar.setTimeInMillis(event.getTimeStamp)
val formatter: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
val formattedDate: String = formatter.format(calendar.getTime)
var logLevel = event.getLevel.toString
while (logLevel.size < 6) logLevel += " "
logLevel + " [" + formattedDate + "] [" + event.getLoggerName + "] " + event.getMessage + "\n"
}
}
private[core] val stderrAppender = new WriterAppender(logLayout, sys.process.stderr)
logger.setLevel(org.apache.log4j.Level.INFO)
logger.addAppender(stderrAppender)
def logger = Logging.logger
}
object Logging {
val logger = Logger.getRootLogger
}
\ No newline at end of file
package nl.lumc.sasc.biopet.core
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.config.{ Config, Configurable }
trait MultiSampleQScript extends BiopetQScript {
type LibraryOutput <: AbstractLibraryOutput
......@@ -13,14 +13,13 @@ trait MultiSampleQScript extends BiopetQScript {
def getLibrary(key: String) = libraries(key)
}
var samplesConfig: Map[String, Any] = Map()
var samplesConfig: Map[String, Any] = config("samples")
var samplesOutput: Map[String, SampleOutput] = Map()
def globalSampleDir: String = outputDir + "samples/"
final def runSamplesJobs() {
samplesConfig = config("samples")
if (samplesConfig == null) samplesConfig = Map()
if (globalConfig.contains("samples")) for ((key, value) <- samplesConfig) {
if (Config.global.contains("samples")) for ((key, value) <- samplesConfig) {
var sample = Configurable.any2map(value)
if (!sample.contains("ID")) sample += ("ID" -> key)
if (sample("ID") == key) {
......@@ -32,7 +31,11 @@ trait MultiSampleQScript extends BiopetQScript {
def runSingleSampleJobs(sampleConfig: Map[String, Any]): SampleOutput
def runSingleSampleJobs(sample: String): SampleOutput = {
return runSingleSampleJobs(Configurable.any2map(samplesConfig(sample)))
var map = Configurable.any2map(samplesConfig(sample))
if (map.contains("ID") && map("ID") != sample)
throw new IllegalStateException("ID in config not the same as the key")
else map += ("ID" -> sample)
return runSingleSampleJobs(map)
}
final def runLibraryJobs(sampleConfig: Map[String, Any]): Map[String, LibraryOutput] = {
......
package nl.lumc.sasc.biopet.core
import org.apache.log4j.WriterAppender
import java.io.File
trait ToolCommand extends MainCommand with Logging {
abstract class AbstractArgs {
}
abstract class AbstractOptParser extends scopt.OptionParser[Args](commandName) {
opt[Unit]("log_nostderr") foreach { _ =>
logger.removeAppender(stderrAppender)
} text ("No output to stderr")
opt[File]("log_file") foreach { x =>
logger.addAppender(new WriterAppender(logLayout, new java.io.PrintStream(x)))
} text ("Log file") valueName ("<file>")
opt[String]('l', "log_level") foreach { x =>
x.toLowerCase match {
case "debug" => logger.setLevel(org.apache.log4j.Level.DEBUG)
......
package nl.lumc.sasc.biopet.core.config
import java.io.File
import org.broadinstitute.gatk.queue.util.Logging
import nl.lumc.sasc.biopet.core.Logging
import argonaut._, Argonaut._
import scalaz._, Scalaz._
......@@ -104,7 +104,9 @@ class Config(var map: Map[String, Any]) extends Logging {
override def toString(): String = map.toString
}
object Config {
object Config extends Logging {
val global = new Config
def valueToMap(input: Any): Map[String, Any] = {
input match {
case m: Map[_, _] => return m.asInstanceOf[Map[String, Any]]
......@@ -197,4 +199,28 @@ object Config {
return None
}
}
def mapToJson(map: Map[String, Any]): Json = {
map.foldLeft(jEmptyObject)((acc, kv) => (kv._1 := {
kv._2 match {
case m: Map[_, _] => mapToJson(m.map(m => m._1.toString -> anyToJson(m._2)))
case _ => anyToJson(kv._2)
}
}) ->: acc)
}
def anyToJson(any: Any): Json = {
any match {
case j: Json => j
case m: Map[_, _] => mapToJson(m.map(m => m._1.toString -> anyToJson(m._2)))
case l: List[_] => Json.array(l.map(anyToJson(_)): _*)
case n: Int => Json.jNumberOrString(n)
case n: Double => Json.jNumberOrString(n)
case n: Long => Json.jNumberOrString(n)
case n: Short => Json.jNumberOrString(n)
case n: Float => Json.jNumberOrString(n)
case n: Byte => Json.jNumberOrString(n)
case _ => jString(any.toString)
}
}
}
\ No newline at end of file
......@@ -6,16 +6,16 @@ import scala.language.implicitConversions
trait Configurable extends Logging {
val root: Configurable
val globalConfig: Config = if (root != null) root.globalConfig else new Config()
//val globalConfig: Config = if (root != null) root.globalConfig else new Config()
def configPath: List[String] = if (root != null) root.configFullPath else List()
protected lazy val configName = getClass.getSimpleName.toLowerCase
protected lazy val configFullPath = configName :: configPath
var defaults: scala.collection.mutable.Map[String, Any] = if (root != null) scala.collection.mutable.Map(root.defaults.toArray: _*)
else scala.collection.mutable.Map()
val config = new ConfigFuntions
val config = new ConfigFunctions
protected class ConfigFuntions {
protected class ConfigFunctions {
def apply(key: String, default: Any = null, submodule: String = null, required: Boolean = false, freeVar: Boolean = true): ConfigValue = {
val m = if (submodule != null) submodule else configName
val p = if (submodule != null) configName :: configPath else configPath
......@@ -29,15 +29,15 @@ trait Configurable extends Logging {
throw new IllegalStateException("Value in config could not be found but it is required, key: " + key + " module: " + m + " path: " + p)
} else return null
}
if (d == null) return globalConfig(m, p, key, freeVar)
else return globalConfig(m, p, key, d, freeVar)
if (d == null) return Config.global(m, p, key, freeVar)
else return Config.global(m, p, key, d, freeVar)
}
def contains(key: String, submodule: String = null, freeVar: Boolean = true) = {
val m = if (submodule != null) submodule else configName
val p = if (submodule != null) configName :: configPath else configPath
globalConfig.contains(m, p, key, freeVar) || !(Config.getValueFromMap(defaults.toMap, ConfigValueIndex(m, p, key, freeVar)) == None)
Config.global.contains(m, p, key, freeVar) || !(Config.getValueFromMap(defaults.toMap, ConfigValueIndex(m, p, key, freeVar)) == None)
}
}
......
......@@ -7,9 +7,9 @@ import java.io.File
class Raxml(val root: Configurable) extends BiopetCommandLineFunction {
override val defaultThreads = 4
override val defaultThreads = 1
override def versionCommand = executable + " -v"
override val versionRegex = """.*version \w* .*""".r
override val versionRegex = """.*version ([\w\.]*) .*""".r
@Input(doc = "Input phy/fasta file", required = true)
var input: File = _
......@@ -32,8 +32,8 @@ class Raxml(val root: Configurable) extends BiopetCommandLineFunction {
@Argument(doc = "Name of output files", required = true)
var f: String = "d"
@Argument(doc = "Output directory", required = false)
var w: String = jobLocalDir.getAbsolutePath
@Argument(doc = "Output directory", required = true)
var w: String = _
@Input(required = false)
var t: File = _
......@@ -44,18 +44,35 @@ class Raxml(val root: Configurable) extends BiopetCommandLineFunction {
@Output(doc = "Output files", required = false)
private var out: List[File] = Nil
executable = config("exe", default = "raxmlHPC")
var executableNonThreads: String = config("exe", default = "raxmlHPC")
var executableThreads: String = config("exe_pthreads")
override def afterGraph {
if (threads == 0) threads = getThreads(defaultThreads)
executable = if (threads > 1 && executableThreads != null) executableThreads else executableNonThreads
super.afterGraph
out +:= getInfoFile
f match {
case "d" if b.isEmpty => out +:= getBestTree
case "d" if b.isDefined => out +:= getBootstrap
case "d" if b.isEmpty => {
out +:= getBestTreeFile
for (t <- 0 until N.getOrElse(1)) {
out +:= new File(w + File.separator + "RAxML_log." + n + ".RUN." + t)
out +:= new File(w + File.separator + "RAxML_parsimonyTree." + n + ".RUN." + t)
out +:= new File(w + File.separator + "RAxML_result." + n + ".RUN." + t)
}
}
case "d" if b.isDefined => out +:= getBootstrapFile
case "b" => {
out +:= new File(w + File.separator + "RAxML_bipartitionsBranchLabels." + n)
out +:= new File(w + File.separator + "RAxML_bipartitions." + n)
}
case _ =>
}
}
def getBestTree: File = new File(w + File.separator + "RAxML_bestTree." + n)
def getBootstrap: File = new File(w + File.separator + "RAxML_bootstrap." + n)
def getBestTreeFile: File = new File(w + File.separator + "RAxML_bestTree." + n)
def getBootstrapFile: File = new File(w + File.separator + "RAxML_bootstrap." + n)
def getInfoFile: File = new File(w + File.separator + "RAxML_info." + n)
def cmdLine = required(executable) +
required("-m", m) +
......@@ -63,9 +80,10 @@ class Raxml(val root: Configurable) extends BiopetCommandLineFunction {
optional("-p", p) +
optional("-b", b) +
optional("-N", N) +
optional("-n", n) +
optional("-w", w) +
optional("-f", f) +
optional("-t", t) +
optional("-z", z) +
(if (threads > 1) required("-T", threads) else "")
}
\ No newline at end of file
required("-T", threads)
}
......@@ -6,6 +6,8 @@ import org.broadinstitute.gatk.queue.extensions.gatk.CommandLineGATK
trait GatkGeneral extends CommandLineGATK with BiopetJavaCommandLineFunction {
memoryLimit = Option(3)
if (config.contains("gatk_jar")) jarFile = config("gatk_jar")
override val defaultVmem = "7G"
if (config.contains("intervals", submodule = "gatk")) intervals = config("intervals", submodule = "gatk").getFileList
......
......@@ -11,7 +11,7 @@ class HaplotypeCaller(val root: Configurable) extends org.broadinstitute.gatk.qu
if (config.contains("scattercount")) scatterCount = config("scattercount")
if (config.contains("dbsnp")) this.dbsnp = config("dbsnp")
this.sample_ploidy = config("ploidy")
nct = config("threads", default = 3)
nct = config("threads", default = 1)
bamOutput = config("bamOutput")
memoryLimit = Option(nct.getOrElse(1) * 2)
if (config.contains("allSitePLs")) this.allSitePLs = config("allSitePLs")
......
......@@ -10,7 +10,7 @@ class UnifiedGenotyper(val root: Configurable) extends org.broadinstitute.gatk.q
if (config.contains("scattercount")) scatterCount = config("scattercount")
if (config.contains("dbsnp")) this.dbsnp = config("dbsnp")
this.sample_ploidy = config("ploidy")
nct = config("threads", default = 3)
nct = config("threads", default = 1)
memoryLimit = Option(nct.getOrElse(1) * 2)
if (config.contains("allSitePLs")) this.allSitePLs = config("allSitePLs")
if (config.contains("output_mode")) {
......
......@@ -26,7 +26,6 @@ class BamMetrics(val root: Configurable) extends QScript with BiopetQScript {
var wholeGenome = false
def init() {
for (file <- configfiles) globalConfig.loadConfigFile(file)
if (outputDir == null) throw new IllegalStateException("Missing Output directory on BamMetrics module")
else if (!outputDir.endsWith("/")) outputDir += "/"
if (config.contains("target_bed")) {
......
package nl.lumc.sasc.biopet.pipelines.basty
import java.io.File
import nl.lumc.sasc.biopet.core.MultiSampleQScript
import nl.lumc.sasc.biopet.core.PipelineCommand
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.Cat
import nl.lumc.sasc.biopet.extensions.Raxml
import nl.lumc.sasc.biopet.pipelines.gatk.GatkPipeline
import nl.lumc.sasc.biopet.tools.BastyGenerateFasta
import org.broadinstitute.gatk.queue.QScript
class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
......@@ -12,15 +16,18 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
class LibraryOutput extends AbstractLibraryOutput {
}
case class FastaOutput(variants: File, consensus: File, consensusVariants: File)
class SampleOutput extends AbstractSampleOutput {
var output: FastaOutput = _
var outputSnps: FastaOutput = _
}
defaults ++= Map("ploidy" -> 1, "use_haplotypecaller" -> false, "use_unifiedgenotyper" -> true)
defaults ++= Map("ploidy" -> 1, "use_haplotypecaller" -> false, "use_unifiedgenotyper" -> true, "joint_variantcalling" -> true)
var gatkPipeline: GatkPipeline = _
var gatkPipeline: GatkPipeline = new GatkPipeline(this)
gatkPipeline.jointVariantcalling = true
def init() {
gatkPipeline = new GatkPipeline(this)
gatkPipeline.outputDir = outputDir
gatkPipeline.init
}
......@@ -29,17 +36,82 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
gatkPipeline.biopetScript
addAll(gatkPipeline.functions)
val refVariants = addGenerateFasta(null, outputDir + "reference/", outputName = "reference")
val refVariantSnps = addGenerateFasta(null, outputDir + "reference/", outputName = "reference", snpsOnly = true)
runSamplesJobs()
val catVariants = Cat(this, refVariants.variants :: samplesOutput.map(_._2.output.variants).toList, outputDir + "fastas/variant.fasta")
add(catVariants)
val catVariantsSnps = Cat(this, refVariantSnps.variants :: samplesOutput.map(_._2.outputSnps.variants).toList, outputDir + "fastas/variant.snps_only.fasta")
add(catVariantsSnps)
val catConsensus = Cat(this, refVariants.consensus :: samplesOutput.map(_._2.output.consensus).toList, outputDir + "fastas/consensus.fasta")
add(catConsensus)
val catConsensusSnps = Cat(this, refVariantSnps.consensus :: samplesOutput.map(_._2.outputSnps.consensus).toList, outputDir + "fastas/consensus.snps_only.fasta")
add(catConsensusSnps)
val catConsensusVariants = Cat(this, refVariants.consensusVariants :: samplesOutput.map(_._2.output.consensusVariants).toList, outputDir + "fastas/consensus.variant.fasta")
add(catConsensusVariants)
val catConsensusVariantsSnps = Cat(this, refVariantSnps.consensusVariants :: samplesOutput.map(_._2.outputSnps.consensusVariants).toList, outputDir + "fastas/consensus.variant.snps_only.fasta")
add(catConsensusVariantsSnps)
val seed: Int = config("seed", default = 12345)
def addRaxml(input: File, outputDir: String, outputName: String) {
val raxmlMl = new Raxml(this)
raxmlMl.input = input
raxmlMl.m = config("raxml_ml_model", default = "GTRGAMMAX")
raxmlMl.p = seed
raxmlMl.n = outputName + "_ml"
raxmlMl.w = outputDir
raxmlMl.N = config("ml_runs", default = 20, submodule = "raxml")
add(raxmlMl)
val r = new scala.util.Random(seed)
val numBoot = config("boot_runs", default = 100, submodule = "raxml").getInt
val bootList = for (t <- 0 until numBoot) yield {
val raxmlBoot = new Raxml(this)
raxmlBoot.threads = 1
raxmlBoot.input = input
raxmlBoot.m = config("raxml_ml_model", default = "GTRGAMMAX")
raxmlBoot.p = seed
raxmlBoot.b = math.abs(r.nextInt)
raxmlBoot.w = outputDir
raxmlBoot.N = 1
raxmlBoot.n = outputName + "_boot_" + t
add(raxmlBoot)
raxmlBoot.getBootstrapFile
}
val cat = Cat(this, bootList.toList, outputDir + "/boot_list")
add(cat)
val raxmlBi = new Raxml(this)
raxmlBi.input = input
raxmlBi.t = raxmlMl.getBestTreeFile
raxmlBi.z = cat.output
raxmlBi.m = config("raxml_ml_model", default = "GTRGAMMAX")
raxmlBi.p = seed
raxmlBi.f = "b"
raxmlBi.n = outputName + "_bi"
raxmlBi.w = outputDir
add(raxmlBi)
}
addRaxml(catVariantsSnps.output, outputDir + "raxml", "snps")
}
// Called for each sample
def runSingleSampleJobs(sampleConfig: Map[String, Any]): SampleOutput = {
val sampleOutput = new SampleOutput
val sampleID: String = sampleConfig("ID").toString
val sampleDir = globalSampleDir + sampleID
val sampleDir = globalSampleDir + sampleID + "/"
sampleOutput.libraries = runLibraryJobs(sampleConfig)
sampleOutput.output = addGenerateFasta(sampleID, sampleDir)
sampleOutput.outputSnps = addGenerateFasta(sampleID, sampleDir, snpsOnly = true)
return sampleOutput
}
......@@ -53,6 +125,23 @@ class Basty(val root: Configurable) extends QScript with MultiSampleQScript {
return libraryOutput
}
def addGenerateFasta(sampleName: String, outputDir: String, outputName: String = null,
snpsOnly: Boolean = false): FastaOutput = {
val bastyGenerateFasta = new BastyGenerateFasta(this)
bastyGenerateFasta.outputName = if (outputName != null) outputName else sampleName
bastyGenerateFasta.inputVcf = gatkPipeline.multisampleVariantcalling.scriptOutput.finalVcfFile
if (gatkPipeline.samplesOutput.contains(sampleName)) {
bastyGenerateFasta.bamFile = gatkPipeline.samplesOutput(sampleName).variantcalling.bamFiles.head
}
bastyGenerateFasta.outputVariants = outputDir + bastyGenerateFasta.outputName + ".variants" + (if (snpsOnly) ".snps_only" else "") + ".fasta"
bastyGenerateFasta.outputConsensus = outputDir + bastyGenerateFasta.outputName + ".consensus" + (if (snpsOnly) ".snps_only" else "") + ".fasta"
bastyGenerateFasta.outputConsensusVariants = outputDir + bastyGenerateFasta.outputName + ".consensus_variants" + (if (snpsOnly) ".snps_only" else "") + ".fasta"
bastyGenerateFasta.sampleName = sampleName
bastyGenerateFasta.snpsOnly = snpsOnly
add(bastyGenerateFasta)
return FastaOutput(bastyGenerateFasta.outputVariants, bastyGenerateFasta.outputConsensus, bastyGenerateFasta.outputConsensusVariants)
}
}
object Basty extends PipelineCommand
......@@ -18,10 +18,10 @@ class Flexiprep(val root: Configurable) extends QScript with BiopetQScript {
var input_R2: File = _
@Argument(doc = "Skip Trim fastq files", shortName = "skiptrim", required = false)
var skipTrim: Boolean = false
var skipTrim: Boolean = config("skiptrim", default = false)
@Argument(doc = "Skip Clip fastq files", shortName = "skipclip", required = false)