-
Notifications
You must be signed in to change notification settings - Fork 881
Expand file tree
/
Copy pathalign_star.config
More file actions
163 lines (150 loc) · 7.43 KB
/
Copy pathalign_star.config
File metadata and controls
163 lines (150 loc) · 7.43 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
process {
// STAR alignment configuration
// Conditionals for when these processes run are handled in the workflow
withName: '.*ALIGN_STAR:STAR_ALIGN|.*ALIGN_STAR:STAR_ALIGN_IGENOMES|.*ALIGN_STAR:SENTIEON_STAR_ALIGN|.*ALIGN_STAR:PARABRICKS_RNA_FQ2BAM' {
ext.args = {
def isPbrun = task.process.contains('PARABRICKS')
def quantifier = params.aligner == 'star_rsem' ? 'rsem' : 'salmon'
// iGenomes is pinned to STAR 2.6.1d which uses the legacy --quantTranscriptomeBan flag.
// Sentieon also uses this legacy flag for now.
// If Sentieon updates to support the STAR 2.7+ flag, remove it from this check.
def useLegacyBanFlag = task.process.endsWith(':STAR_ALIGN_IGENOMES') || task.process.endsWith(':SENTIEON_STAR_ALIGN')
def args = []
// Common args - pbrun uses kebab-case equivalents
if (isPbrun) {
args += [
'--quantMode TranscriptomeSAM',
'--out-sam-attributes NH HI AS NM MD',
'--read-files-command zcat',
"--read-group-sm ${task.tag}",
"--read-group-id-prefix ${task.tag}"
]
} else {
args += [
'--quantMode TranscriptomeSAM',
'--outSAMtype BAM Unsorted',
'--outSAMattributes NH HI AS NM MD',
'--readFilesCommand zcat'
]
}
// Quantifier-specific args
//
// NOTE: pbrun rna_fq2bam is based on STAR 2.7.2a and does NOT support:
// --outFilterType BySJout : no pbrun equivalent; pbrun uses its own filtering defaults
// --sjdbScore 1 : no pbrun equivalent; affects junction scoring priority
// --quantTranscriptomeBan Singleend / --quantTranscriptomeSAMoutput BanSingleEnd :
// no pbrun equivalent; Salmon handles mixed single/paired records gracefully
// --runRNGseed 0 : no pbrun equivalent; pbrun uses deterministic alignment selection
//
if (quantifier == 'rsem') {
if (isPbrun) {
args += [
'--out-sam-unmapped Within',
'--max-out-filter-multimap 20',
'--max-out-filter-mismatch 999',
'--max-out-filter-mismatch-ratio 0.04',
'--min-intron-size 20',
'--max-intron-size 1000000',
'--max-align-mates-gap 1000000',
'--min-align-sj-overhang 8',
'--min-align-sjdb-overhang 1'
]
} else {
args += [
'--outSAMunmapped Within',
'--outFilterType BySJout',
'--outFilterMultimapNmax 20',
'--outFilterMismatchNmax 999',
'--outFilterMismatchNoverLmax 0.04',
'--alignIntronMin 20',
'--alignIntronMax 1000000',
'--alignMatesGapMax 1000000',
'--alignSJoverhangMin 8',
'--alignSJDBoverhangMin 1',
'--sjdbScore 1'
]
}
} else {
if (isPbrun) {
args += [
'--two-pass-mode Basic',
'--max-out-filter-multimap 20',
'--min-align-sjdb-overhang 1',
'--out-sam-strand-field intronMotif'
]
} else {
args += [
'--twopassMode Basic',
'--runRNGseed 0',
'--outFilterMultimapNmax 20',
'--alignSJDBoverhangMin 1',
'--outSAMstrandField intronMotif',
useLegacyBanFlag ? '--quantTranscriptomeBan Singleend' : '--quantTranscriptomeSAMoutput BanSingleEnd'
]
}
}
// Unmapped reads output
if (params.save_unaligned || (params.contaminant_screening && params.contaminant_screening_input == 'unmapped')) {
args += isPbrun
? ['--out-reads-unmapped Fastx']
: ['--outReadsUnmapped Fastx']
}
// Prokaryotic: disable spliced alignment
if (params.prokaryotic) {
if (isPbrun) {
args += ['--max-intron-size 1']
} else {
args += ['--sjdbGTFfeatureExon CDS', '--alignIntronMax 1']
}
}
// Merge user-supplied extra args, deduplicating so user values
// override pipeline defaults (prevents STAR "duplicate parameter" error)
if (params.extra_star_align_args) {
def baseMap = args.join(' ').split(/\s(?=--)/).collectEntries { String token ->
def parts = token.trim().split(/\s+/, 2)
[(parts[0]): parts.size() > 1 ? parts[1] : '']
}
def extraMap = params.extra_star_align_args.split(/\s(?=--)/).collectEntries { String token ->
def parts = token.trim().split(/\s+/, 2)
[(parts[0]): parts.size() > 1 ? parts[1] : '']
}
args = (baseMap + extraMap).collect { k, v -> v ? "${k} ${v}" : k }
}
// Read group tags - assembled once from samplesheet meta and pipeline params
// Per-sample meta values take priority over global params
def seqCenter = meta.seq_center ?: params.seq_center
def seqPlatform = meta.seq_platform ?: params.seq_platform
if (isPbrun) {
// pbrun supports --read-group-pl but has no --read-group-cn flag
if (seqPlatform) args << "--read-group-pl ${seqPlatform}"
} else {
def rgParts = ["'ID:${meta.id}'", "'SM:${meta.id}'"]
if (seqPlatform) rgParts << "'PL:${seqPlatform}'"
if (seqCenter) rgParts << "'CN:${seqCenter}'"
args += ["--outSAMattrRGline ${rgParts.join(' ')}"]
}
args.join(' ')
}
}
withName: '.*ALIGN_STAR:STAR_ALIGN|.*ALIGN_STAR:STAR_ALIGN_IGENOMES|.*ALIGN_STAR:SENTIEON_STAR_ALIGN|.*ALIGN_STAR:PARABRICKS_RNA_FQ2BAM' {
publishDir = [
[
path: { "${params.outdir}/${task.ext.publish_prefix}${params.aligner}/log" },
mode: params.publish_dir_mode,
pattern: '*.{out,tab}'
],
[
path: { params.save_align_intermeds ? "${params.outdir}/${task.ext.publish_prefix}${params.aligner}" : params.outdir },
mode: params.publish_dir_mode,
pattern: '*.bam',
saveAs: { filename -> params.save_align_intermeds ? filename : null }
],
[
path: { params.save_unaligned ? "${params.outdir}/${task.ext.publish_prefix}${params.aligner}/unmapped" : params.outdir },
mode: params.publish_dir_mode,
pattern: '*.fastq.gz',
saveAs: { filename -> params.save_unaligned ? filename : null }
]
]
}
}