| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified January 20, 2025 |
| 7 | |
| 8 | Description: Concatenates and recompresses files. |
| 9 | |
| 10 | Usage: cat.sh *.fna out=catted.fa.gz |
| 11 | |
| 12 | Standard parameters: |
| 13 | in=<file> Comma-delimited input. Filenames with no 'in=' will |
| 14 | also be treated as input files. |
| 15 | out=<file> Output. Defaults to stdout. |
| 16 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 17 | level; lower compression is faster. |
| 18 | |
| 19 | Processing parameters: |
| 20 | None yet! |
| 21 | |
| 22 | Java Parameters: |
| 23 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 24 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 25 | specify 200 megs. The max is typically 85% of physical memory. |
| 26 | -eoom This flag will cause the process to exit if an out-of-memory |
| 27 | exception occurs. Requires Java 8u92+. |
| 28 | -da Disable assertions. |
| 29 | |
| 30 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 31 | " |
| 32 | } |
| 33 | |
| 34 | #This block allows symlinked shellscripts to correctly set classpath. |
| 35 | pushd . > /dev/null |
| 36 | DIR="${BASH_SOURCE[0]}" |
| 37 | while [ -h "$DIR" ]; do |
| 38 | cd "$(dirname "$DIR")" |
| 39 | DIR="$(readlink "$(basename "$DIR")")" |
| 40 | done |
| 41 | cd "$(dirname "$DIR")" |
| 42 | DIR="$(pwd)/" |
| 43 | popd > /dev/null |
| 44 | |
| 45 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 46 | CP="$DIR""current/" |
| 47 | |
| 48 | z="-Xmx200m" |
| 49 | z2="-Xms200m" |
| 50 | set=0 |
| 51 | |
| 52 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 53 | usage |
| 54 | exit |
| 55 | fi |
| 56 | |
| 57 | calcXmx () { |
| 58 | source "$DIR""/calcmem.sh" |
| 59 | setEnvironment |
| 60 | parseXmx "$@" |
| 61 | } |
| 62 | calcXmx "$@" |
| 63 | |
| 64 | catFiles() { |
| 65 | local CMD="java $EA $EOOM $z -cp $CP fileIO.Concatenate $@" |
| 66 | echo $CMD >&2 |
| 67 | eval $CMD |
| 68 | } |
| 69 | |
| 70 | catFiles "$@" |