1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified March 19, 2018
7
8Description:  Summarizes monthly contam files into a single file.
9This is for internal JGI use.
10
11Usage:  summarizecontam.sh <input files> out=<output file>
12
13Parameters:
14in=<file,file>  Input contam summary files, comma-delimited.
15                Alternately, file arguments (from a * expansion) will be
16                considered input files.
17out=<file>      Output.
18tree=auto       Taxtree file location (optional).
19overwrite=t     (ow) Set to false to force the program to abort rather than
20                overwrite an existing file.
21
22Filter Parameters (passing all required to pass):
23minreads=0      Ignore records with fewer reads than this.
24minsequnits=0   Ignore records with fewer seq units than this.
25
26Java Parameters:
27-Xmx            This will set Java's memory usage, overriding autodetection.
28                -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
29                specify 200 megs. The max is typically 85% of physical memory.
30-eoom           This flag will cause the process to exit if an out-of-memory
31                exception occurs.  Requires Java 8u92+.
32-da             Disable assertions.
33
34Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
35"
36}
37
38#This block allows symlinked shellscripts to correctly set classpath.
39pushd . > /dev/null
40DIR="${BASH_SOURCE[0]}"
41while [ -h "$DIR" ]; do
42  cd "$(dirname "$DIR")"
43  DIR="$(readlink "$(basename "$DIR")")"
44done
45cd "$(dirname "$DIR")"
46DIR="$(pwd)/"
47popd > /dev/null
48
49#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
50CP="$DIR""current/"
51
52z="-Xmx1g"
53z2="-Xms1g"
54set=0
55
56if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
57	usage
58	exit
59fi
60
61calcXmx () {
62	source "$DIR""/calcmem.sh"
63	setEnvironment
64	parseXmx "$@"
65	if [[ $set == 1 ]]; then
66		return
67	fi
68	freeRam 1000m 24
69	z="-Xmx${RAM}m"
70	z2="-Xms${RAM}m"
71}
72calcXmx "$@"
73
74process() {
75	local CMD="java $EA $EOOM $z -cp $CP driver.SummarizeContamReport $@"
76	echo $CMD >&2
77	eval $CMD
78}
79
80process "$@"
81