Skip to content

Instantly share code, notes, and snippets.

@lindenb
Created August 3, 2023 12:29
Show Gist options
  • Save lindenb/01826f2cdac12160cdbbec9b88a89d0c to your computer and use it in GitHub Desktop.
Save lindenb/01826f2cdac12160cdbbec9b88a89d0c to your computer and use it in GitHub Desktop.
biostars9571322 Mafile based ngs worfklow for tutorial
# input is
# DATA/father.R1.fq.gz
# DATA/father.R2.fq.gz
# DATA/mother.R1.fq.gz
# DATA/mother.R2.fq.gz
# DATA/child.R1.fq.gz
# DATA/child.R2.fq.gz
#
define mapreads
$(1).bam.bai : $(1).bam
samtools index $$<
$(1).bam : $(1).unsorted.bam
samtools sort -o $$@ -T $$(basename $$@) $$<
$(1).unsorted.bam :$(1).sam
samtools view -Sb -o $$@ $$<
$(1).sam : DATA/$(1).R1.fq.gz DATA/$(1).R2.fq.gz ref.fa.bwt
bwa mem -R '@RG\tID:$$(basename $$@)\tSM:$(1)' ref.fa $$(filter %.fq.gz,$$^) > $$@
endef
all: result.annot.vcf.gz.tbi
result.annot.vcf.gz.tbi: result.annot.vcf.gz
bcftools index $<
result.annot.vcf.gz: result.vcf.gz annot.gff.gz ref.fa.fai
bcftools csq --phase a --fasta-ref ref.fa --gff-annot annot.gff.gz -O b -o $@ $<
annot.gff.gz:
wget -O - "ftp://ftp.ensembl.org/pub/grch37/release-99/gff3/homo_sapiens/Homo_sapiens.GRCh37.87.chromosome.22.gff3.gz" | gunzip -c | sed 's/^22/chr22/' | gzip > $@
result.vcf.gz.tbi: result.vcf.gz
tabix --force --preset vcf $<
result.vcf.gz: result.bcf
bcftools call --multiallelic-caller --variants-only --output-type z -o $@ --format-fields GQ,GP $<
result.bcf : $(addsuffix .bam.bai,child father mother) $(addsuffix .bam,child father mother) ref.fa.fai
bcftools mpileup --fasta-ref ref.fa --output-type b --output $@ -a 'FORMAT/AD' -a 'FORMAT/DP' $(filter %.bam,$^)
$(eval $(call mapreads,father))
$(eval $(call mapreads,child))
$(eval $(call mapreads,mother))
ref.fa.bwt: ref.fa
bwa index $<
ref.fa.fai: ref.fa
samtools faidx $<
ref.fa:
wget -O - "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr22.fa.gz" | gunzip -c > $@
wget -O - "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chrM.fa.gz" | gunzip -c >> $@
clean:
rm -f ref.* child.* father.* mother.* result.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment