1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified January 21, 2015
7
8Description:    Merges coverage stats lines (from pileup) for the same OTU,
9                according to some custom naming scheme.
10
11Usage:          mergeOTUs.sh in=<file> out=<file>
12
13Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
14"
15}
16
17#This block allows symlinked shellscripts to correctly set classpath.
18pushd . > /dev/null
19DIR="${BASH_SOURCE[0]}"
20while [ -h "$DIR" ]; do
21  cd "$(dirname "$DIR")"
22  DIR="$(readlink "$(basename "$DIR")")"
23done
24cd "$(dirname "$DIR")"
25DIR="$(pwd)/"
26popd > /dev/null
27
28#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
29CP="$DIR""current/"
30
31z="-Xmx1g"
32set=0
33
34if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
35	usage
36	exit
37fi
38
39calcXmx () {
40	source "$DIR""/calcmem.sh"
41	setEnvironment
42	parseXmx "$@"
43}
44calcXmx "$@"
45
46function mergeOTUs() {
47	local CMD="java $EA $EOOM $z -cp $CP driver.MergeCoverageOTU $@"
48	echo $CMD >&2
49	eval $CMD
50}
51
52mergeOTUs "$@"
53