Commit 6b55bbde authored by Wai Yi Leung's avatar Wai Yi Leung

Adding CleverFixVCF to add headers and fix the samplename in vcf output

parent a4c98adb
......@@ -30,13 +30,13 @@ class BreakdancerVCF(val root: Configurable) extends PythonCommandLineFunction {
@Output(doc = "Output VCF to PATH")
var output: File = _
@Argument(doc="Samplename")
@Argument(doc = "Samplename")
var sample: String = _
def cmdLine = {
getPythonCommand +
"-i " + required(input) +
"-o " + required(output)+
"-o " + required(output) +
"-s " + required(sample)
}
}
......
......@@ -17,9 +17,9 @@ package nl.lumc.sasc.biopet.extensions.clever
import java.io.File
import nl.lumc.sasc.biopet.core.{ Version, Reference, BiopetCommandLineFunction }
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, Reference, Version }
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction with Reference with Version {
executable = config("exe", default = "clever")
......@@ -39,17 +39,17 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction wit
@Input(doc = "Reference")
var reference: File = _
protected def workDir: File = new File(cwd, "work")
var cwd: File = _
protected def cleverOutputDir: File = new File(cleverWorkDir, "work")
var cleverWorkDir: File = _
@Output(doc = "Clever VCF output")
lazy val outputvcf: File = {
new File(cwd, "predictions.vcf")
new File(cleverOutputDir, "predictions.vcf")
}
@Output(doc = "Clever raw output")
lazy val outputraw: File = {
new File(workDir, "predictions.raw.txt")
new File(cleverOutputDir, "predictions.raw.txt")
}
// var T: Option[Int] = config("T", default = defaultThreads)
......@@ -61,7 +61,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction wit
override def beforeGraph() {
super.beforeGraph()
if (workDir == null) throw new Exception("Clever :: Workdirectory is not defined")
if (cleverOutputDir == null) throw new Exception("Clever :: Workdirectory is not defined")
if (reference == null) reference = referenceFasta()
}
......@@ -75,14 +75,14 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction wit
conditional(r, "-r") +
required(input) +
required(reference) +
required(workDir)
required(cleverOutputDir)
}
object CleverCaller {
def apply(root: Configurable, input: File, svDir: File): CleverCaller = {
val clever = new CleverCaller(root)
clever.input = input
clever.cwd = svDir
clever.cleverWorkDir = svDir
clever
}
}
\ No newline at end of file
package nl.lumc.sasc.biopet.extensions.clever
/**
* Created by wyleung on 4-4-16.
*/
import java.io.{ File, PrintWriter }
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.{ ToolCommand }
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
import scala.io.Source
class CleverFixVCF(val root: Configurable) extends BiopetJavaCommandLineFunction {
javaMainClass = getClass.getName
@Input(doc = "Input Clever VCF")
var input: File = _
@Output(doc = "Output fixed VCF")
var output: File = _
@Argument(doc = "Samplename")
var sampleName: String = _
override def cmdLine = super.cmdLine +
required("-i", input) +
required("-o", output) +
required("-s", sampleName)
}
object CleverFixVCF extends ToolCommand {
case class Args(inputVCF: File = null, sampleLabel: String = "",
outputVCF: File = null) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('i', "inputvcf") required () valueName "<vcffile/path>" action { (x, c) =>
c.copy(inputVCF = x)
} text "Please specify the input Clever VCF file"
opt[String]('s', "samplelabel") valueName "<sample label>" action { (x, c) =>
c.copy(sampleLabel = x)
} text "Sample label is missing"
opt[File]('o', "outputvcf") valueName "<output>" action { (x, c) =>
c.copy(outputVCF = x)
} text "Output path is missing"
}
/**
* @param args the command line arguments
*/
def main(args: Array[String]): Unit = {
val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1)
val input: File = commandArgs.inputVCF
val output: File = commandArgs.outputVCF
val vcfColHeader = "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tdefault"
val vcfColReplacementHeader = s"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\t${commandArgs.sampleLabel}"
val extraHeader = """##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency">
##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation">
##INFO=<ID=NOVEL,Number=0,Type=Flag,Description="Indicates a novel structural variation">
##INFO=<ID=SVEND,Number=1,Type=Integer,Description="End position of the variant described in this record">
##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the variant described in this record">
##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant">
##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles">
##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants">
##INFO=<ID=CIEND,Number=2,Type=Integer,Description="Confidence interval around END for imprecise variants">
##INFO=<ID=HOMLEN,Number=.,Type=Integer,Description="Length of base pair identical micro-homology at event breakpoints">
##INFO=<ID=HOMSEQ,Number=.,Type=String,Description="Sequence of base pair identical micro-homology at event breakpoints">
##INFO=<ID=BKPTID,Number=.,Type=String,Description="ID of the assembled alternate allele in the assembly file">
##INFO=<ID=MEINFO,Number=4,Type=String,Description="Mobile element info of the form NAME,START,END,POLARITY">
##INFO=<ID=METRANS,Number=4,Type=String,Description="Mobile element transduction info of the form CHR,START,END,POLARITY">
##INFO=<ID=DGVID,Number=1,Type=String,Description="ID of this element in Database of Genomic Variation">
##INFO=<ID=DBVARID,Number=1,Type=String,Description="ID of this element in DBVAR">
##INFO=<ID=DBRIPID,Number=1,Type=String,Description="ID of this element in DBRIP">
##INFO=<ID=MATEID,Number=.,Type=String,Description="ID of mate breakends">
##INFO=<ID=PARID,Number=1,Type=String,Description="ID of partner breakend">
##INFO=<ID=EVENT,Number=1,Type=String,Description="ID of event associated to breakend">
##INFO=<ID=CILEN,Number=2,Type=Integer,Description="Confidence interval around the inserted material between breakends">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Read Depth of segment containing breakend">
##INFO=<ID=DPADJ,Number=.,Type=Integer,Description="Read Depth of adjacency">
##INFO=<ID=CN,Number=1,Type=Integer,Description="Copy number of segment containing breakend">
##INFO=<ID=CNADJ,Number=.,Type=Integer,Description="Copy number of adjacency">
##INFO=<ID=CICN,Number=2,Type=Integer,Description="Confidence interval around copy number for the segment">
##INFO=<ID=CICNADJ,Number=.,Type=Integer,Description="Confidence interval around copy number for the adjacency">
##FORMAT=<ID=CN,Number=1,Type=Integer,Description="Copy number genotype for imprecise events">
##FORMAT=<ID=CNQ,Number=1,Type=Float,Description="Copy number genotype quality for imprecise events">
##FORMAT=<ID=CNL,Number=.,Type=Float,Description="Copy number genotype likelihood for imprecise events">
##FORMAT=<ID=NQ,Number=1,Type=Integer,Description="Phred style probability score that the variant is novel">
##FORMAT=<ID=HAP,Number=1,Type=Integer,Description="Unique haplotype identifier">
##FORMAT=<ID=AHAP,Number=1,Type=Integer,Description="Unique identifier of ancestral haplotype">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth">"""
val inputVCF = Source.fromFile(input)
val writer = new PrintWriter(output)
for (line <- inputVCF.getLines()) {
(line == vcfColHeader) match {
case true => {
writer.write(extraHeader+"\n")
writer.write(vcfColReplacementHeader + "\n")
}
case _ => writer.write(line + "\n")
}
}
writer.close()
inputVCF.close()
}
}
......@@ -32,7 +32,7 @@ class Breakdancer(val root: Configurable) extends SvCaller {
val bdcfg = BreakdancerConfig(this, bamFile, new File(breakdancerSampleDir, sample + ".breakdancer.cfg"))
val breakdancer = BreakdancerCaller(this, bdcfg.output, new File(breakdancerSampleDir, sample + ".breakdancer.tsv"))
val bdvcf = BreakdancerVCF(this, breakdancer.output, new File(breakdancerSampleDir, sample + ".breakdancer.vcf"),
sample=sample)
sample = sample)
add(bdcfg, breakdancer, bdvcf)
addVCF(sample, bdvcf.output)
......
......@@ -15,7 +15,7 @@
*/
package nl.lumc.sasc.biopet.pipelines.shiva.svcallers
import nl.lumc.sasc.biopet.extensions.clever.CleverCaller
import nl.lumc.sasc.biopet.extensions.clever.{ CleverCaller, CleverFixVCF }
import nl.lumc.sasc.biopet.utils.config.Configurable
/** Script for sv caler Clever */
......@@ -29,7 +29,13 @@ class Clever(val root: Configurable) extends SvCaller {
val clever = CleverCaller(this, bamFile, cleverDir)
add(clever)
addVCF(sample, clever.outputvcf)
val cleverVCF = new CleverFixVCF(this)
cleverVCF.input = clever.outputvcf
cleverVCF.output = new File(cleverDir, s"${sample}.clever.vcf")
cleverVCF.sampleName = sample
add(cleverVCF)
addVCF(sample, cleverVCF.output)
}
}
}
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