collectFile Error - "no such file or directory" #4559
-
I'm trying to use process WRITE_CSV {
input:
tuple val(meta)
output:
tuple val(meta), path("*.csv"), emit: csv
script:
def csv_text = [
['SampleID', "Replicate"],
[meta.id, meta.rep]
]*.join(',').join(System.lineSeparator)
"""
echo -ne "${csv_text}" > ${meta.id}.csv
"""
}
workflow DEBUG {
input = [ [id: 'sample1', rep: 1],
[id: 'sample1', rep: 2],
[id: 'sample2', rep: 1],
[id: 'sample2', rep: 2] ]
WRITE_CSV( input ).csv
.collectFile(storeDir: "output/") { meta, csv_file ->
[ "${meta.id}.csv", csv_file + '\n' ]
}
} This fails with the error message: ERROR ~ No such file or directory: /path/to/work/58/0bad8fd4ef81d32510624d0eb5ac32/sample1.csv However, the file does exist with the contents I expect: SampleID,Replicate
sample1,1 I'm not sure whether this is a problem in my code or an issue in nextflow. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The problem is I had a newline in the closure ( workflow DEBUG {
input = [ [id: 'sample1', rep: 1],
[id: 'sample1', rep: 2],
[id: 'sample2', rep: 1],
[id: 'sample2', rep: 2] ]
WRITE_CSV( input ).csv
.collectFile(storeDir: "output/") { meta, csv_file ->
[ "${meta.id}.csv", csv_file ]
}
} Thanks @slsevilla for spotting the error! |
Beta Was this translation helpful? Give feedback.
The problem is I had a newline in the closure (
csv_file + '\n'
) which I had copied from the nextflow docs example, but that example was operating on strings not files. Removing that fixed it:Thanks @slsevilla for spotting the error!