Source

utils / tophat_align.makefile

Full commit
SHELL = /bin/bash
TOPHAT = /home/dcittaro/tophat-2.0.4.Linux_x86_64/tophat
TOPHAT_OPT = --bowtie1 --library-type fr-unstranded -r -40 
SAMTOOLS = /usr/local/bin/samtools
PICMERGE = /usr/local/bin/MergeSamFiles.jar
PICOPTS = VALIDATION_STRINGENCY=SILENT CREATE_INDEX=true MSD=true ASSUME_SORTED=true

fcid =  $(shell tail -1 SampleSheet.csv | cut -d',' -f1)
reference = $(shell tail -1 SampleSheet.csv | cut -d',' -f4)
ref_genome = /usr/local/scratch/genomes/$(reference)/bowtie/$(reference)
gtf_file = /usr/local/scratch/genomes/$(reference)/annotation/genes.gtf

experiment_name=$(subst Sample_,,$(notdir $(abspath $(dir .))))

r1_fastq := $(wildcard *R1*fastq.gz)
r2_fastq := $(wildcard *R2*fastq.gz)

chunk_bam := $(patsubst %.fastq.gz,%.bam,$(r1_fastq))
chunk_bam := $(subst _R1,,$(chunk_bam))


all: $(chunk_bam)
	java -jar $(PICMERGE) $(foreach bamfile,$^,I=$(bamfile)) \
	O=$(experiment_name).bam \
	CREATE_INDEX=true \
	MSD=true \
	VALIDATION_STRINGENCY=SILENT \
	ASSUME_SORTED=true \
	USE_THREADING=true


$(chunk_bam): $(r1_fastq) $(r2_fastq)
	$(eval lane := $(subst .bam,,$(shell echo $@ | rev | cut -d'_' -f 2 | rev)))
	$(eval rindex := $(subst .bam,,$(shell echo $@ | rev| cut -d'_' -f 3 | rev)))
	$(eval R1 := $(subst .bam,.fastq.gz,$(subst $(experiment_name)_$(rindex)_$(lane),$(experiment_name)_$(rindex)_$(lane)_R1,$@)))
	$(eval R2 := $(subst .bam,.fastq.gz,$(subst $(experiment_name)_$(rindex)_$(lane),$(experiment_name)_$(rindex)_$(lane)_R2,$@)))
	$(TOPHAT) -o $(subst .bam,,$@) $(TOPHAT_OPT)  -G $(gtf_file) $(ref_genome)  $(R1) $(R2)
	mv $(subst .bam,,$@)/accepted_hits.bam $(chunk_bam)