I have problem with a script of Python in Nextflow, my aim is write a file in the script of python and take this with nextflow and save the file in the publishdir (and after I use this file in other process). My process in nextflow is something like this (the files were defined before):
process writefile{
publishDir "${params.output_dir}/formatted", mode: 'copy'
input:
path file from change_file
output:
path "formattedfile.txt" into file_changed
script:
"""
file2formattedfile.py ${file} formattedfile.txt
"""
}
The script of python: (I simplified the real process, but essentiality is something like this), I need obtain in nextflow the file save in output file.
#!/usr/bin/env python3
import argparse
from sys import argv
def main():
input,output = argv[1:3]
out = open(output, "w")
#My real operations are here
out.write("Operations and text")
out.close()
if __name__ == "__main__":
main()
The problem is the file is don't save in the publish dir, but is in the dir work of nextflow, when i run the workflow the process is completed without error but said DataflowQueue(queue=[])
[e1/74e0ee] process > writefile (DataflowQueue(queue=[])) [100%] 1 of 1 ✔
Thanks!
------------- Update -------------
I changed the input file to a file(). The nextflow.config:
params {
input_file = 'data/old_file.txt'
output_dir = 'output_new'
}
The main.nf
change_file = file(params.input_file)
process writefile{
publishDir "${params.output_dir}/formatted", mode: 'copy'
input:
path file from change_file
output:
path "formattedfile.txt" into file_changed
script:
"""
file2formattedfile.py ${file} formattedfile.txt
"""
}
This changed the ouptput of nextflow, but my input file wasn't in the publish dir (but is in the dir work).
[7d/78559b] process > writefile (/home/myuser/Documentos/dir/pipeline_dir/data/old_file.txt) [100%] 1 of 1 ✔
This path after writefile is the path where is my input file, I don't know why (nothing is change in this dir).
Looks like something is wrong with your input using the 'change_file' channel. If 'change_file' should be a value channel, consider the following:
Results:
If the above doesn't help, please show how the 'change_file' channel is being created.