1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified April 5, 2020
7
8Description:  Summarizes coverage information from basecov files
9              created by pileup.sh.  They should be named like
10              'sample1_basecov.txt' but other naming styles are fine too.
11
12Usage:        summarizecoverage.sh *basecov.txt out=<output file>
13
14Parameters:
15in=<file>           'in=' is not necessary.  Any filename used as a
16                    parameter will be assumed to be an input basecov file.
17out=<file>          Write the summary here.  Default is stdout.
18reflen=-1           If positive, use this as the total reference length.
19                    Otherwise, assume basecov files report every ref base.
20
21Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
22"
23}
24
25#This block allows symlinked shellscripts to correctly set classpath.
26pushd . > /dev/null
27DIR="${BASH_SOURCE[0]}"
28while [ -h "$DIR" ]; do
29  cd "$(dirname "$DIR")"
30  DIR="$(readlink "$(basename "$DIR")")"
31done
32cd "$(dirname "$DIR")"
33DIR="$(pwd)/"
34popd > /dev/null
35
36#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
37CP="$DIR""current/"
38
39z="-Xmx200m"
40set=0
41
42if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
43	usage
44	exit
45fi
46
47calcXmx () {
48	source "$DIR""/calcmem.sh"
49	setEnvironment
50	parseXmx "$@"
51}
52calcXmx "$@"
53
54summarize() {
55	local CMD="java $EA $EOOM $z -cp $CP covid.SummarizeCoverage $@"
56#	echo $CMD >&2
57	eval $CMD
58}
59
60summarize "$@"
61