-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathntLink_rounds
executable file
·149 lines (121 loc) · 5.6 KB
/
ntLink_rounds
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/make -rRf
# ntLink: Scaffold assemblies using long reads and minimizers - launching ntLink rounds
# Written by Lauren Coombe @lcoombe
# ntLink v1.3.11
# Window size
w=100
# Kmer size
k=32
# Number of threads
t=4
# Minimum contig size
z=1000
# Number of rounds
rounds=5
# Prefix for output files - required for rounds
prefix=$(target).k$(k).w$(w).z$(z)
# Flag to indicate development run - retain intermediate files (no clean). Set dev=True to enable.
dev=False
# Record run ntLink_time and memory usage in a file using GNU time
v=0
ifeq ($(v), 0)
ntLink_time=
else
ifneq ($(shell command -v gtime),)
ntLink_time=command gtime -v -o [email protected]
else
ntLink_time=command time -v -o [email protected]
endif
endif
# Path to pairing code and other ntLink files
ntlink_path=$(shell dirname $(realpath $(MAKEFILE_LIST)))/bin
# If the ntlink python files are detected already in the PATH,
# assume setup.py has been used for installation, and adjust expected path
ifneq ($(shell command -v ntlink_liftover_mappings.py),)
ntlink_path=$(shell dirname $(command -v ntlink_liftover_mappings.py))
endif
.SECONDARY:
.DELETE_ON_ERROR:
.PHONY: run_rounds run_rounds_gaps check_prefix clean
help:
@echo ""
@echo "ntLink: Scaffolding assemblies using long reads - running iterative rounds of ntLink"
@echo "ntLink v1.3.11"
@echo "Running rounds of ntLink - no gap-filling"
@echo "Usage: ntLink_rounds run_rounds target=<target scaffolds> reads='List of long read files' rounds=<Number>"
@echo ""
@echo "Running rounds of ntLink - with gap-filling"
@echo "Usage: ntLink_rounds run_rounds_gaps target=<target scaffolds> reads='List of long read files' rounds=<Number>"
@echo ""
@echo "Options:"
@echo "rounds Number of rounds of ntLink [5]"
@echo ""
@echo "See main ntLink file for full additional options"
@echo ""
@echo "Note: "
@echo " - Ensure all assembly and read files are in the current working directory, making soft links if necessary"
@echo " - The prefix parameter can not be changed from default for running rounds with ntLink_rounds"
@echo ""
run_targets = $(shell for i in `seq 2 $(rounds)`; do printf "$(target).k$k.w$w.z$z"; for j in `seq 1 $$i`; do printf ".ntLink"; done; printf ".fa "; done )
run_rounds: check_prefix $(target).k$k.w$w.z$z.ntLink.fa \
$(run_targets) \
$(target).k$k.w$w.z$z.ntLink.$(rounds)rounds.fa
run_targets_gaps = $(shell for i in `seq 2 $(rounds)`; do printf "$(target).k$k.w$w.z$z"; for j in `seq 1 $$i`; do printf ".ntLink"; done; printf ".gap_fill.fa "; done )
run_rounds_gaps: check_prefix $(target).k$k.w$w.z$z.ntLink.gap_fill.fa \
$(run_targets_gaps) \
$(target).k$k.w$w.z$z.ntLink.gap_fill.$(rounds)rounds.fa
$(target).k$k.w$w.z$z.ntLink.$(rounds)rounds.fa: $(run_targets)
ln -sf $(lastword $^) $@
echo "Done ntLink rounds! Final scaffolds found in $@"
$(target).k$k.w$w.z$z.ntLink.gap_fill.$(rounds)rounds.fa: $(run_targets_gaps)
ln -sf $(lastword $^) $@
ln -sf $@ $(target).k$k.w$w.z$z.ntLink.$(rounds)rounds.fa
echo "Done ntLink rounds! Final scaffolds found in $(target).k$k.w$w.z$z.ntLink.$(rounds)rounds.fa"
# Check prefix - must be the default for running ntLink rounds
check_prefix:
ifneq ($(prefix), $(target).k$(k).w$(w).z$(z))
$(error "prefix" must be set to the default value (<target>.k<k>.w<w>.z<z>) when running ntLink in rounds)
endif
# First round of ntLink - with gap-filling
$(target).k$k.w$w.z$z.ntLink.gap_fill.fa: $(target) $(reads)
$(ntLink_time) ntLink scaffold gap_fill target=$< reads=$(reads) k=$k w=$w z=$z
ln -sf $(target).k$k.w$w.z$z.ntLink.scaffolds.gap_fill.fa $(target).k$k.w$w.z$z.ntLink.gap_fill.fa
ln -sf $(target).k$k.w$w.z$z.ntLink.scaffolds.gap_fill.fa.agp $(target).k$k.w$w.z$z.ntLink.gap_fill.fa.agp
ln -sf $(target).k$k.w$w.z$z.verbose_mapping.tsv $(target).k$k.w$w.z$z.ntLink.gap_fill.fa.verbose_mapping.tsv
ifneq ($(dev), True)
ntLink clean extra_clean target=$< reads=$(reads) k=$k w=$w z=$z
endif
# First round of ntLink - no gap-filling
$(target).k$k.w$w.z$z.ntLink.fa: $(target) $(reads)
$(ntLink_time) ntLink scaffold target=$< reads=$(reads) k=$k w=$w z=$z
ln -sf $(target).k$k.w$w.z$z.ntLink.scaffolds.fa $(target).k$k.w$w.z$z.ntLink.fa
ln -sf $(target).k$k.w$w.z$z.trimmed_scafs.agp $(target).k$k.w$w.z$z.ntLink.fa.agp
ln -sf $(target).k$k.w$w.z$z.verbose_mapping.tsv $(target).k$k.w$w.z$z.ntLink.fa.verbose_mapping.tsv
ifneq ($(dev), True)
ntLink clean extra_clean target=$< reads=$(reads) k=$k w=$w z=$z
endif
# Liftover
%.fa.k$k.w$w.z$z.verbose_mapping.tsv: %.fa
$(ntLink_time) $(ntlink_path)/ntlink_liftover_mappings.py -k $k \
-a $*.fa.agp -m $*.fa.verbose_mapping.tsv -o $@
# Subsequent rounds of ntLink - gap-filling
%.ntLink.gap_fill.fa: %.gap_fill.fa $(reads) %.gap_fill.fa.k$k.w$w.z$z.verbose_mapping.tsv
$(ntLink_time) ntLink scaffold gap_fill target=$< reads=$(reads) k=$k w=$w z=$z
ln -sf $*.gap_fill.fa.k$k.w$w.z$z.ntLink.scaffolds.gap_fill.fa $@
ln -sf $*.gap_fill.fa.k$k.w$w.z$z.ntLink.scaffolds.gap_fill.fa.agp $*.ntLink.gap_fill.fa.agp
ln -sf $*.gap_fill.fa.k$k.w$w.z$z.verbose_mapping.tsv $*.ntLink.gap_fill.fa.verbose_mapping.tsv
ifneq ($(dev), True)
ntLink clean extra_clean target=$< reads=$(reads) k=$k w=$w z=$z
endif
# Subsequent rounds of ntLink - no gap-filling
%.ntLink.fa: %.fa $(reads) %.fa.k$k.w$w.z$z.verbose_mapping.tsv
$(ntLink_time) ntLink scaffold target=$< reads=$(reads) k=$k w=$w z=$z
ln -sf $*.fa.k$k.w$w.z$z.ntLink.scaffolds.fa $@
ln -sf $*.fa.k$k.w$w.z$z.trimmed_scafs.agp $*.ntLink.fa.agp
ln -sf $*.fa.k$k.w$w.z$z.verbose_mapping.tsv $*.ntLink.fa.verbose_mapping.tsv
ifneq ($(dev), True)
ntLink clean extra_clean target=$< reads=$(reads) k=$k w=$w z=$z
endif
# Clean up files
clean:
rm -f $(prefix).*verbose_mapping.tsv