Skip to content

Instantly share code, notes, and snippets.

@lindenb
Created August 30, 2012 13:43
Show Gist options
  • Save lindenb/3528814 to your computer and use it in GitHub Desktop.
Save lindenb/3528814 to your computer and use it in GitHub Desktop.
NGS crash course
#http://samtools.sourceforge.net/mpileup.shtml
SAMDIR=/usr/local/package/samtools-0.1.18
SAMTOOLS=$(SAMDIR)/samtools
BCFTOOLS=$(SAMDIR)/bcftools/bcftools
BWA=/usr/local/package/bwa-0.6.1/bwa
REF=chr22.fa
.INTERMEDIATE : align.sam random_1.sai random_2.sai align.bam variations.bcf
%.bam : %.sam
$(SAMTOOLS) view -o $@ -b -S -T $(REF) $<
%.bam.bai : %.bam
$(SAMTOOLS) index $<
variations.vcf: variations.bcf
$(BCFTOOLS) view $< > $@
variations.bcf : align.sorted.bam align.sorted.bam.bai
$(SAMTOOLS) mpileup -uf $(REF) $< | $(BCFTOOLS) view -bvcg - > $@
align.sorted.bam : align.bam
$(SAMTOOLS) sort $< align.sorted
align.sam : random_1.sai random_2.sai
$(BWA) sampe $(REF) $^ random_1.fq.gz random_2.fq.gz > $@
$(REF):
curl -s "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/$(REF).gz" |\
gunzip -c | grep -v N | head -n 100000 > $@
random_1.sai : random_1.fq.gz $(REF).bwt
$(BWA) aln -f $@ $(REF) $<
random_2.sai : random_2.fq.gz $(REF).bwt
$(BWA) aln -f $@ $(REF) $<
random_1.fq.gz random_2.fq.gz : $(REF)
$(SAMDIR)/misc/wgsim -N 1000000 $< random_1.fq random_2.fq > wgsim.output
gzip -f --best random_1.fq random_2.fq
$(REF).bwt : $(REF)
$(BWA) index -a bwtsw $<
$(REF).fai : $(REF)
$(SAMTOOLS) faidx $<
clean:
rm -f chr22.* *.bam *.vcf *.bcf *.sai *.gz *.fq *.bai wgsim.output *.sam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment