-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile.samtools
More file actions
executable file
·89 lines (69 loc) · 1.76 KB
/
Copy pathMakefile.samtools
File metadata and controls
executable file
·89 lines (69 loc) · 1.76 KB
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
#!/usr/bin/make -rRf
#-*- makefile -*-
#
# samtools makefile rules
#
.PHONY: samtools-header samtools-settings
.DELETE_ON_ERROR:
.SECONDARY:
MAKEDIR = $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(findstring Makefile.ngsvars,$(MAKEFILE_LIST)),)
include $(MAKEDIR)Makefile.ngsvars
endif
# samtools
ifndef SAMTOOLS
SAMTOOLS=samtools
endif
ifndef SAMTOOLS_THREADS
SAMTOOLS_THREADS=$(THREADS)
endif
ifndef SAMTOOLS_OPTIONS
SAMTOOLS_OPTIONS=
endif
ifndef SAMTOOLS_REF
SAMTOOLS_REF=$(REF)
endif
# Index a FASTA file
%.fa.fai: %.fa
$(SAMTOOLS) faidx $<
# Convert a SAM file to a BAM file
%.bam: %.sam
$(SAMTOOLS) view -Sb - > $@.tmp && mv $@.tmp $@
# Convert a BAM file to a SAM file
%.bam.sam: %.bam
$(SAMTOOLS) view -h $< >$@
# Sort a SAM file and create a BAM file
%.sort.bam: %.sam
$(SAMTOOLS) view -Su $< |$(SAMTOOLS) sort - $*.sort
# Sort a BAM file
%.sort.bam: %.bam
$(SAMTOOLS) sort $< $*.sort
# Sort a BAM file by query name
%.qsort.bam: %.bam
$(SAMTOOLS) sort -no $< - >$@
# Index a BAM file
%.bam.bai: %.bam
$(SAMTOOLS) index $<
# Fix the mate pair information of a BAM file
%.fixmate.bam: %.qsort.bam
$(SAMTOOLS) fixmate $< $@
# Remove duplicates from a BAM file
%.rmdup.bam: %.bam
$(SAMTOOLS) rmdup $< $@
# Count flags of a BAM file
%.flagstat: %.bam
$(SAMTOOLS) flagstat $< >$@
# Report BAM index stats
%.idxstats.tsv: %.bam %.bam.bai
(printf 'tid\tlength\tnumMapped\tnumUnmapped\n' \
&& $(SAMTOOLS) idxstats $<) >$@
##############################
# settings
##############################
.PHONY: samtools-settings samtools-header
print-%:
@echo '$*=$($*)'
samtools-header:
@echo -e "\nMakefile.samtools options"
@echo "========================="
samtools-settings: samtools-header print-SAMTOOLS print-SAMTOOLS_THREADS print-SAMTOOLS_OPTIONS print-SAMTOOLS_REF