Skip to content

Commit caad7fa

Browse files
committed
Fix argument conflict between STAR versions
1 parent 161cf95 commit caad7fa

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

subworkflows/local/align_star/nextflow.config

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1+
def generateStarAlignArgs(save_unaligned, contaminant_screening, extra_star_align_args) {
2+
def argsToMap = { String args ->
3+
args.split(/\s(?=--)/).collectEntries {
4+
def parts = it.trim().split(/\s+/, 2)
5+
[(parts[0]): parts.size() > 1 ? parts[1] : '']
6+
}
7+
}
8+
9+
def base_args = """
10+
--quantMode TranscriptomeSAM
11+
--twopassMode Basic
12+
--outSAMtype BAM Unsorted
13+
--readFilesCommand zcat
14+
--runRNGseed 0
15+
--outFilterMultimapNmax 20
16+
--alignSJDBoverhangMin 1
17+
--outSAMattributes NH HI AS NM MD
18+
--outSAMstrandField intronMotif
19+
""".trim()
20+
21+
if (save_unaligned || contaminant_screening) {
22+
base_args += "\n--outReadsUnmapped Fastx"
23+
}
24+
25+
def final_args_map = argsToMap(base_args) + (extra_star_align_args ? argsToMap(extra_star_align_args) : [:])
26+
final_args_map.collect { key, value -> "${key} ${value}".trim() }.join(' ')
27+
}
28+
129
if (!params.skip_alignment && params.aligner == 'star_salmon') {
230
process {
3-
withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' {
4-
ext.args = {
5-
// Function to convert argument strings into a map
6-
def argsToMap = { String args ->
7-
args.split("\\s(?=--)").collectEntries {
8-
def parts = it.trim().split(/\s+/, 2)
9-
[(parts.first()): parts.last()]
10-
}
11-
}
12-
13-
// Initialize the map with preconfigured values
14-
def preset_args_map = argsToMap("""
15-
--quantMode TranscriptomeSAM
16-
--twopassMode Basic
17-
--outSAMtype BAM Unsorted
18-
--readFilesCommand zcat
19-
--runRNGseed 0
20-
--outFilterMultimapNmax 20
21-
--alignSJDBoverhangMin 1
22-
--outSAMattributes NH HI AS NM MD
23-
--quantTranscriptomeSAMoutput BanSingleEnd
24-
--outSAMstrandField intronMotif
25-
${params.save_unaligned || params.contaminant_screening ? '--outReadsUnmapped Fastx' : ''}
26-
""".trim())
2731

28-
// Consolidate the extra arguments
29-
def final_args_map = preset_args_map + (params.extra_star_align_args ? argsToMap(params.extra_star_align_args) : [:])
32+
// We have to condition this, because the args are slightly different between the latest STAR and the one compatible with iGenomes
3033

31-
// Convert the map back to a list and then to a single string
32-
final_args_map.collect { key, value -> "${key} ${value}" }.join(' ').trim()
34+
withName: '.*:ALIGN_STAR:STAR_ALIGN' {
35+
ext.args = {
36+
generateStarAlignArgs(params.save_unaligned, params.contaminant_screening, params.extra_star_align_args + ' --quantTranscriptomeSAMoutput BanSingleEnd')
37+
}
38+
}
39+
withName: 'ALIGN_STAR:STAR_ALIGN_IGENOMES' {
40+
ext.args = {
41+
generateStarAlignArgs(params.save_unaligned, params.contaminant_screening, params.extra_star_align_args + ' --quantTranscriptomeBan Singleend')
3342
}
43+
44+
}
45+
withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' {
3446

3547
publishDir = [
3648
[

0 commit comments

Comments
 (0)