1

我有以下(简化的)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

这是有道理的——我没有指定这些文件的来源。但我怎么能?如果我遵循文档的配置部分并nextflow.config使用以下内容创建一个:

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

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

4

1 回答 1

1

将脚本作为模块导入时会忽略隐式工作流定义。这意味着您的工作流脚本可以用作库模块或应用程序脚本:

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 选项为其指定任何所需的参数。例如:

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)
}
于 2021-04-14T02:48:25.523 回答