-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved ext.args consolidation for STAR and TRIMGALORE #1248
Improved ext.args consolidation for STAR and TRIMGALORE #1248
Conversation
|
Thank your for doing this, @MatthiasZepper. I think it follows the principle of "least surprise". Don't know how easy it would be, but if you wanted to avoid people inadvertently overwriting preset options, you could test for that and issue a warning. I don't consider it strictly necessary, though -- people who use this option should know what they are doing. |
67cd1e7
to
7d29205
Compare
7d29205
to
3b3c178
Compare
params.save_unaligned ? '--outReadsUnmapped Fastx' : '', | ||
params.extra_star_align_args ? params.extra_star_align_args.split("\\s(?=--)") : '' | ||
].flatten().unique(false).join(' ').trim() } | ||
ext.args = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Principle makes sense.
Would it make more sense to factor out maps and merge from there? Like the following (untested).
ext.args = {
// Function to convert argument strings into a map
def argsToMap(String args) {
args.split("\\s(?=--)").collectEntries {
def (key, value) = it.trim().split(/\s+/, 2)
[(key): value]
}
}
// Initialize the map with preset arguments
def preset_args_map = argsToMap('''
--quantMode TranscriptomeSAM
--twopassMode Basic
--outSAMtype BAM Unsorted
--readFilesCommand zcat
--runRNGseed 0
--outFilterMultimapNmax 20
--alignSJDBoverhangMin 1
--outSAMattributes NH HI AS NM MD
--quantTranscriptomeBan Singleend
--outSAMstrandField intronMotif
${params.save_unaligned ? '--outReadsUnmapped Fastx' : ''}
'''.trim())
// Convert extra arguments into a map
def extra_args_map = params.extra_star_align_args ? argsToMap(params.extra_star_align_args) : [:]
// Merge maps: extra arguments override preset arguments
def final_args_map = preset_args_map + extra_args_map
// Convert the map back to a list and then to a single string
final_args_map.collect { key, value -> "${key} ${value}" }.join(' ').trim()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way is fine with me.
Since I do know neither Java nor Groovy (why is Nextflow not pythonic :-/ ?!?) I was just happy that I could nudge the AI into coming up with something that worked. But it is true, using a map is an elegant solution, because it avoids repeatedly looping over the preset arguments for each extra argument.
…sets from the config.
…ion for the local STAR alignment subworkflow.
…ion for the FastQC-UMItools-Trimgalore subworkflow..
3b3c178
to
8027585
Compare
Seems the tests are failing. Before I try to troubleshoot code in a language I do not know... do you, Jonathan, right away know where the problem is? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. These should do it.
But otherwise just flip back to your original, this is only a marginal improvement
subworkflows/nf-core/fastq_fastqc_umitools_trimgalore/nextflow.config
Outdated
Show resolved
Hide resolved
Co-authored-by: Jonathan Manning <[email protected]>
That looks much better! Thank you very much! There are two tests failing, but to me, it doesn't seem that this is anyway related to this PR. |
Occasionally, people were surprised that parameters provided to
extra_star_align_args
could still conflict with the default configuration (e.g. #1046).As a convenience parameter, I felt that it should never take precedence over the actual module configuration, because it seemed more error-prone to silently overwrite the module config with something that (as the parameter name suggests) is meant to be extra. Hence, I preferred that a custom module config should be used.
However, I said that I would be open to reconsider and since now also @tdanhorn and @CharlotteAnne suggested that change, I gave in. This PR now improves the
extra_args
parameter consolidation so it can override presets from the config.PR checklist
nf-core lint
).nextflow run . -profile test,docker --outdir <OUTDIR>
).nextflow run . -profile debug,test,docker --outdir <OUTDIR>
).CHANGELOG.md
is updated.