Skip to content

Instantly share code, notes, and snippets.

@dpryan79
Created December 22, 2022 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpryan79/1494d5252f72ac4640c732bd1cac7263 to your computer and use it in GitHub Desktop.
Save dpryan79/1494d5252f72ac4640c732bd1cac7263 to your computer and use it in GitHub Desktop.
Iterative with connected inputs/outputs
rawFastqs = Channel.fromFilePairs(['data/*_{1,2}.fastq.gz', 'data/*_R{1,2}.fastq.gz'])
databases = Channel.of(['label1', '/some/path/database'], ['label2', '/some/other/path/database'], ...)
/+
The general structure of what I'd like to achieve, just without manually putting in all of the someProcess() calls
That won't work for a variety of reasons, among them being that someProcess() would need an alias each time
*/
workflow {
someProcess(rawFastqs, databases.first())
someProcess(someProcess.out.fastq, databases[2])
...
someProcess(someProcess.out.fastq, databases.last())
}
process someProcess {
input:
tuple val(sampleName), path(reads)
tuple val(label), path(database)
output:
path "*.processed.fastq.gz", emit: fastq
"""
some script processing reads through the database, noting the label for eventual reporting
"""
}
rawFastqs = Channel.fromFilePairs(['data/*_{1,2}.fastq.gz', 'data/*_R{1,2}.fastq.gz'])
//N.B., this is a tuple of tuples
databases = Channel.of([['label1', '/some/path/database'], ['label2', '/some/other/path/database'], ...])
workflow {
someProcess(rawFastqs, databases)
}
process someProcess {
input:
tuple val(sampleName), path(reads)
val(tuple(val(label), path(database))) // This doesn't work, there's a "no such variable: label" error
output:
path "*.processed.fastq.gz", emit: fastq
shell:
"""
Some script that iterates over the databases array
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment