Commit 8836885f authored by Sander Bollen's avatar Sander Bollen

Merge branch 'fix-BIOPET-477' into 'develop'

Fix BIOPET-477

This feature was required by a project

See merge request !485
parents ad393299 492dd1a0
......@@ -44,6 +44,7 @@ class MpileupToVcf(val root: Configurable) extends ToolCommandFunction with Refe
var minAP: Option[Int] = config("min_ap")
var homoFraction: Option[Double] = config("homoFraction")
var ploidy: Option[Int] = config("ploidy")
var refCalls: Boolean = config("ref_calls", default = false)
var sample: String = _
var reference: String = _
......@@ -72,6 +73,7 @@ class MpileupToVcf(val root: Configurable) extends ToolCommandFunction with Refe
optional("--minAP", minAP) +
optional("--homoFraction", homoFraction) +
optional("--ploidy", ploidy) +
conditional(refCalls, "--refCalls") +
required("--sample", sample) +
(if (inputAsStdin) "" else required("-I", inputMpileup))
}
......@@ -27,7 +27,7 @@ import scala.math.{ floor, round }
object MpileupToVcf extends ToolCommand {
case class Args(input: File = null, output: File = null, sample: String = null, minDP: Int = 8, minAP: Int = 2,
homoFraction: Double = 0.8, ploidy: Int = 2, seqError: Double = 0.005) extends AbstractArgs
homoFraction: Double = 0.8, ploidy: Int = 2, seqError: Double = 0.005, refCalls: Boolean = false) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('I', "input") valueName "<file>" action { (x, c) =>
......@@ -54,6 +54,9 @@ object MpileupToVcf extends ToolCommand {
opt[Double]("seqError") action { (x, c) =>
c.copy(seqError = x)
}
opt[Unit]("refCalls") action { (x, c) =>
c.copy(refCalls = true)
}
}
/**
......@@ -66,6 +69,7 @@ object MpileupToVcf extends ToolCommand {
val writer = new PrintWriter(commandArgs.output)
writer.println("##fileformat=VCFv4.1")
writer.println("##ALT=<ID=REF,Description=\"Placeholder if location has no ALT alleles\">")
writer.println("##INFO=<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">")
writer.println("##INFO=<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency, for each ALT allele, in the same order as listed\">")
writer.println("##FORMAT=<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">")
......@@ -172,7 +176,7 @@ object MpileupToVcf extends ToolCommand {
case _ =>
}
if (alt.nonEmpty) {
if (alt.nonEmpty || commandArgs.refCalls) {
val ad = for (ad <- format("AD").toString.split(",")) yield ad.toInt
var left = reads - dels
val gt = ArrayBuffer[Int]()
......@@ -187,11 +191,11 @@ object MpileupToVcf extends ToolCommand {
}
left -= ad(max)
}
writer.println(Array(chr, pos, ".", ref.toUpperCase, alt.mkString(","), ".", ".", info.mkString(";"),
writer.println(Array(chr, pos, ".", ref.toUpperCase, if (alt.nonEmpty) alt.mkString(",") else "<REF>", ".", ".", info.mkString(";"),
"GT:" + format.keys.mkString(":"), gt.sortWith(_ < _).mkString("/") + ":" + format.values.mkString(":")
).mkString("\t"))
}
}
writer.close()
}
}
\ 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