|
| 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 | + |
1 | 29 | if (!params.skip_alignment && params.aligner == 'star_salmon') { |
2 | 30 | 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()) |
27 | 31 |
|
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 |
30 | 33 |
|
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') |
33 | 42 | } |
| 43 | + |
| 44 | + } |
| 45 | + withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' { |
34 | 46 |
|
35 | 47 | publishDir = [ |
36 | 48 | [ |
|
0 commit comments