Commit 92c23be4 authored by Sander Bollen's avatar Sander Bollen
Browse files

consistency of naming conventions (using VCF names of fields) and spelling

parent c7dddadd
...@@ -28,7 +28,7 @@ class VcfToTsv { ...@@ -28,7 +28,7 @@ class VcfToTsv {
object VcfToTsv extends ToolCommand { object VcfToTsv extends ToolCommand {
case class Args(inputFile: File = null, outputFile: File = null, fields: List[String] = Nil, infoFields: List[String] = Nil, case class Args(inputFile: File = null, outputFile: File = null, fields: List[String] = Nil, infoFields: List[String] = Nil,
sampleFileds: List[String] = Nil, disableDefaults: Boolean = false, sampleFields: List[String] = Nil, disableDefaults: Boolean = false,
allInfo: Boolean = false, allFormat: Boolean = false) extends AbstractArgs allInfo: Boolean = false, allFormat: Boolean = false) extends AbstractArgs
class OptParser extends AbstractOptParser { class OptParser extends AbstractOptParser {
...@@ -51,7 +51,7 @@ object VcfToTsv extends ToolCommand { ...@@ -51,7 +51,7 @@ object VcfToTsv extends ToolCommand {
c.copy(allFormat = true) c.copy(allFormat = true)
} }
opt[String]('s', "sample_field") unbounded () action { (x, c) => opt[String]('s', "sample_field") unbounded () action { (x, c) =>
c.copy(sampleFileds = x :: c.sampleFileds) c.copy(sampleFields = x :: c.sampleFields)
} }
opt[Unit]('d', "disable_defaults") unbounded () action { (x, c) => opt[Unit]('d', "disable_defaults") unbounded () action { (x, c) =>
c.copy(disableDefaults = true) c.copy(disableDefaults = true)
...@@ -75,7 +75,7 @@ object VcfToTsv extends ToolCommand { ...@@ -75,7 +75,7 @@ object VcfToTsv extends ToolCommand {
commandArgs.fields.toSet[String] ++ commandArgs.fields.toSet[String] ++
(if (commandArgs.allInfo) allInfoFields else commandArgs.infoFields).map("INFO-" + _) ++ { (if (commandArgs.allInfo) allInfoFields else commandArgs.infoFields).map("INFO-" + _) ++ {
val buffer: ListBuffer[String] = ListBuffer() val buffer: ListBuffer[String] = ListBuffer()
for (f <- (if (commandArgs.allFormat) allFormatFields else commandArgs.sampleFileds); sample <- samples) { for (f <- (if (commandArgs.allFormat) allFormatFields else commandArgs.sampleFields); sample <- samples) {
buffer += sample + "-" + f buffer += sample + "-" + f
} }
buffer.toSet[String] buffer.toSet[String]
...@@ -102,16 +102,16 @@ object VcfToTsv extends ToolCommand { ...@@ -102,16 +102,16 @@ object VcfToTsv extends ToolCommand {
witter.println(sortedFields.mkString("#", "\t", "")) witter.println(sortedFields.mkString("#", "\t", ""))
for (vcfRecord <- reader) { for (vcfRecord <- reader) {
val values: Map[String, Any] = Map() val values: Map[String, Any] = Map()
values += "chr" -> vcfRecord.getChr values += "CHROM" -> vcfRecord.getChr
values += "pos" -> vcfRecord.getStart values += "POS" -> vcfRecord.getStart
values += "id" -> vcfRecord.getID values += "ID" -> vcfRecord.getID
values += "ref" -> vcfRecord.getReference.getBaseString values += "REF" -> vcfRecord.getReference.getBaseString
values += "alt" -> { values += "ALT" -> {
val t = for (a <- vcfRecord.getAlternateAlleles) yield a.getBaseString val t = for (a <- vcfRecord.getAlternateAlleles) yield a.getBaseString
t.mkString(",") t.mkString(",")
} }
values += "qual" -> (if (vcfRecord.getPhredScaledQual == -10) "." else scala.math.round(vcfRecord.getPhredScaledQual * 100.0) / 100.0) values += "QUAL" -> (if (vcfRecord.getPhredScaledQual == -10) "." else scala.math.round(vcfRecord.getPhredScaledQual * 100.0) / 100.0)
values += "filter" -> vcfRecord.getFilters values += "INFO" -> vcfRecord.getFilters
for ((field, content) <- vcfRecord.getAttributes) { for ((field, content) <- vcfRecord.getAttributes) {
values += "INFO-" + field -> { values += "INFO-" + field -> {
content match { content match {
...@@ -129,10 +129,10 @@ object VcfToTsv extends ToolCommand { ...@@ -129,10 +129,10 @@ object VcfToTsv extends ToolCommand {
val l = for (g <- genotype.getAlleles) yield vcfRecord.getAlleleIndex(g) val l = for (g <- genotype.getAlleles) yield vcfRecord.getAlleleIndex(g)
l.map(x => if (x < 0) "." else x).mkString("/") l.map(x => if (x < 0) "." else x).mkString("/")
} }
if (genotype.hasAD) values += sample + "-AD" -> List(genotype.getAD: _*).mkString(",") if (genotype.hasAD) values += "AD-" + sample -> List(genotype.getAD: _*).mkString(",")
if (genotype.hasDP) values += sample + "-DP" -> genotype.getDP if (genotype.hasDP) values += "DP-" + sample -> genotype.getDP
if (genotype.hasGQ) values += sample + "-GQ" -> genotype.getGQ if (genotype.hasGQ) values += "GQ-" + sample -> genotype.getGQ
if (genotype.hasPL) values += sample + "-PL" -> List(genotype.getPL: _*).mkString(",") if (genotype.hasPL) values += "PL-" + sample -> List(genotype.getPL: _*).mkString(",")
for ((field, content) <- genotype.getExtendedAttributes) { for ((field, content) <- genotype.getExtendedAttributes) {
values += sample + "-" + field -> content values += sample + "-" + field -> content
} }
......
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