1#!/usr/local/bin/bash
2
3#Running callvariants2.sh is equivalent to running callvariants.sh with the "multi" flag.
4#See callvariants.sh for usage information.
5
6#callvariants2 is intended for multiple sam/bam files, one from each sample, which should have variants called independently; the point is that allele frequencies will be reported for ALL samples at locations where ANY sample has a variant called.
7#callvariants2 is NOT a better version of callvariants, it's the same, just designed for multisample processing.
8#If you have only 1 sample (regardless of how many sam/bam files there are) you should use callvariants.sh without the "multi" flag.
9
10usage(){
11bash "$DIR"callvariants.sh
12}
13
14#This block allows symlinked shellscripts to correctly set classpath.
15pushd . > /dev/null
16DIR="${BASH_SOURCE[0]}"
17while [ -h "$DIR" ]; do
18  cd "$(dirname "$DIR")"
19  DIR="$(readlink "$(basename "$DIR")")"
20done
21cd "$(dirname "$DIR")"
22DIR="$(pwd)/"
23popd > /dev/null
24
25#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
26CP="$DIR""current/"
27
28z="-Xmx4g"
29z2="-Xms4g"
30set=0
31
32if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
33	usage
34	exit
35fi
36
37calcXmx () {
38	source "$DIR""/calcmem.sh"
39	setEnvironment
40	parseXmx "$@"
41	if [[ $set == 1 ]]; then
42		return
43	fi
44	freeRam 4000m 84
45	z="-Xmx${RAM}m"
46	z2="-Xms${RAM}m"
47}
48calcXmx "$@"
49
50callvariants2() {
51	local CMD="java $EA $EOOM $z $z2 -cp $CP var2.CallVariants2 $@"
52	echo $CMD >&2
53	eval $CMD
54}
55
56callvariants2 "$@"
57