Skip to content

feature request: generating call-ready input JSONs from a template #67

Open
@a-frantz

Description

@a-frantz

I have a Bash script I use to do this "manually", but it would be really cool to add this as an official function in sprocket. Bash script below:

#!/bin/bash
set -euo pipefail

[ $# -ne 3 ] && { echo "Usage: $0 <list_of_paths> <template_json> <out_dir>"; exit 1; }

mkdir -p $3

for sample_path in $(cat $1); do
  sample_name=$(basename $sample_path)
  cp $2 $3/"$sample_name".input.json;
  sed -i 's;foo;'"$sample_path"';g' $3/"$sample_name".input.json
done

where my template JSONs look something like:

{
  "quality_check.gtf": "path/to/gencode.v31.gtf.gz",
  "quality_check.rna": true,
  "quality_check.bam_index": "foo.bai",
  "quality_check.bam": "foo",
  "quality_check.kraken_db": "path/to/kraken2_db.tar.gz",
...
}

The workflow for using these hypothetical sprocket commands:

$ cat qc.wdl
version 1.1

workflow wf {
    input {
        File bam
        File bam_index
        File reference_fasta
        String? strandedness
    }
    ... # irrlevant
}
$ sprocket inputs --name wf qc.wdl > template.json
$ vim template.json # edit JSON to have the proper production values and paths
$ cat template.json
{
    "wf.reference_fasta": "path/to/reference.fa",
    "wf.strandedness": "Stranded-Reverse"
}
$ cat inputs.tsv
name\tbam\tbam_index
sample1\t/path/to/sample1.bam\t/path/to/sample1.bam.bai
sample2\t/path/to/sample2.bam\t/path/to/sample2.bam.bai
$ sprocket generate-inputs --name wf qc.wdl --template template.json --inputs inputs.tsv --output-dir input_jsons/
$ ls input_jsons/
sample1.json
sample2.json
$ cat input_jsons/sample1.json
{
    "wf.reference_fasta": "path/to/reference.fa",
    "wf.strandedness": "Stranded-Reverse",
    "wf.bam": "/path/to/sample1.bam",
    "wf.bam_index": "/path/to/sample1.bam.bai"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions