1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
SAM=$(wildcard *.sam)
BAM=$(SAM:%.sam=%.bam)
BAI=$(BAM:%.bam=%.bam.bai)
CRAM=ex1.cram ex2.cram ex3.cram
CRAI=$(CRAM:%.cram=%.cram.crai)
NO_PG:=$(findstring --no-PG,$(shell samtools view '-?'))
# ex2.bam - bam file without index
all: all.stamp
all.stamp: ex1.pileup.gz \
ex1.sam ex1.bam \
ex2.sam.gz ex2.sam ex2.bam ex2.bam.bai \
with_md.sam.gz with_md.bam with_md.bam.bai \
uncompressed.bam \
$(BAM) $(BAI) \
$(CRAM) $(CRAI) \
example_bai.bam \
rg_with_tab.bam \
ex2_truncated.bam \
ex2_corrupt.bam \
empty.bam empty.bam.bai \
explicit_index.bam explicit_index.cram \
faidx_empty_seq.fq.gz \
ex1.fa.gz ex1.fa.gz.fai ex1.fa.gz.gzi \
ex1_csi.bam \
example_reverse_complement.bam \
example_dash_in_chr.bam
touch $@
# ex2.sam - as ex1.sam, but with header
ex2.sam.gz: ex1.bam ex1.bam.bai
samtools view $(NO_PG) -h ex1.bam | gzip > ex2.sam.gz
with_md.sam.gz: ex2.bam ex1.fa
samtools calmd $(NO_PG) --output-fmt BAM $^ > $@
#%.bam: %.sam ex1.fa.fai
# samtools view $(NO_PG) -bo $@ -t ex1.fa.fai $<
uncompressed.bam: ex2.sam
samtools view $(NO_PG) -bu -o $@ $<
%.bam: %.sam
samtools view $(NO_PG) -bo $@ $<
%.cram: %.sam
samtools view $(NO_PG) -Co $@ -T ex1.fa $<
%.cram.crai: %.cram
samtools index $<
%.sam: %.sam.gz
gunzip < $< > $@
%.fa.fai: %.fa
samtools faidx $<
%.fa.gz.fai %.fa.gz.gzi: %.fa.gz
samtools faidx $<
ex1.bam:ex1.sam.gz ex1.fa.fai
samtools view $(NO_PG) -bo ex1.bam -t ex1.fa.fai ex1.sam.gz
%.bam.bai:%.bam
samtools index $<
ex1.pileup.gz:ex1.bam ex1.fa
samtools mpileup -f ex1.fa ex1.bam | gzip > ex1.pileup.gz
ex2_truncated.bam: ex2.bam
dd if=ex2.bam of=ex2_truncated.bam bs=$$((`wc -c < ex2.bam`-512)) count=1
# Append a corrupt read with block_size < sizeof(bam_core_t fields)
ex2_corrupt.bam: ex2.bam
(bgzip -d < $<; printf '\37\0\0\0\1\0\0\0') | bgzip > $@
ex1_csi.bam: ex1.bam
cp ex1.bam ex1_csi.bam
samtools index -c ex1_csi.bam
empty.bam: ex2.sam
grep "^@" $< | samtools view $(NO_PG) -bo $@ -
example_unmapped_reads_no_sq.bam: example_unmapped_reads_no_sq.sam
touch tmp.list
samtools view $(NO_PG) -bo $@ -t tmp.list $<
rm -f tmp.list
example_bai.bam: ex1.bam
cp ex1.bam $@
samtools index $@
mv $@.bai example_bai.bai
explicit_index.bam: ex1.bam
cp ex1.bam $@
explicit_index.cram: ex1.cram
cp ex1.cram $@
clean:
rm -fr *.bai *.csi *.fai *.gzi *.pileup* [A-Za-z]*.cram *.crai \
all.lock all.stamp *~ calDepth *.dSYM pysam_*.sam \
ex2.sam ex2.sam.gz ex1.sam ex1.fa.gz \
with_md.sam.gz \
*.fq.gz
%.fq.gz: %.fq
gzip < $< > $@
%.fa.gz: %.fa
bgzip < $< > $@
|