【问题标题】:How to run Python Script in Nextflow如何在 Nextflow 中运行 Python 脚本
【发布时间】:2020-10-14 03:09:57
【问题描述】:

我是 Nextflow 的新手,我尝试在 Nextflow 中运行 Python 脚本。因此,我将 Python 脚本存储在与 Nextflow 管道相同的文件夹中并尝试运行它,但我总是收到此错误:.command.sh: line 2: ./example.py: No such file or directory。 有没有人遇到过同样的问题并且能够解决?

我的流程如下所示:

#!/usr/bin/env nextflow

input_ch = Channel.fromPath('data/*.txt')

process foo {

    input:
    file x from input_ch

    output:
    file "$x" into outputt_ch

    """
    ./example.py ${x}
    """

}

P.S.:我的 Python 脚本可以从终端执行!

提前谢谢你!

【问题讨论】:

    标签: python-3.x workflow nextflow


    【解决方案1】:

    Nextflow 在单独的工作目录中运行每个任务。因此./example.py 将不起作用。您必须使用example.py 并使脚本可以通过系统PATH 访问或将其复制到项目bin/ 目录中。

    【讨论】:

      【解决方案2】:

      另一种解决方案是使用projectDir 变量。 例如,

      #!/usr/bin/env nextflow
      
      input_ch = Channel.fromPath('data/*.txt')
      project_dir = projectDir
      
      process foo {
      
          input:
          file x from input_ch
      
          output:
          file "$x" into outputt_ch
      
          """
          python $project_dir/example.py ${x}
          """
      
      }
      

      【讨论】:

        猜你喜欢
        • 2017-04-12
        • 2018-08-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        • 2019-02-27
        相关资源
        最近更新 更多