File: consensus.make

package info (click to toggle)
nanopolish 0.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,760 kB
  • sloc: cpp: 22,200; ansic: 1,478; python: 814; makefile: 210; sh: 43; perl: 17
file content (58 lines) | stat: -rwxr-xr-x 1,044 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/make -f

SHELL=/bin/bash -o pipefail
.SECONDARY:

BWA=bwa

# Get the path to the Makefile
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

# Get the name of the input file without a suffix
READS_BASE=$(basename $(READS))

#
# A pipeline to recompute a consensus sequence for an assembly
#
all: $(READS_BASE).pp.sorted.bam $(READS_BASE).pp.sorted.bam.bai $(ASSEMBLY).fai

#
# Preprocess the reads to make a name map
# and uniquify names
#
%.pp.fa: %.fa
	$(ROOT_DIR)/consensus-preprocess.pl $^ > $@

# handle .fasta too
%.pp.fa: %.fasta
	$(ROOT_DIR)/consensus-preprocess.pl $^ > $@

#
# Make bwa index files for the assembly
#
$(ASSEMBLY).bwt: $(ASSEMBLY)
	$(BWA) index $^

#
# Map reads to the assembly using bwa
#
%.pp.bam: %.pp.fa $(ASSEMBLY).bwt
	$(BWA) mem -x ont2d -t 8 $(ASSEMBLY) $< | samtools view -Sb - > $@

#
# Sort BAM
#
%.sorted.bam: %.bam
	samtools sort -f $^ $@

#
# Index BAM
#
%.sorted.bam.bai: %.sorted.bam
	samtools index $^

#
# Index assembly
#
$(ASSEMBLY).fai: $(ASSEMBLY)
	samtools faidx $<