Create a gist now

Instantly share code, notes, and snippets.

@lindenb /Makefile
Last active Apr 13, 2016

What would you like to do?
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