通过 CLI 提供 NextFlow 工作流输入(不是参数)

Provide NextFlow workflow inputs (not parameters) via the CLI

我有以下(简化的)nextflow 模块。它有一个过程,运行 是一个 fasta 文件的多序列比对,还有一个 运行 是这个过程的工作流程(最终它也会 运行 其他过程):

process clustal_omega_msa {
    input:
      path fastas
    output:
      path 'clustal.sto'
    script:
      """
      cat ${fastas} > merged.fa
      clustalo -infile merged.fa --outfmt=stockholm
      """
    container "https://depot.galaxyproject.org/singularity/clustalo:1.2.4--h1b792b2_4"
}

workflow msa {
  take:
    path fastas
  main:
    clustal_omega_msa(fastas)
}

我希望此工作流程既可作为子工作流程导入,又可直接执行。出于这个原因,我没有指定任何参数,只使用了输入(因为我相信在调用子工作流时不能指定参数)。

但是,我无法直接在命令行上运行此子工作流程。

如果我 运行 nextflow run msa.nf -entry msa 我得到以下错误:

No such variable: fastas

 -- Check script 'msa.nf' at line: 1 or see '.nextflow.log' file for more details

这是有道理的 - 我没有指定这些文件的来源。但是我怎么能如果我按照文档的 config 部分创建一个包含以下内容的 nextflow.config

fastas = "/some/path/to/*.fasta"

我仍然收到此错误。我也知道有一个 -params-file 选项,但我相信它只适用于参数,而不适用于输入。

当脚本作为模块导入时,

Implicit workflow definitions 将被忽略。这意味着您的工作流脚本可以用作库模块或应用程序脚本:

nextflow.enable.dsl=2
params.input_fasta_files = './data/*.fasta'


process clustal_omega_msa {

    input:
    path fastas
    
    output:
    path 'clustal.sto'

    """
    cat ${fastas} > merged.fa
    clustalo -infile merged.fa --outfmt=stockholm
    """
}

workflow msa {
  
    take:
    fasta_files
  
    main:
    clustal_omega_msa(fasta_files)
}

workflow {

    input_fasta_files = Channel.fromPath( params.input_fasta_files ).collect()

    msa( input_fasta_files )
}

请注意,如果您要将 'msa' 子工作流移动到一个单独的文件中,例如名为 'msa.nf',您可以直接导入它并使用addParams option。例如:

nextflow.enable.dsl=2

include { msa } from './path/to/msa.nf' addParams(foo: 'bar')

params.input_fasta_files = './data/*.fasta'


workflow {

    input_fasta_files = Channel.fromPath( params.input_fasta_files ).collect()

    msa(input_fasta_files)
}