Skip to content

Instantly share code, notes, and snippets.

@lindenb
Last active April 13, 2016 18:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lindenb/3c07ca722f793cc5dd60 to your computer and use it in GitHub Desktop.
Save lindenb/3c07ca722f793cc5dd60 to your computer and use it in GitHub Desktop.
generating a simple NGS workflow with JSON, apache velocity and jsvelocity https://github.com/lindenb/jsvelocity
{
"reference": {
"name": "ref",
"fasta": "/path/to/ref.fasta"
},
"samples": [
{
"fastq": [
"path/to/Sample1/Sample1_1.fq.gz",
"path/to/Sample1/Sample1_2.fq.gz"
],
"name": "Sample1"
},
{
"fastq": [
"path/to/Sample2/Sample2_1.fq.gz",
"path/to/Sample2/Sample2_2.fq.gz"
],
"name": "Sample2"
},
{
"fastq": [
"path/to/Sample3/Sample3_1.fq.gz",
"path/to/Sample3/Sample3_2.fq.gz"
],
"name": "Sample3"
}
],
"tools": {
"bcftools": "/path/to/bcftools",
"bwa": "/path/to/bwa",
"samtools": "/path/to/samtools"
}
}
java -jar jsvelocity.jar -f config config.json make.vm > Makefile
REF=${config.reference.fasta}
.PHONY:all
all: align/variants.vcf
align/variants.vcf: #foreach($sample in ${config.samples}) align/${sample.name}_sorted.bam #end
${config.tools.samtools} mpileup -uf ${REF} $^ |\
${config.tools.bcftools} view -vcg - >$@
#foreach($sample in ${config.samples})
align/${sample.name}_sorted.bam : ${sample.fastq[0]} ${sample.fastq[1]}
mkdir -p $(dir $@) && \
${config.tools.bwa} mem -R '@RG\tID:${sample.getId()}\tSM:${sample.name}' ${REF} $^ |\
${config.tools.samtools} view -b -S - |\
${config.tools.samtools} sort - $(basename $@) && \
${config.tools.samtools} index $@
#end
REF=/path/to/ref.fasta
.PHONY:all
all: align/variants.vcf
align/variants.vcf: align/Sample1_sorted.bam align/Sample2_sorted.bam align/Sample3_sorted.bam
/path/to/samtools mpileup -uf ${REF} $^ |\
/path/to/bcftools view -vcg - >$@
align/Sample1_sorted.bam : path/to/Sample1/Sample1_1.fq.gz path/to/Sample1/Sample1_2.fq.gz
mkdir -p $(dir $@) && \
/path/to/bwa mem -R '@RG\tID:id10\tSM:Sample1' ${REF} $^ |\
/path/to/samtools view -b -S - |\
/path/to/samtools sort - $(basename $@) && \
/path/to/samtools index $@
align/Sample2_sorted.bam : path/to/Sample2/Sample2_1.fq.gz path/to/Sample2/Sample2_2.fq.gz
mkdir -p $(dir $@) && \
/path/to/bwa mem -R '@RG\tID:id15\tSM:Sample2' ${REF} $^ |\
/path/to/samtools view -b -S - |\
/path/to/samtools sort - $(basename $@) && \
/path/to/samtools index $@
align/Sample3_sorted.bam : path/to/Sample3/Sample3_1.fq.gz path/to/Sample3/Sample3_2.fq.gz
mkdir -p $(dir $@) && \
/path/to/bwa mem -R '@RG\tID:id20\tSM:Sample3' ${REF} $^ |\
/path/to/samtools view -b -S - |\
/path/to/samtools sort - $(basename $@) && \
/path/to/samtools index $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment