| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified January 9, 2025 |
| 7 | |
| 8 | Description: Renames fasta files with a TaxID, based on SendSketch results. |
| 9 | Designed for metagenome binning evaluation and synthetic read generation. |
| 10 | |
| 11 | Usage: renamebysketch.sh *.fa |
| 12 | |
| 13 | Input may be fasta or fastq, compressed or uncompressed. |
| 14 | |
| 15 | Java Parameters: |
| 16 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 17 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 18 | specify 200 megs. The max is typically 85% of physical memory. |
| 19 | -eoom This flag will cause the process to exit if an out-of-memory |
| 20 | exception occurs. Requires Java 8u92+. |
| 21 | -da Disable assertions. |
| 22 | |
| 23 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 24 | " |
| 25 | } |
| 26 | |
| 27 | #This block allows symlinked shellscripts to correctly set classpath. |
| 28 | pushd . > /dev/null |
| 29 | DIR="${BASH_SOURCE[0]}" |
| 30 | while [ -h "$DIR" ]; do |
| 31 | cd "$(dirname "$DIR")" |
| 32 | DIR="$(readlink "$(basename "$DIR")")" |
| 33 | done |
| 34 | cd "$(dirname "$DIR")" |
| 35 | DIR="$(pwd)/" |
| 36 | popd > /dev/null |
| 37 | |
| 38 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 39 | CP="$DIR""current/" |
| 40 | |
| 41 | z="-Xmx4g" |
| 42 | z2="-Xms4g" |
| 43 | set=0 |
| 44 | |
| 45 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 46 | usage |
| 47 | exit |
| 48 | fi |
| 49 | |
| 50 | calcXmx () { |
| 51 | source "$DIR""/calcmem.sh" |
| 52 | setEnvironment |
| 53 | parseXmx "$@" |
| 54 | if [[ $set == 1 ]]; then |
| 55 | return |
| 56 | fi |
| 57 | freeRam 4000m 84 |
| 58 | z="-Xmx${RAM}m" |
| 59 | z2="-Xms${RAM}m" |
| 60 | } |
| 61 | calcXmx "$@" |
| 62 | |
| 63 | rename() { |
| 64 | local CMD="java $EA $EOOM $z -cp $CP bin.FileRenamer $@" |
| 65 | echo $CMD >&2 |
| 66 | eval $CMD |
| 67 | } |
| 68 | |
| 69 | rename "$@" |