Last active
June 18, 2019 05:42
-
-
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!!
This file contains 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 | |
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 | |
""" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cf: https://www.nextflow.io/docs/latest/script.html#check-file-attributes