Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the format for a Snakemake JSON config file?

I can find examples of yaml config files, but I can’t find any json config files, and my guesses are failing

How do I do this in a JSON config file, such that config["samples"] will return the correct values?

Yaml:
samples:
    A: data/samples/A.fastq
    B: data/samples/B.fastq

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you have config.yaml that looks like this:

samples:
    A: data/samples/A.fastq
    B: data/samples/B.fastq

Then the equivalent config.json will look like this:

{
    "samples":
    {
        "A": "data/samples/A.fastq",
        "B": "data/samples/B.fastq"
    }
}

So the following Snakefile will have the same behaviour with yaml or json configfile:

# uncomment the option of interest
# configfile: 'config.json'
# configfile: 'config.yaml'

rule all:
    input:
       A=config['samples']["A"],
       B=config['samples']["B"]

Note that the failure of the Snakefile above is intended, it will show that the contents of the configfile were parsed correctly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading