1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified January 20, 2017
7
8Description:  Creates a ROC curve from a sam file of synthetic reads with headers generated by RandomReads3.java
9
10Usage:  samtoroc.sh in=<sam file> reads=<number of reads in input fastq>
11
12Parameters:
13in=<file>       Specify the input sam file, or stdin.
14thresh=20       Max deviation from correct location to be considered 'loosely correct'.
15blasr=f         Set to 't' for BLASR output; fixes extra information added to read names.
16ssaha2=f        Set to 't' for SSAHA2 or SMALT output; fixes incorrect soft-clipped read locations.
17bitset=t        Track read ID's to detect secondary alignments.
18                Necessary for mappers that incorrectly output multiple primary alignments per read.
19
20Java Parameters:
21-Xmx            This will set Java's memory usage, overriding autodetection.
22                -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs.
23                    The max is typically 85% of physical memory.
24-eoom           This flag will cause the process to exit if an out-of-memory
25                exception occurs.  Requires Java 8u92+.
26-da             Disable assertions.
27
28Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
29"
30}
31
32#This block allows symlinked shellscripts to correctly set classpath.
33pushd . > /dev/null
34DIR="${BASH_SOURCE[0]}"
35while [ -h "$DIR" ]; do
36  cd "$(dirname "$DIR")"
37  DIR="$(readlink "$(basename "$DIR")")"
38done
39cd "$(dirname "$DIR")"
40DIR="$(pwd)/"
41popd > /dev/null
42
43#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
44CP="$DIR""current/"
45
46z="-Xmx200m"
47set=0
48
49if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
50	usage
51	exit
52fi
53
54calcXmx () {
55	source "$DIR""/calcmem.sh"
56	setEnvironment
57	parseXmx "$@"
58}
59calcXmx "$@"
60
61samtoroc() {
62	local CMD="java $EA $EOOM $z -cp $CP align2.MakeRocCurve $@"
63#	echo $CMD >&2
64	eval $CMD
65}
66
67samtoroc "$@"
68