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

Change defaults when vcf has not a variant, added reference option

parent 57ad3610
......@@ -33,6 +33,7 @@ class BastyGenerateFasta(val root: Configurable) extends BiopetJavaCommandLineFu
override val defaultVmem = "8G"
memoryLimit = Option(4.0)
var reference = false
override def commandLine = super.commandLine +
optional("--inputVcf", inputVcf) +
......@@ -40,7 +41,8 @@ class BastyGenerateFasta(val root: Configurable) extends BiopetJavaCommandLineFu
optional("--outputVariants", outputVariants) +
conditional(snpsOnly, "--snpsOnly") +
optional("--sampleName", sampleName) +
optional("--minAD", minAD)
optional("--minAD", minAD) +
conditional(reference, "--reference")
}
object BastyGenerateFasta extends ToolCommand {
......@@ -49,7 +51,8 @@ object BastyGenerateFasta extends ToolCommand {
bamFile: File = null,
snpsOnly: Boolean = false,
sampleName: String = null,
minAD: Int = 8) extends AbstractArgs
minAD: Int = 8,
reference: Boolean = false) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('V', "inputVcf") unbounded () valueName ("<file>") action { (x, c) =>
......@@ -70,6 +73,9 @@ object BastyGenerateFasta extends ToolCommand {
opt[Int]("minAD") unbounded () action { (x, c) =>
c.copy(minAD = x)
}
opt[Unit]("reference") unbounded () action { (x, c) =>
c.copy(reference = true)
}
}
var commandArgs: Args = _
......@@ -103,10 +109,11 @@ object BastyGenerateFasta extends ToolCommand {
val maxSize = vcfRecord.getAlleles()(longestAlleleID).getBases.length
def fill(bases: String) = bases + (Array.fill[Char](maxSize - bases.size)('N')).mkString
if (commandArgs.reference) return fill(vcfRecord.getReference.getBaseString)
if (genotype == null) return fill(vcfRecord.getReference.getBaseString)
if (genotype == null) return fill("")
val AD = genotype.getAD
if (AD == null) return fill(vcfRecord.getReference.getBaseString)
if (AD == null) return fill("")
val maxADid = AD.zipWithIndex.maxBy(_._1)._2
if (AD(maxADid) < commandArgs.minAD) return fill("")
return fill(vcfRecord.getAlleles()(maxADid).getBaseString)
......
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