forked from UMCUGenetics/GATK-QScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndelRealigner.scala
87 lines (70 loc) · 3 KB
/
IndelRealigner.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.broadinstitute.sting.queue.qscripts
import org.broadinstitute.sting.queue.QScript
import org.broadinstitute.sting.queue.extensions.gatk._
import org.broadinstitute.sting.queue.function.ListWriterFunction
class Realigner extends QScript {
// Create an alias 'qscript' to be able to access variables in the Realigner.
// 'qscript' is now the same as 'Realigner.this'
qscript =>
// Required arguments. All initialized to empty values.
@Input(doc="The reference file for the bam files.", shortName="R", required=true)
var referenceFile: File = _
@Input(doc="One or more bam files.", shortName="I",required=true)
var bamFiles: List[File] = Nil
@Argument(doc="Maxmem.", shortName="mem", required=true)
var maxMem: Int = _
@Argument(doc="Number of data threads", shortName="nt", required=true)
var numDataThreads: Int = _
@Argument(doc="Number of scatters", shortName="nsc", required=true)
var numScatters: Int = _
@Argument(doc="Realign mode: single or multi sample.", shortName="mode", required=true)
var realignMode: String = _
// Optional arguments
@Input(doc ="Input VCF file with known indels.", shortName="known", required=false)
var knownIndelFiles: List[File] = Nil
// This trait allows us set the variables below in one place,
// and then reuse this trait on each CommandLineGATK function below.
trait TCIR_Arguments extends CommandLineGATK {
this.reference_sequence = qscript.referenceFile
this.memoryLimit = maxMem
}
def script() {
if (realignMode == "multi") {
val targetCreator = new RealignerTargetCreator with TCIR_Arguments
val indelRealigner = new IndelRealigner with TCIR_Arguments
//Target creator
targetCreator.input_file = bamFiles
if(knownIndelFiles != Nil){
targetCreator.known = knownIndelFiles
}
targetCreator.num_threads = numDataThreads
targetCreator.scatterCount = numScatters
targetCreator.out = new File("target.intervals.list")
//Indel realigner
indelRealigner.targetIntervals = targetCreator.out
indelRealigner.input_file = bamFiles
indelRealigner.scatterCount = numScatters
indelRealigner.nWayOut = "_realigned.bam"
add(targetCreator,indelRealigner)
} else if (realignMode == "single") {
for (bamFile <- bamFiles) {
val targetCreator = new RealignerTargetCreator with TCIR_Arguments
val indelRealigner = new IndelRealigner with TCIR_Arguments
//Target Creator
targetCreator.input_file :+= bamFile
if(knownIndelFiles != Nil){
targetCreator.known = knownIndelFiles
}
targetCreator.num_threads = numDataThreads
targetCreator.scatterCount = numScatters
targetCreator.out = swapExt(bamFile, "bam", "target.intervals.list")
//Indel realigner
indelRealigner.targetIntervals = targetCreator.out
indelRealigner.input_file +:= bamFile
indelRealigner.scatterCount = numScatters
indelRealigner.out = swapExt(bamFile, "bam", "realigned.bam")
add(targetCreator, indelRealigner)
}
}
}
}