【问题标题】:Overriding Nextflow Parameters with Commandline Arguments使用命令行参数覆盖 Nextflow 参数
【发布时间】:2021-02-25 10:00:35
【问题描述】:

鉴于以下nextflow.config

google {
  project = "cool-project"
  region = "europe-west4"
            
  lifeSciences {
    bootDiskSize = "200 GB"
    debug = true
    preemptible = true
  }
}

是否可以使用命令行参数覆盖这些设置中的一个或多个。例如,如果我想指定不应该使用抢占式机器,我可以执行以下操作:

nextflow run main.nf -c nextflow.config --google.lifeSciences.preemptible false

?

【问题讨论】:

    标签: nextflow


    【解决方案1】:

    可以使用 Nextflow 的 command line interface 通过在参数名称前加上双破折号来覆盖管道参数。例如,将以下内容放入名为“test.nf”的文件中:

    #!/usr/bin/env nextflow
    
    params.greeting = 'Hello'
    
    names = Channel.of( "foo", "bar", "baz" )
    
    process greet {
    
        input:
        val name from names
    
        output:
        stdout result
    
        """
        echo "${params.greeting} ${name}"
        """
    }
    
    result.view { it.trim() }
    

    并使用以下命令运行它:

    nextflow run -ansi-log false test.nf --greeting 'Bonjour'
    

    结果:

    N E X T F L O W  ~  version 20.10.0
    Launching `test.nf` [backstabbing_cajal] - revision: 431ef92cef
    [46/22b4f0] Submitted process > greet (1)
    [ca/32992c] Submitted process > greet (3)
    [6e/5880b0] Submitted process > greet (2)
    Bonjour bar
    Bonjour foo
    Bonjour baz
    

    这适用于管道参数,但 AFAIK 无法像您在命令行中描述的那样直接覆盖执行器配置。但是,您可以只参数化这些值并在命令行上设置它们,如上所述。例如,在您的 nextflow.config 中:

    params {
    
      gc_region = false
      gc_preemptible = true
    
      ...
    }
    
    profiles {
    
      'test' {
        includeConfig 'conf/test.config'
      }
    
      'google' {
        includeConfig 'conf/google.config'
      }
    
      ...
    }
    

    在一个名为“conf/google.config”的文件中:

    google {
      project = "cool-project"
      region = params.gc_region
                
      lifeSciences {
        bootDiskSize = "200 GB"
        debug = true
        preemptible = params.gc_preemptible
      }
    }
    

    那么您应该能够以通常的方式覆盖这些:

    nextflow run main.nf -profile google --gc_region "europe-west4" --gc_preemptible false
    

    请注意,您还可以通过用逗号分隔配置文件名称来指定多个 configuration profiles

    nextflow run main.nf -profile google,test ...
    

    【讨论】:

      猜你喜欢
      • 2021-05-05
      • 1970-01-01
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 2016-11-06
      • 1970-01-01
      相关资源
      最近更新 更多