Nextflow:python的脚本don';不保存输出
我对Nextflow中的Python脚本有问题,我的目标是用Python脚本编写一个文件,并将其与Nextflow一起保存在publishdir中(以及在其他过程中使用此文件之后)。 我在nextflow中的流程如下(这些文件是以前定义的): python脚本:(我简化了实际过程,但本质是这样的),我需要在nextflow中获得保存在输出文件中的文件Nextflow:python的脚本don';不保存输出,python,nextflow,Python,Nextflow,我对Nextflow中的Python脚本有问题,我的目标是用Python脚本编写一个文件,并将其与Nextflow一起保存在publishdir中(以及在其他过程中使用此文件之后)。 我在nextflow中的流程如下(这些文件是以前定义的): python脚本:(我简化了实际过程,但本质是这样的),我需要在nextflow中获得保存在输出文件中的文件 #!/usr/bin/env python3 import argparse from sys import argv def main():
#!/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()
问题是文件不是保存在发布目录中,而是在nextflow的目录工作中,当我运行工作流时,流程完成,没有错误,但表示DataflowQueue(queue=[])
谢谢
-----------更新-----------------
我将输入文件更改为文件()。nextflow.config文件:
params {
input_file = 'data/old_file.txt'
output_dir = 'output_new'
}
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
"""
}
这更改了nextflow的输出,但我的输入文件不在发布目录中(但在目录工作中)
writefile之后的这个路径是我的输入文件所在的路径,我不知道为什么(该目录中没有任何更改)。使用“更改文件”频道时,您的输入似乎有问题。如果“嫦娥文件”应该是A,请考虑以下内容:
params.change_file = 'my_change_file.txt'
params.output_dir = 'my_output_dir'
change_file = file(params.change_file)
process writefile{
publishDir "${params.output_dir}/formatted", mode: 'copy'
input:
path infile from change_file
output:
path "formattedfile.txt" into file_changed
"""
file2formattedfile.py "${infile}" formattedfile.txt
"""
}
结果:
[d6/5173c1] process > writefile [100%] 1 of 1 ✔
如果上述内容没有帮助,请说明“更改文件”频道是如何创建的。谢谢您的回答!我更改了输入,这也更改了nextflow的输出,但是我的文件还没有在publish目录中。我用新的information@JocHwo您的意思是输入文件不在publishDir中还是输出文件不在publishDir中?对我来说,上面的工作与预期一样,并将输出文件“formattedfile.txt”复制到publishDir。上面更新的代码似乎没有任何问题。您提到您的输入文件不在发布目录中。这是因为,默认情况下,流程输出中不包括输入文件。尝试将路径填充添加到进程“输出”声明中。这将确保捕获它,并让publishDir指令将其复制到输出目录。stdout(/home/myuser/Documentos/…)上的writefile路径只是您的输入文件。在您的实际代码中(上面没有显示),您可能只是用
tag{infle}
或类似的东西标记了流程。
[7d/78559b] process > writefile (/home/myuser/Documentos/dir/pipeline_dir/data/old_file.txt) [100%] 1 of 1 ✔
params.change_file = 'my_change_file.txt'
params.output_dir = 'my_output_dir'
change_file = file(params.change_file)
process writefile{
publishDir "${params.output_dir}/formatted", mode: 'copy'
input:
path infile from change_file
output:
path "formattedfile.txt" into file_changed
"""
file2formattedfile.py "${infile}" formattedfile.txt
"""
}
[d6/5173c1] process > writefile [100%] 1 of 1 ✔