Skip to content

Instantly share code, notes, and snippets.

@yuifu
Last active June 18, 2019 05:42
Show Gist options
  • Save yuifu/5b220ed266d03a4f2e5f2848cefc8a9f to your computer and use it in GitHub Desktop.
Save yuifu/5b220ed266d03a4f2e5f2848cefc8a9f to your computer and use it in GitHub Desktop.
I want to count the number of input and output files to check all files are properly processed. -> Solved!!
#!/usr/bin/env nextflow
Channel.fromPath("*.txt")
.map{[
file(it),
file(it).baseName
]}.into{
input_files
input_files_
input_files__
}
// Get the number of files (Strictly speaking, the number of [file (it), file(it).baseName])
n_files = input_files_.count().getVal()
// Get the number of files with > 0 bytes
n_file_pos = input_files__.count {it[0].size() > 0}.getVal()
println "# of files with >0 bytes: $n_file_pos"
process line_count {
tag { "${sample_id}"}
publishDir "line_count/${sample_id}"
input:
set file(infile), sample_id from input_files
output:
set file("${sample_id}.out.txt"), sample_id into output_files
script:
def ofile = "${sample_id}.out.txt"
"""
wc -l $infile > $ofile
"""
}
@yuifu
Copy link
Author

yuifu commented Jun 18, 2019

@yuifu
Copy link
Author

yuifu commented Jun 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment