Home > Back-end >  What is the format for a Snakemake JSON config file?
What is the format for a Snakemake JSON config file?

Time:08-24

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

CodePudding user response:

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.

  • Related