Star.scala 22.7 KB
Newer Older
1
/**
2
3
4
5
6
7
8
9
10
11
12
13
14
  * Biopet is built on top of GATK Queue for building bioinformatic
  * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
  * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
  * should also be able to execute Biopet tools and pipelines.
  *
  * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
  *
  * Contact us at: sasc@lumc.nl
  *
  * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
  * license; For commercial users or users who do not want to follow the AGPL
  * license, please contact us to obtain a separate license.
  */
15
16
17
package nl.lumc.sasc.biopet.extensions

import java.io.File
Peter van 't Hof's avatar
Peter van 't Hof committed
18

Peter van 't Hof's avatar
Peter van 't Hof committed
19
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
20
import nl.lumc.sasc.biopet.core.{BiopetCommandLineFunction, Reference, Version}
21
import org.broadinstitute.gatk.utils.commandline.{Argument, Input, Output}
Peter van 't Hof's avatar
Peter van 't Hof committed
22

Peter van 't Hof's avatar
Peter van 't Hof committed
23
24
import scala.util.matching.Regex

Peter van 't Hof's avatar
Peter van 't Hof committed
25
/**
26
27
28
29
30
31
  * Extension for STAR
  */
class Star(val parent: Configurable)
    extends BiopetCommandLineFunction
    with Reference
    with Version {
bow's avatar
bow committed
32
  @Input(doc = "The reference file for the bam files.", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
33
  var reference: File = _
bow's avatar
bow committed
34
35

  @Input(doc = "Fastq file R1", required = false)
36
  var R1: File = _
bow's avatar
bow committed
37
38

  @Input(doc = "Fastq file R2", required = false)
39
  var R2: File = _
bow's avatar
bow committed
40
41

  @Output(doc = "Output SAM file", required = false)
42
  var outputSam: File = _
bow's avatar
bow committed
43
44

  @Output(doc = "Output tab file", required = false)
45
  var outputTab: File = _
bow's avatar
bow committed
46

Peter van 't Hof's avatar
Peter van 't Hof committed
47
48
  @Input(doc = "sjdbFileChrStartEnd file", required = false)
  var sjdbFileChrStartEnd: List[File] = Nil
bow's avatar
bow committed
49
50

  @Output(doc = "Output genome file", required = false)
51
  var outputGenome: File = _
bow's avatar
bow committed
52
53

  @Output(doc = "Output SA file", required = false)
54
  var outputSA: File = _
bow's avatar
bow committed
55
56

  @Output(doc = "Output SAindex file", required = false)
57
  var outputSAindex: File = _
bow's avatar
bow committed
58

Peter van 't Hof's avatar
Peter van 't Hof committed
59
  executable = config("exe", "STAR")
bow's avatar
bow committed
60

Peter van 't Hof's avatar
Peter van 't Hof committed
61
62
  def versionCommand: String = executable + " --version"
  def versionRegex: Regex = """(.*)""".r
63

bow's avatar
bow committed
64
  @Argument(doc = "Output Directory")
Peter van 't Hof's avatar
Peter van 't Hof committed
65
  var outputDir: File = _
bow's avatar
bow committed
66

Peter van 't Hof's avatar
Peter van 't Hof committed
67
  var genomeDir: File = _
68
69
  var runmode: String = _
  var outFileNamePrefix: String = _
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
70
71
  var runThreadN: Option[Int] = config("runthreadn")

72
  var runDirPerm: Option[String] = config("rundirperm")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
73
  var runRNGseed: Option[Int] = config("runrngseed")
74
  var genomeLoad: Option[String] = config("genomeload")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
75

76
  var genomeFastaFiles: Option[String] = config("genomefastafiles")
77

Peter van 't Hof's avatar
Peter van 't Hof committed
78
  /** can be a list of strings **/
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
79
  var genomeChrBinNbits: Option[Int] = config("genomechrbinnbits")
Peter van 't Hof's avatar
Peter van 't Hof committed
80
  var genomeSAindexNbases: Option[Long] = config("genomesaindexnbases")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
81
82
  var genomeSAsparseD: Option[Int] = config("genomesasparsed")

pjvan_thof's avatar
pjvan_thof committed
83
  private def defaultGtf: Option[File] = config("annotation_gtf")
Peter van 't Hof's avatar
Peter van 't Hof committed
84
  @Input(required = false)
pjvan_thof's avatar
pjvan_thof committed
85
86
87
88
89
  var sjdbGTFfile: Option[File] = defaultGtf match {
    case Some(file) => config("sjdbgtfile", default = file)
    case _ => config("sjdbgtfile")
  }

90
91
92
93
  var sjdbGTFchrPrefix: Option[String] = config("sjdbgtfchrprefix")
  var sjdbGTFfeatureExon: Option[String] = config("sjdbgtffeatureexon")
  var sjdbGTFtagExonParentTranscript: Option[String] = config("sjdbgtftagexonparenttranscript")
  var sjdbGTFtagExonParentGene: Option[String] = config("sjdbgtftagexonparentgene")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
94
95
  var sjdbOverhang: Option[Int] = config("sjdboverhang")
  var sjdbScore: Option[Int] = config("sjdbscore")
96
  var sjdbInsertSave: Option[String] = config("sjdbinsertsave")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
97

98
  var readFilesCommand: Option[String] = config("readfilescommand")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
99
  var readMapNumber: Option[Int] = config("readmapnumber")
100
101
  var readMatesLengthsIn: Option[String] = config("readmateslengthsin")
  var readNameSeparator: Option[String] = config("readnameseparator")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
102
103
  var clip3pNbases: Option[Int] = config("clip3pnbases")
  var clip5pNbases: Option[Int] = config("clip5pnbases")
104
105
  var clip3pAdapterSeq: Option[String] = config("clip3adapterseq")
  var clip3pAdapterMMp: Option[String] = config("clip3adaptermmp")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
106
  var clip3pAfterAdapterNbases: Option[Int] = config("clip3afteradapternbases")
Peter van 't Hof's avatar
Peter van 't Hof committed
107
108
109
  var limitGenomeGenerateRAM: Option[Long] = config("limitgenomegenerateram")
  var limitIObufferSize: Option[Long] = config("limitiobuffersize")
  var limitOutSAMoneReadBytes: Option[Long] = config("limitoutsamonereadbytes")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
110
111
  var limitOutSJoneRead: Option[Int] = config("limitoutsjoneread")
  var limitOutSJcollapsed: Option[Int] = config("limitoutsjcollapsed")
Peter van 't Hof's avatar
Peter van 't Hof committed
112
  var limitBAMsortRAM: Option[Long] = config("limitbamsortram")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
113
114
  var limitSjdbInsertNsj: Option[Int] = config("limitsjdbinsertnsj")

115
116
117
  var outTmpDir: Option[String] = config("outtmpdir")
  var outStd: Option[String] = config("outstd")
  var outReadsUnmapped: Option[String] = config("outreadsunmapped")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
118
  var outQSconversionAdd: Option[Int] = config("outqsconversionadd")
119
120
121
122
123
  var outMultimapperOrder: Option[String] = config("outmultimapperorder")
  var outSAMtype: Option[String] = config("outsamtype")
  var outSAMmode: Option[String] = config("outsammode")
  var outSAMstrandField: Option[String] = config("outsamstrandfield")
  var outSAMattributes: Option[String] = config("outsamattributes")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
124
  var outSAMattrIHstart: Option[Int] = config("outsamattrihstart")
125
126
127
128
  var outSAMunmapped: Option[String] = config("outsamunmapped")
  var outSAMorder: Option[String] = config("outsamorder")
  var outSAMprimaryFlag: Option[String] = config("outsamprimaryflag")
  var outSAMreadID: Option[String] = config("outsamreadid")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
129
130
131
  var outSAMmapqUnique: Option[Int] = config("outsammapqunique")
  var outSAMflagOR: Option[Int] = config("outsamflagor")
  var outSAMflagAND: Option[Int] = config("outsamflagand")
132
133
134
135
136
  var outSAMattrRGline: Option[String] = config("outsamattrrgline")
  var outSAMheaderHD: Option[String] = config("outsamheaderhd")
  var outSAMheaderPG: Option[String] = config("outsamheaderpg")
  var outSAMheaderCommentFile: Option[String] = config("outsamheadercommentfile")
  var outSAMfilter: Option[String] = config("outsamfilter")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
137
138
139
  var outSAMmultNmax: Option[Int] = config("outsammultnmax")
  var outBAMcompression: Option[Int] = config("outbamcompression")
  var outBAMsortingThreadN: Option[Int] = config("outbamsortingthreadn")
140
  var bamRemoveDuplicatesType: Option[String] = config("bamremoveduplicatestype")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
141
142
  var bamRemoveDuplicatesMate2basesN: Option[Int] = config("bamremoveduplicatesmate2basesn")

143
144
145
146
147
  var outWigType: Option[String] = config("outwigtype")
  var outWigStrand: Option[String] = config("outwigstrand")
  var outWigReferencesPrefix: Option[String] = config("outwigreferencesprefix")
  var outWigNorm: Option[String] = config("outwignorm")
  var outFilterType: Option[String] = config("outfiltertype")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
148
149
150
151
152
153
154
155
156
  var outFilterMultimapScoreRange: Option[Int] = config("outfiltermultimapscorerange")
  var outFilterMultimapNmax: Option[Int] = config("outfiltermultimapnmax")
  var outFilterMismatchNmax: Option[Int] = config("outfiltermismatchnmax")
  var outFilterMismatchNoverLmax: Option[Int] = config("outfiltermismatchnoverlmax")
  var outFilterMismatchNoverReadLmax: Option[Int] = config("outfiltermismatchnoverreadlmax")
  var outFilterScoreMin: Option[Int] = config("outfilterscoremin")
  var outFilterScoreMinOverLread: Option[Float] = config("outfilterscoreminoverlread")
  var outFilterMatchNmin: Option[Int] = config("outfiltermatchnmin")
  var outFilterMatchNminOverLread: Option[Int] = config("outfiltermatchnminoverload")
157
  var outFilterIntronMotifs: Option[String] = config("outfilterintronmotifs")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
158

159
  var outSJfilterReads: Option[String] = config("outsjfilterreads")
Peter van 't Hof's avatar
Peter van 't Hof committed
160
161
162
  var outSJfilterOverhangMin: List[String] = config("outsjfilteroverhandmin", default = Nil)
  var outSJfilterCountUniqueMin: List[String] = config("outsjfiltercountuniquemin", default = Nil)
  var outSJfilterCountTotalMin: List[String] = config("outsjfiltercounttotalmin", default = Nil)
163
164
165
166
  var outSJfilterDistToOtherSJmin: List[String] =
    config("outsjfilterdisttoothersjmin", default = Nil)
  var outSJfilterIntronMaxVsReadN: List[String] =
    config("outsjfilterintronmaxvsreadn", default = Nil)
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

  var scoreGap: Option[Int] = config("scoregap")
  var scoreGapNoncan: Option[Int] = config("scoregapnoncan")
  var scoreGapGCAG: Option[Int] = config("scoregapgcag")
  var scoreGapATAC: Option[Int] = config("scoregapatac")
  var scoreGenomicLengthLog2scale: Option[Float] = config("scoregenomiclengthlog2scale")
  var scoreDelOpen: Option[Int] = config("scoredelopen")
  var scoreDelBase: Option[Int] = config("scoredelbase")
  var scoreInsOpen: Option[Int] = config("scoreinsopen")
  var scoreInsBase: Option[Int] = config("scoreinsbase")
  var scoreStitchSJshift: Option[Int] = config("scorestitchsjshift")

  var seedSearchStartLmax: Option[Int] = config("seedsearchstartlmax")
  var seedSearchStartLmaxOverLread: Option[Float] = config("seedsearchstartlmaxoverlread")
  var seedSearchLmax: Option[Int] = config("seedsearchlmax")
  var seedMultimapNmax: Option[Int] = config("seedmultimapnmax")
  var seedPerReadNmax: Option[Int] = config("seedperreadnmax")
  var seedPerWindowNmax: Option[Int] = config("seedperwindownmax")
  var seedNoneLociPerWindow: Option[Int] = config("seednonlociperwindow")
  var alignIntronMin: Option[Int] = config("alignintronmin")
  var alignIntronMax: Option[Int] = config("alignintronmax")
  var alignMatesGapMax: Option[Int] = config("alignmatesgapmax")
Peter van 't Hof's avatar
Peter van 't Hof committed
189
  var alignSJoverhangMin: Option[Int] = config("alignsjoverhangmin")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
190
191
192
193
194
195
196
  var alignSJstitchMismatchNmax: Option[Int] = config("alignsjstitchmismatchnmax")
  var alignSJDBoverhangMin: Option[Int] = config("alignsjdboverhangmin")
  var alignSplicedMateMapLmin: Option[Int] = config("alignsplicedmatemaplmin")
  var alignSplicedMateMapLminOverLmate: Option[Float] = config("alignsplicedmatemaplminoverlmate")
  var alignWindowsPerReadNmax: Option[Int] = config("alignwindowsperreadnmax")
  var alignTranscriptsPerWindowNmax: Option[Int] = config("aligntranscriptsperwindownmax")
  var alignTranscriptsPerReadNmax: Option[Int] = config("aligntranscriptsperreadnmax")
197
198
  var alignEndsType: Option[String] = config("alignendstype")
  var alignSoftClipAtReferenceEnds: Option[String] = config("alignsoftclipatreferenceends")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
199
200
201
202
203

  var winAnchorMultimapNmax: Option[Int] = config("winanchormultimapnmax")
  var winBinNbits: Option[Int] = config("winbinnbits")
  var winAnchorDistNbins: Option[Int] = config("winanchordistnbins")
  var winFlankNbins: Option[Int] = config("winflaknbins")
204
  var chimOutType: Option[String] = config("chimOutType")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
205
206
207
208
209
  var chimSegmentMin: Option[Int] = config("chimsegmentmin")
  var chimScoreMin: Option[Int] = config("chimscoremin")
  var chimScoreDropMax: Option[Int] = config("chimscoredropmax")
  var chimScoreSeparation: Option[Int] = config("chimscoreseparation")
  var chimScoreJunctionNonGTAG: Option[Int] = config("chimscorejunctionnongtag")
Peter van 't Hof's avatar
Peter van 't Hof committed
210
  var chimJunctionOverhangMin: Option[Int] = config("chimjunctionoverhangmin")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
211
  var chimSegmentReadGapMax: Option[Int] = config("chimsegmentreadgapmax")
212
  var chimFilter: Option[String] = config("chimfilter")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
213

214
  var quantMode: Option[String] = config("quantmode")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
215
  var quantTranscriptomeBAMcompression: Option[Int] = config("quanttranscriptomebamcompression")
216
  var quantTranscriptomeBan: Option[String] = config("quanttranscriptomebam")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
217

218
  var twopassMode: Option[String] = config("twopassmode")
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
219
220
  var twopass1readsN: Option[Int] = config("twopass1readsn")

Peter van 't Hof's avatar
Peter van 't Hof committed
221
  override def defaultCoreMemory = 6.0
Peter van 't Hof's avatar
Peter van 't Hof committed
222
  override def defaultThreads = 8
bow's avatar
bow committed
223

Peter van 't Hof's avatar
Peter van 't Hof committed
224
  /** Sets output files for the graph */
225
  override def beforeGraph() {
Peter van 't Hof's avatar
Peter van 't Hof committed
226
    super.beforeGraph()
227
    if (reference == null) reference = referenceFasta()
bow's avatar
bow committed
228
    if (outFileNamePrefix != null && !outFileNamePrefix.endsWith(".")) outFileNamePrefix += "."
229
230
231
    val prefix =
      if (outFileNamePrefix != null) outputDir + File.separator + outFileNamePrefix
      else outputDir + File.separator
Peter van 't Hof's avatar
Peter van 't Hof committed
232
    if (runmode == null) {
233
234
      outputSam = new File(prefix + "Aligned.out.sam")
      outputTab = new File(prefix + "SJ.out.tab")
Peter van 't Hof's avatar
Peter van 't Hof committed
235
      genomeDir = config("genomeDir", new File(reference.getAbsoluteFile.getParent, "star"))
Peter van 't Hof's avatar
Peter van 't Hof committed
236
237
    } else if (runmode == "genomeGenerate") {
      genomeDir = outputDir
238
239
240
      outputGenome = new File(prefix + "Genome")
      outputSA = new File(prefix + "SA")
      outputSAindex = new File(prefix + "SAindex")
Peter van 't Hof's avatar
Peter van 't Hof committed
241
      sjdbOverhang = config("sjdboverhang")
Peter van 't Hof's avatar
Peter van 't Hof committed
242
    }
243
  }
bow's avatar
bow committed
244

Peter van 't Hof's avatar
Peter van 't Hof committed
245
  /** Returns command to execute */
Peter van 't Hof's avatar
Peter van 't Hof committed
246
  def cmdLine: String = {
Peter van 't Hof's avatar
Peter van 't Hof committed
247
    var cmd: String = required("cd", outputDir) + " && " + required(executable)
Peter van 't Hof's avatar
Peter van 't Hof committed
248
    if (runmode != null && runmode == "genomeGenerate") { // Create index
Peter van 't Hof's avatar
Peter van 't Hof committed
249
      cmd += required("--runMode", runmode) +
250
        required("--genomeFastaFiles", reference)
Peter van 't Hof's avatar
Peter van 't Hof committed
251
    } else { // Aligner
Peter van 't Hof's avatar
Peter van 't Hof committed
252
      cmd += required("--readFilesIn", R1) + optional(R2)
Peter van 't Hof's avatar
Peter van 't Hof committed
253
    }
Peter van 't Hof's avatar
Peter van 't Hof committed
254
    cmd += required("--genomeDir", genomeDir) +
Peter van 't Hof's avatar
Peter van 't Hof committed
255
      multiArg("--sjdbFileChrStartEnd", sjdbFileChrStartEnd) +
256
      optional("--runThreadN", threads) +
Peter van 't Hof's avatar
Peter van 't Hof committed
257
      optional("--outFileNamePrefix", outFileNamePrefix) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
258
      optional("--sjdbOverhang", sjdbOverhang) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
      optional("--runDirPerm", runDirPerm) +
      optional("--genomeFastaFiles", genomeFastaFiles) +
      optional("--genomeChrBinNbits", genomeChrBinNbits) +
      optional("--genomeSAindexNbases", genomeSAindexNbases) +
      optional("--genomeSAsparseD", genomeSAsparseD) +
      optional("--sjdbGTFfile", sjdbGTFfile) +
      optional("--sjdbGTFchrPrefix", sjdbGTFchrPrefix) +
      optional("--sjdbGTFfeatureExon", sjdbGTFfeatureExon) +
      optional("--sjdbGTFtagExonParentTranscript", sjdbGTFtagExonParentTranscript) +
      optional("--sjdbGTFtagExonParentGene", sjdbGTFtagExonParentGene) +
      optional("--sjdbOverhang", sjdbOverhang) +
      optional("--sjdbScore", sjdbScore) +
      optional("--sjdbInsertSave", sjdbInsertSave) +
      optional("--readFilesCommand", readFilesCommand) +
      optional("--readMapNumber", readMapNumber) +
      optional("--readMatesLengthsIn", readMatesLengthsIn) +
      optional("--readNameSeparator", readNameSeparator) +
      optional("--clip3pNbases", clip3pNbases) +
      optional("--clip5pNbases", clip5pNbases) +
      optional("--clip3pAdapterSeq", clip3pAdapterSeq) +
      optional("--clip3pAdapterMMp", clip3pAdapterMMp) +
      optional("--clip3pAfterAdapterNbases", clip3pAfterAdapterNbases) +
      optional("--limitGenomeGenerateRAM", limitGenomeGenerateRAM) +
      optional("--limitIObufferSize", limitIObufferSize) +
      optional("--limitOutSAMoneReadBytes", limitOutSAMoneReadBytes) +
      optional("--limitOutSJoneRead", limitOutSJoneRead) +
      optional("--limitOutSJcollapsed", limitOutSJcollapsed) +
      optional("--limitBAMsortRAM", limitBAMsortRAM) +
      optional("--limitSjdbInsertNsj", limitSjdbInsertNsj) +
      optional("--outTmpDir", outTmpDir) +
Peter van 't Hof's avatar
Peter van 't Hof committed
289
290
      optional("--outStd", outStd) +
      multiArg("--outSJfilterOverhangMin", outSJfilterOverhangMin, groupSize = 4, maxGroups = 1) +
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
      multiArg("--outSJfilterCountUniqueMin",
               outSJfilterCountUniqueMin,
               groupSize = 4,
               maxGroups = 1) +
      multiArg("--outSJfilterCountTotalMin",
               outSJfilterCountTotalMin,
               groupSize = 4,
               maxGroups = 1) +
      multiArg("--outSJfilterDistToOtherSJmin",
               outSJfilterDistToOtherSJmin,
               groupSize = 4,
               maxGroups = 1) +
      multiArg("--outSJfilterIntronMaxVsReadN",
               outSJfilterIntronMaxVsReadN,
               groupSize = 3,
               maxGroups = 1)
307
308
309

    // Break as workaround for a stackoverflow error for the compiler
    cmd += optional("--outReadsUnmapped", outReadsUnmapped) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
      optional("--outQSconversionAdd", outQSconversionAdd) +
      optional("--outMultimapperOrder", outMultimapperOrder) +
      optional("--outSAMtype", outSAMtype) +
      optional("--outSAMmode", outSAMmode) +
      optional("--outSAMstrandField", outSAMstrandField) +
      optional("--outSAMattributes", outSAMattributes) +
      optional("--outSAMattrIHstart", outSAMattrIHstart) +
      optional("--outSAMunmapped", outSAMunmapped) +
      optional("--outSAMorder", outSAMorder) +
      optional("--outSAMprimaryFlag", outSAMprimaryFlag) +
      optional("--outSAMreadID", outSAMreadID) +
      optional("--outSAMmapqUnique", outSAMmapqUnique) +
      optional("--outSAMflagOR", outSAMflagOR) +
      optional("--outSAMflagAND", outSAMflagAND) +
      optional("--outSAMattrRGline", outSAMattrRGline) +
      optional("--outSAMheaderHD", outSAMheaderHD) +
      optional("--outSAMheaderPG", outSAMheaderPG) +
      optional("--outSAMheaderCommentFile", outSAMheaderCommentFile) +
      optional("--outSAMfilter", outSAMfilter) +
      optional("--outSAMmultNmax", outSAMmultNmax) +
      optional("--outBAMcompression", outBAMcompression) +
      optional("--outBAMsortingThreadN", outBAMsortingThreadN) +
      optional("--bamRemoveDuplicatesType", bamRemoveDuplicatesType) +
      optional("--bamRemoveDuplicatesMate2basesN", bamRemoveDuplicatesMate2basesN) +
      optional("--outWigType", outWigType) +
      optional("--outWigStrand", outWigStrand) +
      optional("--outWigReferencesPrefix", outWigReferencesPrefix) +
      optional("--outWigNorm", outWigNorm) +
      optional("--outFilterType", outFilterType) +
      optional("--outFilterMultimapScoreRange", outFilterMultimapScoreRange) +
      optional("--outFilterMultimapNmax", outFilterMultimapNmax) +
      optional("--outFilterMismatchNmax", outFilterMismatchNmax) +
      optional("--outFilterMismatchNoverLmax", outFilterMismatchNoverLmax) +
      optional("--outFilterMismatchNoverReadLmax", outFilterMismatchNoverReadLmax) +
      optional("--outFilterScoreMin", outFilterScoreMin) +
      optional("--outFilterScoreMinOverLread", outFilterScoreMinOverLread) +
      optional("--outFilterMatchNmin", outFilterMatchNmin) +
      optional("--outFilterMatchNminOverLread", outFilterMatchNminOverLread) +
      optional("--outFilterIntronMotifs", outFilterIntronMotifs) +
      optional("--outSJfilterReads", outSJfilterReads) +
      optional("--scoreGap", scoreGap) +
      optional("--scoreGapNoncan", scoreGapNoncan) +
      optional("--scoreGapGCAG", scoreGapGCAG) +
      optional("--scoreGapATAC", scoreGapATAC) +
      optional("--scoreGenomicLengthLog2scale", scoreGenomicLengthLog2scale) +
355
356
357
      optional("--scoreDelOpen", scoreDelOpen)

    // Break as workaround for a stackoverflow error for the compiler
Peter van 't Hof's avatar
Peter van 't Hof committed
358
    cmd += optional("--scoreDelBase", scoreDelBase) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
      optional("--scoreInsOpen", scoreInsOpen) +
      optional("--scoreInsBase", scoreInsBase) +
      optional("--scoreStitchSJshift", scoreStitchSJshift) +
      optional("--seedSearchStartLmax", seedSearchStartLmax) +
      optional("--seedSearchStartLmaxOverLread", seedSearchStartLmaxOverLread) +
      optional("--seedSearchLmax", seedSearchLmax) +
      optional("--seedMultimapNmax", seedMultimapNmax) +
      optional("--seedPerReadNmax", seedPerReadNmax) +
      optional("--seedPerWindowNmax", seedPerWindowNmax) +
      optional("--seedNoneLociPerWindow", seedNoneLociPerWindow) +
      optional("--alignIntronMin", alignIntronMin) +
      optional("--alignIntronMax", alignIntronMax) +
      optional("--alignMatesGapMax", alignMatesGapMax) +
      optional("--alignSJoverhangMin", alignSJoverhangMin) +
      optional("--alignSJstitchMismatchNmax", alignSJstitchMismatchNmax) +
      optional("--alignSJDBoverhangMin", alignSJDBoverhangMin) +
      optional("--alignSplicedMateMapLmin", alignSplicedMateMapLmin) +
      optional("--alignSplicedMateMapLminOverLmate", alignSplicedMateMapLminOverLmate) +
      optional("--alignWindowsPerReadNmax", alignWindowsPerReadNmax) +
      optional("--alignTranscriptsPerWindowNmax", alignTranscriptsPerWindowNmax) +
      optional("--alignTranscriptsPerReadNmax", alignTranscriptsPerReadNmax) +
      optional("--alignEndsType", alignEndsType) +
      optional("--alignSoftClipAtReferenceEnds", alignSoftClipAtReferenceEnds) +
      optional("--winAnchorMultimapNmax", winAnchorMultimapNmax) +
      optional("--winBinNbits", winBinNbits) +
      optional("--winAnchorDistNbins", winAnchorDistNbins) +
      optional("--winFlankNbins", winFlankNbins) +
      optional("--chimOutType", chimOutType) +
      optional("--chimSegmentMin", chimSegmentMin) +
      optional("--chimScoreMin", chimScoreMin) +
      optional("--chimScoreDropMax", chimScoreDropMax) +
      optional("--chimScoreSeparation", chimScoreSeparation) +
      optional("--chimScoreJunctionNonGTAG", chimScoreJunctionNonGTAG) +
      optional("--chimJunctionOverhangMin", chimJunctionOverhangMin) +
      optional("--chimSegmentReadGapMax", chimSegmentReadGapMax) +
      optional("--chimFilter", chimFilter) +
      optional("--quantMode", quantMode) +
      optional("--quantTranscriptomeBAMcompression", quantTranscriptomeBAMcompression) +
      optional("--quantTranscriptomeBan", quantTranscriptomeBan) +
      optional("--twopassMode", twopassMode) +
      optional("--twopass1readsN", twopass1readsN)
bow's avatar
bow committed
400

Peter van 't Hof's avatar
Peter van 't Hof committed
401
    cmd
Peter van 't Hof's avatar
Peter van 't Hof committed
402
  }
403
404
405
}

object Star {
406

Peter van 't Hof's avatar
Peter van 't Hof committed
407
  /**
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
    * Create default star
    * @param configurable root object
    * @param R1 R1 fastq file
    * @param R2 R2 fastq file
    * @param outputDir Outputdir for Star
    * @param isIntermediate When set true jobs are flaged as intermediate
    * @param deps Deps to add to wait on run
    * @return Return Star
    *
    */
  def apply(configurable: Configurable,
            R1: File,
            R2: Option[File],
            outputDir: File,
            isIntermediate: Boolean = false,
            deps: List[File] = Nil): Star = {
Peter van 't Hof's avatar
Peter van 't Hof committed
424
    val star = new Star(configurable)
425
    star.R1 = R1
Peter van 't Hof's avatar
Peter van 't Hof committed
426
    R2.foreach(R2 => star.R2 = R2)
427
    star.outputDir = outputDir
428
    star.isIntermediate = isIntermediate
Peter van 't Hof's avatar
Peter van 't Hof committed
429
    star.deps = deps
Peter van 't Hof's avatar
Peter van 't Hof committed
430
431
    star.beforeGraph()
    star
432
  }
bow's avatar
bow committed
433

Peter van 't Hof's avatar
Peter van 't Hof committed
434
  /**
435
436
437
438
439
440
441
442
443
    * returns Star with 2pass star method
    * @param configurable root object
    * @param R1 R1 fastq file
    * @param R2 R2 fastq file
    * @param outputDir Outputdir for Star
    * @param isIntermediate When set true jobs are flaged as intermediate
    * @param deps Deps to add to wait on run
    * @return Return Star
    */
Peter van 't Hof's avatar
Peter van 't Hof committed
444
445
  def _2pass(configurable: Configurable,
             R1: File,
Peter van 't Hof's avatar
Peter van 't Hof committed
446
             R2: Option[File],
Peter van 't Hof's avatar
Peter van 't Hof committed
447
448
449
             outputDir: File,
             isIntermediate: Boolean = false,
             deps: List[File] = Nil): (File, List[Star]) = {
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
450
451
452
453
454
455
    val starCommandPass1 = Star(configurable, R1, R2, new File(outputDir, "aln-pass1"))
    starCommandPass1.isIntermediate = isIntermediate
    starCommandPass1.deps = deps
    starCommandPass1.beforeGraph()

    val starCommandReindex = new Star(configurable)
Peter van 't Hof's avatar
Peter van 't Hof committed
456
    starCommandReindex.sjdbFileChrStartEnd :+= starCommandPass1.outputTab
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
457
458
459
460
461
462
463
464
465
466
467
468
    starCommandReindex.outputDir = new File(outputDir, "re-index")
    starCommandReindex.runmode = "genomeGenerate"
    starCommandReindex.isIntermediate = isIntermediate
    starCommandReindex.beforeGraph()

    val starCommandPass2 = Star(configurable, R1, R2, new File(outputDir, "aln-pass2"))
    starCommandPass2.genomeDir = starCommandReindex.outputDir
    starCommandPass2.isIntermediate = isIntermediate
    starCommandPass2.deps = deps
    starCommandPass2.beforeGraph()

    (starCommandPass2.outputSam, List(starCommandPass1, starCommandReindex, starCommandPass2))
Peter van 't Hof's avatar
Peter van 't Hof committed
469
  }
470
}