forked from JustinChu/JupiterPlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjupiter
executable file
·100 lines (76 loc) · 2.67 KB
/
jupiter
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
#!/usr/bin/make -Rrf
ifdef profile
SHELL=/usr/bin/time -f '=> jupiter: %e %C' /bin/bash -o pipefail
else
SHELL=/bin/bash -o pipefail
endif
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
#------------------------------------------------------------
# params
#------------------------------------------------------------
ng=75
maxScaff=-1
maxGap=100000
minBundleSize=50000
m=100000
g=1
gScaff=100000
i=0
t=4
#------------------------------------------------------------
# meta rules
#------------------------------------------------------------
.PRECIOUS: %-agp.sam %.agp %.bed %.links.final %.fai
.DELETE_ON_ERROR:
.PHONY: check-params generateplot
default: generateplot
generateplot: check-params $(name).svg
check-name-param:
ifndef name
$(error missing required param 'name' (output file prefix))
endif
check-params: check-name-param
ifndef ref
$(error missing required param 'ref' (FASTA reference file))
endif
ifndef fa
$(error missing required param 'fa' (FASTA contigs file))
endif
#optional command for sam files
ifdef sam
$(attempting to skip alignments given $(sam))
endif
#------------------------------------------------------------
# pipeline rules
#------------------------------------------------------------
$(name)_reference.fa: $(ref)
ln -s $< $@
$(name)_scaffolds.fa: $(fa)
ln -s $< $@
# index FASTA file
%.fa.fai: %.fa
samtools faidx $<
%.agp %-agp.fa : %_scaffolds.fa
perl $(ROOT_DIR)/bin/fatoagp.pl -f $*-agp.fa $< > $*.agp
ifdef sam
$(name)-agp.sam: $(sam)
ln -s $< $@
else
%-agp.sam: %_reference.fa %-agp.fa
minimap2 -ax asm10 -t $(t) $*_reference.fa $*-agp.fa > $@
endif
%.bed: %.sam
grep -v XA $< | grep -v '^@' | awk '{if($$5 > 50 || $$5 == "" ) print}' | perl $(ROOT_DIR)/bin/samToBed.pl > $@
%.conf %.karyotype %.rv.links %.fw.links %.seqOrder.txt: %.agp %-agp.bed %_reference.karyotype %_scaffolds.fa
perl $(ROOT_DIR)/bin/generateConf.pl -n $(ng) -m $(maxScaff) -r $(ROOT_DIR)/config/rawConf.conf -p $* -s $*_scaffolds.fa -b $*-agp.bed -a $*.agp -k $*_reference.karyotype -g $(gScaff)
$(name)_reference.karyotype: $(name)_reference.fa
perl $(ROOT_DIR)/bin/generateKaryotype.pl -g $(g) -i $(i) -m $(m) $(name)_reference.fa > $@
%.links.bundled: %.links
cat $< | perl $(ROOT_DIR)/circos-tools-0.22/tools/bundlelinks/bin/bundlelinks -max_gap $(maxGap) -min_bundle_size $(minBundleSize) > $@
#cat $< | perl $(ROOT_DIR)/bin/linkCollapse.pl -m $(maxGap) -b $(minBundleSize) > $@ #simple bundle
%.fw.links.bundled.flipped : %.fw.links.bundled
awk ' { t = $$5; $$5 = $$6; $$6 = t; print; } ' $< > $@
%.links.final : %.rv.links.bundled %.fw.links.bundled.flipped
cat $^ > $@
%.svg: %.conf %.karyotype %.links.final
circos -noparanoid -conf $<