我在 Nextflow 中的 Python 脚本有问题,我的目标是在 python 脚本中编写一个文件,然后将它与 nextflow 一起使用并将文件保存在 publishdir 中(以及在我在其他进程中使用此文件之后)。我在 nextflow 中的流程是这样的(文件是之前定义的):
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
"""
}
python的脚本:(我简化了实际过程,但本质是这样的),我需要在nextflow中获取保存在输出文件中的文件。
#!/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=[])
[e1/74e0ee] process > writefile (DataflowQueue(queue=[])) [100%] 1 of 1 ✔
谢谢!
- - - - - - - 更新 - - - - - - -
我将输入文件更改为 file()。nextflow.config:
params {
input_file = 'data/old_file.txt'
output_dir = 'output_new'
}
主.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 的输出,但我的输入文件不在发布目录中(但在目录工作中)。
[7d/78559b] process > writefile (/home/myuser/Documentos/dir/pipeline_dir/data/old_file.txt) [100%] 1 of 1 ✔
writefile 之后的这个路径是我的输入文件的路径,我不知道为什么(这个目录没有任何变化)。