1

是否可以将自定义命令行参数传递给snakemake脚本?我试过了,但执行Snakefile与​​导致错误snakemake: error: unrecognized arguments: -zz。以下是一个示例脚本。在Snakemake脚本中使用argparse

import argparse 

def get_args(): 
    parser = argparse.ArgumentParser(description='Compares Illumina and 10x VCFs using RTG vcfeval') 

    # required main arguments 
    parser.add_argument('-zz', metavar='--filename', dest='fn', help='Filename', required=True) 

    # parse arguments 
    args = parser.parse_args() 

    fn = args.fn 
    return fn 

fn = get_args() 

rule test_1: 
    input: 
     fn + "/example.txt" 
    shell: 
     "echo Using file {input}" 
+0

你是如何调用这个脚本的?通常我会希望看到:'python your_script.py -zz afilename'。 – hpaulj

+0

找到解决方案。允许通过'--config'。 [来源](http://snakemake.readthedocs.io/en/stable/project_info/faq.html#is-it-possible-to-pass-variable-values-to-the-workflow-via-the-command-线) – JeeYem

回答

1

从命令行传递参数是possible using --config。例如:

snakemake --config zz="filename"

在snakefile脚本,这可以以这种方式使用:

rule test_1: 
    input: 
     fn + config['zz'] 
    shell: 
     "echo Using file {input}" 

See the doc获取更多信息。