1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified September 18, 2019
7
8Description:  Runs TadpoleWrapper after some preprocessing,
9to allow optimal assemblies using long kmers.
10Only paired reads are supported.
11
12Usage:
13tadpipe.sh in=reads.fq out=contigs.fa
14
15
16Parameters:
17in=<file>           Input reads.
18in2=<file>          Optional read 2, if reads are in two files.
19out=contigs.fa      Output file name.
20temp=$TMPDIR        Path to a directory for temp files.
21delete=t            Delete intermediate files.
22gz=f                Gzip intermediate files.
23
24Other parameters can be passed to individual phases like this:
25
26assemble_k=200,250  Set kmer lengths for assembly phase.
27merge_strict        Set the strict flag in merge phase.
28extend_el=120       Set the left-extension distance in the extension phase.
29
30Valid prefixes:
31
32filter_             PhiX and contaminant filtering.
33trim_               Adapter trimmming.
34merge_              Paired-read merging.
35correct_            Error correction.
36extend_             Read extension.
37assemble_           Final assembly.
38"
39}
40
41#This block allows symlinked shellscripts to correctly set classpath.
42pushd . > /dev/null
43DIR="${BASH_SOURCE[0]}"
44while [ -h "$DIR" ]; do
45  cd "$(dirname "$DIR")"
46  DIR="$(readlink "$(basename "$DIR")")"
47done
48cd "$(dirname "$DIR")"
49DIR="$(pwd)/"
50popd > /dev/null
51
52#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
53CP="$DIR""current/"
54
55z="-Xmx14g"
56z2="-Xms14g"
57set=0
58
59if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
60	usage
61	exit
62fi
63
64calcXmx () {
65	source "$DIR""/calcmem.sh"
66	setEnvironment
67	parseXmx "$@"
68	if [[ $set == 1 ]]; then
69		return
70	fi
71	freeRam 15000m 84
72	z="-Xmx${RAM}m"
73	z2="-Xms${RAM}m"
74}
75calcXmx "$@"
76
77tadpipe() {
78	local CMD="java $EA $EOOM $z $z2 -cp $CP assemble.TadPipe $@"
79	echo $CMD >&2
80	eval $CMD
81}
82
83tadpipe "$@"
84