1

我在 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 之后的这个路径是我的输入文件的路径,我不知道为什么(这个目录没有任何变化)。

4

1 回答 1

1

您使用“change_file”频道的输入似乎有问题。如果 'change_file' 应该是一个价值通道,请考虑以下几点:

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 ✔

如果上述方法没有帮助,请显示“change_file”频道是如何创建的。

于 2020-09-28T23:39:35.780 回答