Created
July 28, 2021 17:00
-
-
Save SamStudio8/4320e63ad22743b9da967e452054909c to your computer and use it in GitHub Desktop.
collect_nf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nextflow | |
params.testdir = "/cephfs/covid/software/sam/nf-test/" | |
params.fofn_single = [params.testdir, 'samples.csv'].join('/') | |
single_manifest_ch = Channel | |
.fromPath(params.fofn_single) // open say, a CSV | |
.splitCsv(header:true) // split text stream into CSV records | |
.map { row-> file(row.path) } // coerce the record and return a file for each line | |
.collect() // emit all items as one | |
process echo_fofn_single { | |
input: | |
file '*.txt' from single_manifest_ch | |
output: | |
publishDir path: "${params.testdir}", pattern: "out", mode: "copy", overwrite: true | |
file "out" | |
script: | |
""" | |
cat *.txt > out | |
""" | |
} | |
params.fofn_group = [params.testdir, 'grouped_samples.tsv'].join('/') | |
group_manifest_ch = Channel | |
.fromPath(params.fofn_group) | |
.splitCsv(header:true, sep:'\t') | |
.map { row-> tuple(row.group, file(row.path)) } // coerce the record into a (group, file) tuple | |
.groupTuple() // return tuples of (group, [file1, ...fileN]) | |
process echo_fofn_group { | |
input: | |
tuple(group, file(files)) from group_manifest_ch | |
output: | |
publishDir path: "${params.testdir}", pattern: "g*out", mode: "copy", overwrite: true | |
file "g${group}.out" | |
script: | |
""" | |
cat ${files} > g${group}.out | |
""" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hoot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello | |
world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hoot | |
meow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group | path | |
---|---|---|
1 | /cephfs/covid/software/sam/nf-test/file1.txt | |
1 | /cephfs/covid/software/sam/nf-test/file2.txt | |
2 | /cephfs/covid/software/sam/nf-test/file3.txt | |
2 | /cephfs/covid/software/sam/nf-test/file4.txt | |
3 | /cephfs/covid/software/sam/nf-test/file5.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello | |
world |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path | |
/cephfs/covid/software/sam/nf-test/file1.txt | |
/cephfs/covid/software/sam/nf-test/file2.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment