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 $<
|