1#!/usr/local/bin/bash
2
3usage(){
4echo "
5Written by Brian Bushnell
6Last modified July 29, 2019
7
8Description:  Shrinks accession2taxid tables by removing unneeded columns.
9This is not necessary but makes accession2taxid files smaller and load faster.
10
11Usage:  shrinkaccession.sh in=<file> out=<outfile>
12
13Parameters:
14ow=f            (overwrite) Overwrites files that already exist.
15app=f           (append) Append to files that already exist.
16zl=4            (ziplevel) Set compression level, 1 (low) to 9 (max).
17pigz=t          Use pigz for compression, if available.
18gi=t            Retain gi numbers.
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
33#This block allows symlinked shellscripts to correctly set classpath.
34pushd . > /dev/null
35DIR="${BASH_SOURCE[0]}"
36while [ -h "$DIR" ]; do
37  cd "$(dirname "$DIR")"
38  DIR="$(readlink "$(basename "$DIR")")"
39done
40cd "$(dirname "$DIR")"
41DIR="$(pwd)/"
42popd > /dev/null
43
44#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
45CP="$DIR""current/"
46
47z="-Xmx80m"
48set=0
49
50if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
51	usage
52	exit
53fi
54
55calcXmx () {
56	source "$DIR""/calcmem.sh"
57	setEnvironment
58	parseXmx "$@"
59}
60calcXmx "$@"
61
62function shrinkaccession() {
63	local CMD="java $EA $EOOM $z -cp $CP tax.ShrinkAccession $@"
64	echo $CMD >&2
65	eval $CMD
66}
67
68shrinkaccession "$@"
69