Is it possible to pass custom command line arguments to snakemake scripts? I have tried, but executing Snakefile with argparse results in error snakemake: error: unrecognized arguments: -zz. Below is an example script.
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}"
Passing arguments from command line is possible using --config. For example:
snakemake --config zz="filename"
In snakefile script, this can be used in this way:
rule test_1:
    input:
        fn + config['zz']
    shell:
        "echo Using file {input}"
See the doc for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With