Debian Codegraph @

bin/abyss-pe

raw ◀ ▶
1 Debian patch touch this file
1 #!/usr/bin/make -rRf
2 # Run the ABySS assembler.
3 # Written by Shaun Jackman <[email protected]> and
4 # Anthony Raymond <[email protected]>.
5
•6 PATH:=/usr/lib/abyss:${PATH}
7
8 SHELL=bash -e -o pipefail
9 ifeq ($(shell zsh -e -o pipefail -c 'true' 2>/dev/null; echo $$?), 0)
10 # Set pipefail to ensure that all commands of a pipe succeed.
11 SHELL=zsh -e -o pipefail
12 # Report run time and memory usage with zsh.
13 export REPORTTIME=1
14 export TIMEFMT=time user=%U system=%S elapsed=%E cpu=%P memory=%M job=%J
15 endif
16
17 # Record run time and memory usage in a file using GNU time.
18 ifdef time
19 ifneq ($(shell command -v gtime),)
20 gtime=command gtime -v -o [email protected]
21 else
22 gtime=command time -v -o [email protected]
23 endif
24 endif
25
26 # Wrapper script for commands that require an increased stack size limit
27 stack=abyss-stack-size 65536
28
29 # Define this environment variable on Mac OS X to read
30 # compressed files.
31 export DYLD_FORCE_FLAT_NAMESPACE=1
32
33 # Integrate with Sun Grid Engine (SGE)
34 ifdef JOB_NAME
35 name?=$(JOB_NAME)
36 endif
37 ifdef SGE_TASK_ID
38 k?=$(SGE_TASK_ID)
39 endif
40 ifdef NSLOTS
41 ifneq ($(NSLOTS), 1)
42 np?=$(NSLOTS)
43 endif
44 endif
45
46 # Integrate with Portable Batch System (PBS)
47 ifdef PBS_JOBNAME
48 name?=$(PBS_JOBNAME)
49 endif
50 ifdef PBS_ARRAYID
51 k?=$(PBS_ARRAYID)
52 endif
53 ifdef PBS_NODEFILE
54 NSLOTS=$(shell wc -l <$(PBS_NODEFILE))
55 ifneq ($(NSLOTS), 1)
56 np?=$(NSLOTS)
57 endif
58 endif
59
60 # Integrate with Load Sharing Facility (LSF)
61 ifdef LSB_JOBNAME
62 name?=$(LSB_JOBNAME)
63 endif
64 ifdef LSB_JOBINDEX
65 k?=$(LSB_JOBINDEX)
66 endif
67 ifdef LSB_DJOB_NUMPROC
68 ifneq ($(LSB_DJOB_NUMPROC), 1)
69 np?=$(LSB_DJOB_NUMPROC)
70 endif
71 endif
72 ifdef LSF_BINDIR
73 mpirun?=$(LSF_BINDIR)/mpirun.lsf
74 endif
75
76 # Integrate with IBM LoadLeveler
77 ifdef LOADL_JOB_NAME
78 name?=$(LOADL_JOB_NAME)
79 endif
80 ifdef LOADL_STEP_ID
81 k?=$(LOADL_STEP_ID)
82 endif
83 ifdef LOADL_HOSTFILE
84 NSLOTS=$(shell wc -l <$(LOADL_HOSTFILE))
85 ifneq ($(NSLOTS), 1)
86 np?=$(NSLOTS)
87 endif
88 endif
89
90 # Integrate with SLURM
91 ifdef SLURM_JOB_NAME
92 name?=$(SLURM_JOB_NAME)
93 endif
94 ifdef SLURM_ARRAY_TASK_ID
95 k?=$(SLURM_ARRAY_TASK_ID)
96 endif
97 ifdef SLURM_NTASKS
98 np?=$(SLURM_NTASKS)
99 endif
100
101 # Determine the path to mpirun
102 mpirun?=$(shell command -v mpirun)
103 ifeq ($(mpirun),)
104 mpirun=mpirun
105 endif
106
107 # Use pigz or bgzip for parallel compression if available.
108 ifneq ($(shell command -v pigz),)
109 gzip=pigz -p$j
110 else
111 ifneq ($(shell command -v bgzip),)
112 gzip=bgzip -@$j
113 else
114 gzip=gzip
115 endif
116 endif
117
118 ifndef preserve_path
119 # Determine the path to the ABySS executables
120 path?=$(shell dirname `command -v $(MAKEFILE_LIST)`)
121 ifdef path
122 PATH:=$(path):$(PATH)
123 endif
124 endif
125
126 ifdef db
127 # Determine the location of sqlite database
128 override dbopt:=--db=$(db)
129
130 # Track data details for database
131 library ?= ""
132 strain ?= ""
133 species ?= ""
134 endif
135
136 # Programs
137 MARKDOWN=pandoc
138
139 map=$(foreach a,$(2),$(call $(1),$(a)))
140 deref=$($1)
141
142 ifdef lr
143 ifndef lib
144 lib:=$(pe) $(lr)
145 endif
146 endif
147
148 ifdef lib
149 in?=$(call map, deref, $(lib))
150 else
151 ifdef in
152 lib?=$(name)
153 $(lib)?=$(in)
154 endif
155 endif
156
157 pe?=$(lib)
158 ifdef mp
159 mp_provided=1
160 endif
161 mp?=$(pe)
162
163 # Strip spaces from the file paths
164 ifdef in
165 override in:=$(strip $(in))
166 endif
167 ifdef se
168 override se:=$(strip $(se))
169 endif
170 ifdef lr
171 override lr_reads=$(strip $(call map, deref, $(lr)))
172 endif
173
174 # Graph file format
175 graph?=dot
176 # g is private. Use graph instead.
177 override g:=$(graph)
178
179 # Number of threads
180 ifdef PE_HOSTFILE
181 hostname?=$(shell hostname -f)
182 j?=$(shell awk '$$1 == "$(hostname)" {print $$2}' $(PE_HOSTFILE))
183 endif
184 ifeq ($j,)
185 j:=$(np)
186 endif
187 ifeq ($j,)
188 j:=2
189 endif
190
191 # ABYSS parameters
192 q ?= 3
193 abyssopt += -k$k -q$q
194 ifdef K
195 abyssopt += -K$K
196 endif
197 ifdef e
198 abyssopt += -e$e
199 endif
200 ifdef E
201 abyssopt += -E$E
202 endif
203 ifdef t
204 abyssopt += -t$t
205 endif
206 ifdef c
207 abyssopt += -c$c
208 endif
209 ifdef kc
210 abyssopt += --kc=$(kc)
211 endif
212 ifdef b
213 abyssopt += -b$b
214 pbopt += -b$b
215 endif
216 ifdef Q
217 abyssopt += -Q$Q
218 endif
219 ifdef ss
220 SS=--SS
221 endif
222 abyssopt += $v
223
224 # additional params for Bloom filter assembly (`abyss-bloom-dbg`)
225 ifdef B
226 abyssopt += -b$B
227 ifdef H
228 abyssopt += -H$H
229 endif
230 ifdef j
231 abyssopt += -j$j
232 endif
233 ifdef x
234 abyssopt += -s$x
235 endif
236 else
237 abyssopt += $(dbopt) $(SS) --coverage-hist=coverage.hist -s $*-bubbles.fa
238 endif
239
240 # AdjList parameters
241 ifdef mp_provided
242 m?=0
243 else ifeq ($(shell test $(k) -le 50; echo $$?),0)
244 m?=0
245 else
246 m?=50
247 endif
248 alopt += $v $(dbopt) $(SS) -k$k -m$m
249 ifndef B
250 ifdef K
251 alopt += -K$K
252 endif
253 endif
254
255 # filtergraph parameters
256 ifndef B
257 ifdef K
258 fgopt += --assemble --shim-max-degree=2
259 endif
260 endif
261 ifdef xtip
262 fgopt += -t$(shell echo $k*2 |bc)
263 endif
264
265 # PopBubbles parameters
266 p?=0.9
267 pbopt += -p$p
268 ifdef a
269 pbopt += -a$a
270 endif
271
272 # Keep sequence and quality strings of read alignments
273 ifdef ssq
274 ssq_t :=-ssq
275 endif
276
277 # Aligner parameters
278 aligner?=map$(ssq_t)
279 ifeq ($(SS),--SS)
280 ifneq ($(aligner),map$(ssq_t))
281 $(warning warning: setting aligner to abyss-map$(ssq_t) since other aligners do not support ss=1)
282 override aligner=map$(ssq_t)
283 endif
284 endif
285
286 align?=abyss-$(aligner)
287 mapopt=$v $(dbopt) -j$j -l$($*_l) $(SS) $(ALIGNER_OPTIONS) $(MAP_OPTIONS)
288
289 # DIDA parameters
290 escape_quotes=$(shell echo "$(1)" | sed 's|"|\\\"|g')
291 ifeq ($(aligner),dida)
292 ifdef np
293 mapopt+=-n$(np)
294 endif
295 ifdef DIDA_RUN_OPTIONS
296 mapopt+=$(DIDA_RUN_OPTIONS)
297 endif
298 ifdef DIDA_MPIRUN
299 mapopt+=-m"$(call escape_quotes,$(DIDA_MPIRUN))"
300 endif
301 ifdef DIDA_OPTIONS
302 mapopt+=-d"$(call escape_quotes,$(DIDA_OPTIONS))"
303 endif
304 endif
305
306 # fixmate parameters
307 ifeq ($(align),abyss-kaligner)
308 fixmate?=ParseAligns
309 else
310 fixmate?=abyss-fixmate$(ssq_t)
311 endif
312 fmopt=$v $(dbopt) -l$($*_l) $(FIXMATE_OPTIONS)
313
314 # DistanceEst parameters
315 DistanceEst?=DistanceEst$(ssq_t)
316 l?=40
317 s?=1000
318 n?=10
319 $(foreach i,$(pe),$(eval $i_l?=$l))
320 $(foreach i,$(pe),$(eval $i_s?=$s))
321 $(foreach i,$(pe),$(eval $i_n?=$n))
322 override deopt=$v $(dbopt) -j$j -k$k $(DISTANCEEST_OPTIONS) -l$($*_l) -s$($*_s) -n$($*_n) $($*_de)
323
324 # SimpleGraph parameters
325 sgopt += $(dbopt) -s$s -n$n
326 ifdef d
327 sgopt += -d$d
328 endif
329
330 # MergePaths parameters
331 mpopt += $v $(dbopt) -j$j -k$k -s$s
332 ifdef G
333 mpopt += -G$G
334 endif
335
336 # PathOverlap parameters
337 poopt += $v $(dbopt) -k$k
338
339 # PathConsensus parameters
340 pcopt += $(dbopt)
341 ifdef a
342 pcopt += -a$a
343 endif
344 pcopt += -p$p
345
346 # MergeContigs parameters
347 mcopt += $v $(dbopt) -k$k
348
349 # Scaffold parameters
350 L?=$l
351 S?=100-5000
352 N?=15-20
353 SCAFFOLD_DE_S?=$(shell echo $S | sed 's/-.*//')
354 SCAFFOLD_DE_N?=$(shell echo $N | sed 's/-.*//')
355 SCAFFOLD_DE_OPTIONS?=$(DISTANCEEST_OPTIONS)
356 $(foreach i,$(mp),$(eval $i_scaf_l?=$L))
357 $(foreach i,$(mp),$(eval $i_scaf_s?=$(SCAFFOLD_DE_S)))
358 $(foreach i,$(mp),$(eval $i_scaf_n?=$(SCAFFOLD_DE_N)))
359 override scaffold_deopt=$v $(dbopt) --dot --median -j$j -k$k $(SCAFFOLD_DE_OPTIONS) -l$($*_scaf_l) -s$($*_scaf_s) -n$($*_scaf_n) $($*_de)
360 scopt += $v $(dbopt) $(SS) -k$k
361 ifdef G
362 scopt += -G$G
363 endif
364
365 # abyss-fac parameters
366 ifdef G
367 override facopt = -G$G
368 endif
369
370 # BWA-SW parameters
371 bwaswopt=-t$j
372 BWASW_OPTIONS='-b9 -q16 -r1 -w500'
373
374 # Remove environment variables
375 unexport in se $(lib) $(pe) $(mp) $(long)
376
377 # Check the mandatory parameters
378
379 ifndef name
380 error::
381 @>&2 echo 'abyss-pe: missing parameter `name`'
382 endif
383 ifndef k
384 error::
385 @>&2 echo 'abyss-pe: missing parameter `k`'
386 endif
387 ifeq ($(lib)$(in)$(se)$(lr),)
388 error::
389 @>&2 echo 'abyss-pe: missing parameter `lib`, `in`, `se`, or `lr`'
390 endif
391
392 ifndef B
393 ifndef np
394 error::
395 @>&2 echo 'abyss-pe: must specify either `B` or `np` for the Bloom filter and MPI modes respectively. Bloom filter mode is recommended.'
396 endif
397 endif
398
399 default:
400
401 error::
402 @>&2 echo 'Try `abyss-pe help` for more information.'
403 @false
404
405 # Help and version messages
406
407 help:
408 @echo 'Usage: abyss-pe [OPTION]... [PARAMETER=VALUE]... [COMMAND]...'
409 @echo 'Assemble reads into contigs and scaffolds. ABySS is a de novo'
410 @echo 'sequence assembler intended for short paired-end reads and'
411 @echo 'genomes of all sizes. See the abyss-pe man page for documentation'
412 @echo 'of assembly parameters and commands. abyss-pe is a Makefile'
413 @echo 'script, and so options of `make` may also be used with abyss-pe.'
414 @echo 'See the `make` man page for documentation.'
415 @echo
416 @echo 'Report bugs to https://github.com/bcgsc/abyss/issues or [email protected].'
417
418 version:
419 @echo "abyss-pe (ABySS) 2.3.10"
420 @echo "Written by Shaun Jackman and Anthony Raymond."
421 @echo
422 @echo "Copyright 2012 Canada's Michael Smith Genome Science Centre"
423
424 versions: version
425 @echo PATH=$(PATH)
426 @ABYSS --version; echo
427 @-ABYSS-P --version; echo
428 @AdjList --version; echo
429 @DistanceEst --version; echo
430 @MergeContigs --version; echo
431 @MergePaths --version; echo
432 @Overlap --version; echo
433 @PathConsensus --version; echo
434 @PathOverlap --version; echo
435 @PopBubbles --version; echo
436 @SimpleGraph --version; echo
437 @abyss-fac --version; echo
438 @abyss-filtergraph --version; echo
439 @abyss-fixmate --version; echo
440 @abyss-map --version; echo
441 @abyss-scaffold --version; echo
442 @abyss-sealer --version; echo
443 @abyss-todot --version; echo
444 @abyss-rresolver-short --version; echo
445 @$(align) --version; echo
446 @awk --version; echo
447 @sort --version; echo
448 @-mpirun --version
449
450 # Determine the default target
451 ifdef db
452 default: startDb
453 endif
454 default: unitigs
455 ifneq ($(in),)
456 default: contigs contigs-graph
457 endif
458 ifneq ($(mp),)
459 default: scaffolds scaffolds-graph
460 ifneq ($(long),)
461 default: long-scaffs long-scaffs-graph
462 endif
463 endif
464 ifdef db
465 default: finishDb
466 endif
467 default: stats
468
469 # Define the commands (phony targets)
470 unitigs: $(name)-unitigs.fa
471
472 unitigs-graph: $(name)-unitigs.$g
473
474 pe-index: $(name)-3.fa.fm
475
476 pe-sam: $(addsuffix -3.sam.gz, $(pe))
477
478 pe-bam: $(addsuffix -3.bam.bai, $(pe))
479
480 contigs: $(name)-contigs.fa
481
482 contigs-graph: $(name)-contigs.$g
483
484 mp-index: $(name)-6.fa.fm
485
486 mp-sam: $(addsuffix -6.sam.gz, $(mp))
487
488 mp-bam: $(addsuffix -6.bam.bai, $(mp))
489
490 scaffolds: $(name)-scaffolds.fa
491
492 scaffolds-graph: $(name)-scaffolds.$g
493
494 seal-scaffolds: $(name)-scaffolds-sealed.fa
495
496 scaftigs: $(name)-scaftigs.fa $(name)-scaftigs.agp
497
498 long-scaffs: $(name)-long-scaffs.fa
499
500 long-scaffs-graph: $(name)-long-scaffs.$g
501
502 all: default bam stats
503
504 clean:
505 rm -f *.adj *.asqg *.dot *.gfa *.sam *.txt \
506 *.sam.gz *.hist *.dist *.path *.path[123]
507
508 ifdef db
509 .PHONY: startDb finishDb
510 endif
511
512 .PHONY: bam default stats \
513 unitigs unitigs-graph \
514 pe-index pe-sam pe-bam contigs contigs-graph \
515 mp-index mp-sam mp-bam scaffolds scaffolds-graph \
516 scaftigs long-scaffs long-scaffs-graph seal-scaffolds \
517 all clean help version versions
518
519 .DELETE_ON_ERROR:
520 .SECONDARY:
521
522 # Utilities
523
524 %.fa.fai: %.fa
525 abyss-index $v --fai $<
526
527 %.fa.fm: %.fa
528 abyss-index $v $<
529
530 %.bam: %.sam.gz
531 samtools view -Sb $< -o $@
532
533 %.bam.bai: %.bam
534 samtools index $<
535
536 # Assemble unitigs
537
538 ifdef db
539 startDb:
540 @echo -e \
541 $(name)".sqlite\n"\
542 > name.txt
543 @echo -e \
544 $(shell echo `date +%s`"_"`whoami`_)\
545 $(shell echo $$RANDOM \% 1000 \+ 1 | bc)"\n"\
546 $(library)"\n"\
547 $(strain)"\n"\
548 $(species)"\n"\
549 $(name)"\n"\
550 $(k)"\n"\
551 $(lib)$(in)$(se)\
552 > db.txt
553 endif
554
555 ifdef B
556 %-1.fa:
557 $(gtime) $(stack) abyss-bloom-dbg $(abyssopt) $(ABYSS_OPTIONS) $(in) $(se) > $@
558 else ifdef K
559
560 ifdef np
561 %-1.fa:
562 $(gtime) $(mpirun) -np $(np) abyss-paired-dbg-mpi $(abyssopt) $(ABYSS_OPTIONS) -o $*-1.fa $(in) $(se)
563 else
564 %-1.fa %-1.$g:
565 $(gtime) abyss-paired-dbg $(abyssopt) $(ABYSS_OPTIONS) -o $*-1.fa -g $*-1.$g $(in) $(se)
566 endif
567
568 else ifdef np
569 %-1.fa:
570 $(gtime) $(mpirun) -np $(np) ABYSS-P $(abyssopt) $(ABYSS_OPTIONS) -o $@ $(in) $(se)
571 else
572 %-1.fa:
573 $(gtime) ABYSS $(abyssopt) $(ABYSS_OPTIONS) -o $@ $(in) $(se)
574 endif
575
576 # Find overlapping contigs
577
578 %-1.$g: %-1.fa
579 $(gtime) AdjList $(alopt) --$g $< >$@
580
581 # Resolve repeats with short reads
582
583 ifdef B
584 %-1-rr.fa %-1-rr.$g: %-1.fa %-1.$g
585 $(gtime) abyss-rresolver-short $v -b$B -f0.8 -j$j -k$k \
586 $(RRESOLVER_OPTIONS) -h $*-1-rr --$g -c $*-1-rr.fa \
587 -g $*-1-rr.$g $^ $(in) $(se)
588 else
589 %-1-rr.fa: %-1.fa
590 ln -s $< $@
591
592 %-1-rr.$g: %-1.$g
593 ln -s $< $@
594 endif
595
596 # Remove shim contigs
597
598 %-2.$g1 %-1-rr.path: %-1-rr.$g %-1-rr.fa
599 $(gtime) abyss-filtergraph $v --$g $(fgopt) $(FILTERGRAPH_OPTIONS) -k$k -g $*-2.$g1 $^ >$*-1-rr.path
600
601 %-2.fa %-2.$g: %-1-rr.fa %-2.$g1 %-1-rr.path
602 $(gtime) MergeContigs --$g $(mcopt) -g $*-2.$g -o $*-2.fa $^
603
604 # Pop bubbles
605
606 %-2.path %-3.$g: %-2.fa %-2.$g
607 $(gtime) PopBubbles $v --$g -j$j -k$k $(SS) $(pbopt) $(POPBUBBLES_OPTIONS) -g $*-3.$g $^ >$*-2.path
608
609 %-3.fa: %-2.fa %-2.$g %-2.path
610 $(gtime) MergeContigs $(mcopt) -o $@ $^
611 awk '!/^>/ {x[">" $$1]=1; next} {getline s} $$1 in x {print $$0 "\n" s}' \
612 $*-2.path $*-1-rr.fa >$*-indel.fa
613
614 %-unitigs.fa: %-3.fa
615 ln -sf $< $@
616
617 %-unitigs.$g: %-3.$g
618 ln -sf $< $@
619
620 # Estimate distances between unitigs
621
622 %-3.sam.gz %-3.hist: $(name)-3.fa
623 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
624 |$(fixmate) $(fmopt) -h $*-3.hist \
625 |sort -snk3 -k4 \
626 |$(gzip) >$*-3.sam.gz
627
628 %-3.bam %-3.hist: $(name)-3.fa
629 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
630 |$(fixmate) $(fmopt) -h $*-3.hist \
631 |sort -snk3 -k4 \
632 |samtools view -Sb - -o $*-3.bam
633
634 %-3.dist: %-3.sam.gz %-3.hist
635 gunzip -c $< \
636 |$(gtime) $(DistanceEst) $(deopt) -o $@ $*-3.hist
637
638 %-3.dist: %-3.bam %-3.hist
639 $(gtime) samtools view -h $< \
640 |$(DistanceEst) $(deopt) -o $@ $*-3.hist
641
642 %-3.dist: $(name)-3.fa
643 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
644 |$(fixmate) $(fmopt) -h $*-3.hist \
645 |sort -snk3 -k4 \
646 |$(DistanceEst) $(deopt) -o $@ $*-3.hist
647
648 dist=$(addsuffix -3.dist, $(pe))
649
650 ifneq ($(name)-3.dist, $(dist))
651 $(name)-3.dist: $(name)-3.fa $(dist)
652 $(gtime) abyss-todot $v --dist -e $^ >$@
653
654 $(name)-3.bam: $(addsuffix -3.bam, $(pe))
655 $(gtime) samtools merge -r $@ $^
656 endif
657
658 # Find overlaps between contigs
659
660 %-4.fa %-4.$g: %-3.fa %-3.$g %-3.dist
661 $(gtime) Overlap $v --$g $(SS) $(OVERLAP_OPTIONS) -k$k -g $*-4.$g -o $*-4.fa $^
662
663 # Assemble contigs
664
665 %-4.path1: %-4.$g %-3.dist
666 $(gtime) $(stack) SimpleGraph $v $(sgopt) $(SIMPLEGRAPH_OPTIONS) -j$j -k$k -o $@ $^
667
668 %-4.path2: %-4.path1 %-3.fa.fai %-4.fa.fai
669 cat $*-3.fa.fai $*-4.fa.fai \
670 |$(gtime) MergePaths $(mpopt) $(MERGEPATHS_OPTIONS) -o $@ - $<
671
672 %-4.path3: %-4.$g %-4.path2
673 PathOverlap --assemble $(poopt) $(SS) $^ >$@
674
675 ifndef cs
676
677 %-5.path %-5.fa %-5.$g: %-3.fa %-4.fa %-4.$g %-4.path3
678 cat $(wordlist 1, 2, $^) \
679 |$(gtime) $(stack) PathConsensus $v --$g -k$k $(pcopt) $(PATHCONSENSUS_OPTIONS) -o $*-5.path -s $*-5.fa -g $*-5.$g - $(wordlist 3, 4, $^)
680
681 %-6.fa: %-3.fa %-4.fa %-5.fa %-5.$g %-5.path
682 cat $(wordlist 1, 3, $^) |$(gtime) MergeContigs $(mcopt) -o $@ - $(wordlist 4, 5, $^)
683
684 else
685
686 %-5.$g %-5.path: %-4.$g %-4.path3
687 ln -sf $*-4.$g $*-5.$g
688 ln -sf $*-4.path3 $*-5.path
689
690 %-cs.fa: %-3.fa %-4.fa %-4.$g %-4.path3
691 cat $(wordlist 1, 2, $^) |$(gtime) MergeContigs $(mcopt) -o $@ - $(wordlist 3, 4, $^)
692
693 # Convert colour-space sequence to nucleotides
694
695 %-6.fa: %-cs.fa
696 $(gtime) KAligner $v --seq -m -j$j -l$l $(in) $(se) $< \
697 |Consensus $v -o $@ $<
698
699 endif
700
701 %-6.$g: %-5.$g %-5.path
702 $(gtime) PathOverlap --overlap $(poopt) --$g $^ >$@
703
704 %-contigs.fa: %-6.fa
705 ln -sf $< $@
706
707 %-contigs.$g: %-6.$g
708 ln -sf $< $@
709
710 # Estimate distances between contigs
711
712 %-6.sam.gz %-6.hist: $(name)-6.fa
713 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
714 |$(fixmate) $(fmopt) -h $*-6.hist \
715 |sort -snk3 -k4 \
716 |$(gzip) >$*-6.sam.gz
717
718 %-6.bam %-6.hist: $(name)-6.fa
719 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
720 |$(fixmate) $(fmopt) -h $*-6.hist \
721 |sort -snk3 -k4 \
722 |samtools view -Sb - -o $*-6.bam
723
724 %-6.dist.dot: %-6.sam.gz %-6.hist
725 gunzip -c $< \
726 |$(gtime) $(DistanceEst) $(scaffold_deopt) -o $@ $*-6.hist
727
728 %-6.dist.dot: %-6.bam %-6.hist
729 samtools view -h $< \
730 |$(gtime) $(DistanceEst) $(scaffold_deopt) -o $@ $*-6.hist
731
732 %-6.dist.dot: $(name)-6.fa
733 $(gtime) $(align) $(mapopt) $(strip $($*)) $< \
734 |$(fixmate) $(fmopt) -h $*-6.hist \
735 |sort -snk3 -k4 \
736 |$(DistanceEst) $(scaffold_deopt) -o $@ $*-6.hist
737
738 # Scaffold
739
740 %-6.path: $(name)-6.$g $(addsuffix -6.dist.dot, $(mp))
741 $(gtime) abyss-scaffold $(scopt) -s$S -n$N -g [email protected] $(SCAFFOLD_OPTIONS) $^ >$@
742
743 %-7.path %-7.$g %-7.fa: %-6.fa %-6.$g %-6.path
744 $(gtime) $(stack) PathConsensus $v --$g -k$k $(pcopt) $(PATHCONSENSUS_OPTIONS) -s $*-7.fa -g $*-7.$g -o $*-7.path $^
745
746 %-8.fa: %-6.fa %-7.fa %-7.$g %-7.path
747 cat $(wordlist 1, 2, $^) \
748 |$(gtime) MergeContigs $(mcopt) -o $@ - $(wordlist 3, 4, $^)
749
750 %-8.$g: %-7.$g %-7.path
751 $(gtime) PathOverlap --overlap $(poopt) --$g $^ >$@
752
753 # Scaffold using linked reads
754 ifdef lr
755
756 # Tigmint
757
758 # Options for mapping the reads to the draft assembly.
759 lr_l?=$l
760 override lrmapopt=$v -j$j -l$(lr_l) $(LR_MAP_OPTIONS)
761
762 # Options for abyss-scaffold
763 lr_s?=1000-100000
764 lr_n?=5-20
765
766 # Minimum AS/Read length ratio
767 tigmint_as?=0.65
768
769 # Maximum number of mismatches
770 tigmint_nm?=5
771
772 # Minimum mapping quality threshold
773 tigmint_mapq?=0
774
775 # Maximum distance between reads to be considered the same molecule
776 tigmint_d?=50000
777
778 # Minimum number of spanning molecules
779 tigmint_n?=10
780
781 # Size of the window that must be spanned by moecules
782 tigmint_w?=1000
783
784 # Align paired-end reads to the draft genome, sort by BX tag,
785 # and create molecule extents BED.
786 %.lr.bed: %.fa.fai
787 $(gtime) $(align) $(lrmapopt) $(lr_reads) $*.fa \
788 | samtools sort -@$j -tBX -l0 -T$$(mktemp -u -t [email protected]) \
789 | tigmint-molecule -a $(tigmint_as) -n $(tigmint_nm) -q $(tigmint_mapq) -d $(tigmint_d) - \
790 | sort -k1,1 -k2,2n -k3,3n >$@
791
792 # Align paired-end reads to the draft genome and sort by BX tag.
793 %.lr.sortbx.bam: %.fa.fai
794 $(gtime) $(align) $(lrmapopt) $(lr_reads) $*.fa \
795 | samtools sort -@$j -tBX -T$$(mktemp -u -t [email protected]) -o $@
796
797 # Filter the BAM file, create molecule extents BED.
798 %.lr.bed: %.lr.sortbx.bam
799 $(gtime) tigmint-molecule -a $(tigmint_as) -n $(tigmint_nm) -q $(tigmint_mapq) -d $(tigmint_d) $< \
800 | sort -k1,1 -k2,2n -k3,3n >$@
801
802 # Cut sequences at assembly errors.
803 %.tigmint.fa: %.lr.bed %.fa %.fa.fai
804 $(gtime) tigmint-cut -p$j -n$(tigmint_n) -w$(tigmint_w) -o $@ $*.fa $<
805
806 # ARCS
807 arcs_c?=2
808 arcs_d?=0
809 arcs_e?=30000
810 arcs_l?=0
811 arcs_m?=4-20000
812 arcs_r?=0.05
813 arcs_s?=98
814 arcs_z?=500
815
816 # Align reads and create a graph of linked contigs using ARCS.
817 %.arcs.dist.gv: %.fa
818 $(gtime) $(align) $(lrmapopt) $(lr_reads) $< \
819 | abyss-fixmate-ssq --all --qname $v -l$(lr_l) $(FIXMATE_OPTIONS) \
820 | arcs $v -c$(arcs_c) -d$(arcs_d) -e$(arcs_e) -l$(arcs_l) -m$(arcs_m) -r$(arcs_r) -s$(arcs_s) -z$(arcs_z) \
821 -g $*.arcs.dist.gv --tsv=$*.arcs.tsv --barcode-counts=$*.arcs.barcode-counts.tsv /dev/stdin
822
823 # Align paired-end reads to the draft genome and do not sort.
824 %.lr.sortn.sam.gz: %.fa
825 $(gtime) $(align) $(lrmapopt) $(lr_reads) $< \
826 | abyss-fixmate-ssq --all --qname $v -l$(lr_l) $(FIXMATE_OPTIONS) \
827 | $(gzip) >$@
828
829 # Create a graph of linked contigs using ARCS.
830 %.arcs.dist.gv: %.lr.sortn.sam.gz
831 gunzip -c $< \
832 |$(gtime) arcs $v -c$(arcs_c) -d$(arcs_d) -e$(arcs_e) -l$(arcs_l) -m$(arcs_m) -r$(arcs_r) -s$(arcs_s) -z$(arcs_z) \
833 -g $*.arcs.dist.gv --tsv=$*.arcs.tsv --barcode-counts=$*.arcs.barcode-counts.tsv /dev/stdin
834
835 # Scaffold using ARCS and abyss-scaffold.
836 %.arcs.path: %.arcs.dist.gv
837 $(gtime) abyss-scaffold $(scopt) -s$(lr_s) -n$(lr_n) -g [email protected] $(LR_SCAFFOLD_OPTIONS) $< >$@
838
839 # Create the FASTA file of ARCS scaffolds.
840 %.arcs.fa: %.fa %.arcs.path
841 $(gtime) MergeContigs $(mcopt) -o $@ $^
842
843 %-scaffolds.fa: %-8.tigmint.arcs.fa
844 ln -sf $< $@
845
846 else
847
848 %-scaffolds.fa: %-8.fa
849 ln -sf $< $@
850
851 endif
852
853 %-scaffolds.$g: %-8.$g
854 ln -sf $< $@
855
856 # Sealed Scaffold
857 sealer_ks?=-k90 -k80 -k70 -k60 -k50 -k40 -k30
858
859 %-8_scaffold.fa: %-8.fa
860 $(gtime) abyss-sealer -v -j$j --print-flanks -o$*-8 -S$< $(sealer_ks) $(SEALER_OPTIONS) $(in) $(se)
861
862 %-scaffolds-sealed.fa: %-8_scaffold.fa
863 ln -s $< $@
864
865 # Scaftig
866
867 %-scaftigs.fa: %-scaffolds-agp.fa
868 ln -sf $< $@
869
870 %-scaftigs.agp: %-scaffolds.agp
871 ln -sf $< $@
872
873 # Transcriptome assisted scaffolding
874
875 %.fa.bwt: %.fa
876 $(gtime) bwa index $<
877
878 %-8.sam.gz: $(name)-8.fa.bwt
879 $(gtime) bwa mem -a -t$j -S -P -k$l $(name)-8.fa $(strip $($*)) \
880 |$(gzip) >$@
881
882 %-8.dist.dot: %-8.sam.gz
883 $(gtime) abyss-longseqdist -k$k $(LONGSEQDIST_OPTIONS) $< \
884 |grep -v "l=" >$@
885
886 %-8.path: $(name)-8.$g $(addsuffix -8.dist.dot, $(long))
887 $(gtime) abyss-scaffold $(scopt) -s$S -n1 -g $@.$g $(SCAFFOLD_OPTIONS) $^ >$@
888
889 %-9.path %-9.$g %-9.fa: %-8.fa %-8.$g %-8.path
890 $(gtime) $(stack) PathConsensus $v --$g -k$k $(pcopt) $(PATHCONSENSUS_OPTIONS) -s $*-9.fa -g $*-9.$g -o $*-9.path $^
891
892 %-10.fa: %-8.fa %-9.fa %-9.$g %-9.path
893 cat $(wordlist 1, 2, $^) \
894 |$(gtime) MergeContigs $(mcopt) -o $@ - $(wordlist 3, 4, $^)
895
896 %-10.$g: %-9.$g %-9.path
897 $(gtime) PathOverlap --overlap $(poopt) --$g $^ >$@
898
899 %-long-scaffs.fa: %-10.fa
900 ln -sf $< $@
901
902 %-long-scaffs.$g: %-10.$g
903 ln -sf $< $@
904
905 ifdef db
906 finishDb:
907 @rm -f db.txt
908 endif
909
910 # Create the final BAM file
911
912 ifneq ($(mp),)
913 bam: $(name)-scaffolds.bam.bai
914 else
915 ifneq ($(in),)
916 bam: $(name)-contigs.bam.bai
917 else
918 bam: $(name)-unitigs.bam.bai
919 endif
920 endif
921
922 $(name)-unitigs.bam: %.bam: %.fa
923 $(gtime) $(align) $v -j$j -l$l $(ALIGNER_OPTIONS) $(se) $< \
924 |samtools view -Su - |samtools sort -o - - >$@
925
926 $(name)-contigs.bam $(name)-scaffolds.bam: %.bam: %.fa
927 $(gtime) $(align) $v -j$j -l$l $(ALIGNER_OPTIONS) \
928 $(call map, deref, $(sort $(lib) $(pe) $(mp))) $< \
929 |$(fixmate) $v $(FIXMATE_OPTIONS) \
930 |sort -snk3 -k4 \
931 |samtools view -Sb - >$@
932
933 # Align the variants to the assembly
934
935 %-variants.bam: %.fa.bwt
936 $(gtime) bwa bwasw -t$j $*.fa <(cat $(name)-bubbles.fa $(name)-indel.fa) \
937 |samtools view -Su - |samtools sort -o - - >$@
938
939 %-variants.vcf.gz: %.fa %-variants.bam
940 $(gtime) samtools mpileup -Buf $^ |bcftools view -vp1 - |bgzip >$@
941
942 %.gz.tbi: %.gz
943 $(gtime) tabix -pvcf $<
944
945 # Calculate assembly contiguity statistics
946
947 stats: $(name)-stats.tab $(name)-stats $(name)-stats.csv $(name)-stats.md
948 ifneq ($(shell command -v $(MARKDOWN)),)
949 stats: $(name)-stats.html
950 endif
951
952 %-stats: %-stats.tab
953 ln -sf $< $@
954
955 $(name)-stats.tab: %-stats.tab: %-unitigs.fa
956 ifneq ($(in),)
957 $(name)-stats.tab: %-stats.tab: %-contigs.fa
958 endif
959 ifneq ($(mp),)
960 $(name)-stats.tab: %-stats.tab: %-scaffolds.fa
961 endif
962 ifneq ($(long),)
963 $(name)-stats.tab: %-stats.tab: %-long-scaffs.fa
964 endif
965 $(name)-stats.tab:
966 abyss-fac $(facopt) $(FAC_OPTIONS) $^ |tee $@
967
968 %.csv: %.tab
969 tr '\t' , <$< >$@
970
971 %.md: %.tab
972 abyss-tabtomd $< >$@
973
974 %.html: %.md
975 $(MARKDOWN) $< >$@
976
977 # Create an AGP file and FASTA file of scaftigs from scaffolds
978
979 %.agp %-agp.fa: %.fa
980 $(gtime) abyss-fatoagp $(FATOAGP_OPTIONS) -f $*-agp.fa $< >$*.agp
981
982 # Align the contigs to the reference
983
984 %-$(ref).sam.gz: %.fa
985 $(gtime) bwa bwasw $(bwaswopt) $(BWASW_OPTIONS) $($(ref)) $< |$(gzip) >$@
986
987 # Find breakpoints in the alignments
988
989 %.break: %.sam.gz
990 $(gtime) abyss-samtobreak $(SAMTOBREAK_OPTIONS) $< >$@
991
992 # Report ABySS configuration variable(s) and value(s) currently set.
993
994 override varList := a b c d e E G j k l m n N p q s S t v cs pi \
995 np pe lib mp se SS hostname xtip \
996 ssq ssq_ti path name in mpirun \
997 aligner long ref fixmate DistanceEst \
998 map deref abyssopt fgopt pbopt \
999 align mapopt fmopt deopt \
1000 pcopt sgopt bwaswopt \
1001 ABYSS_OPTIONS FILTERGRAPH_OPTIONS POPBUBBLES_OPTIONS \
1002 OVERLAP_OPTIONS SIMPLEGRAPH_OPTIONS MERGEPATHS_OPTIONS \
1003 SCAFFOLD_OPTIONS ALIGNER_OPTIONS MAP_OPTIONS FAC_OPTIONS \
1004 FIXMATE_OPTIONS BWASW_OPTIONS FATOAGP_OPTIONS SAMTOBREAK_OPTIONS \
1005 RRESOLVER_OPTIONS MARKDOWN
1006
1007 env:
1008 @echo 'List of ABySS configuration variables currently set:'
1009 @echo '[environment], if variable was inherited from the environment.'
1010 @echo '[command line], if variable was defined on the command line.'
1011 @echo '[file], if variable was defined in (this) makefile.'
1012 @echo '[override], if variable was defined with an override directive in (this) makefile.'
1013
1014 @$(foreach var,$(varList),\
1015 echo -e $(var)" = "$($(var))"\t["$(origin $(var))"]";)