| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified July 30, 2024 |
| 7 | |
| 8 | Description: Selects a subset of files from an all-to-all identity |
| 9 | comparison. The subset will contain exactly X files with maximal |
| 10 | pairwise ANI, or all files with at most Y pairwise identity. |
| 11 | This program is similar to representative.sh but does not use taxonomy. |
| 12 | |
| 13 | Input should be in 3+ column TSV format (first 3 are required): |
| 14 | (query, ref, ANI) |
| 15 | ...as produced by CompareSketch when run like this: |
| 16 | comparesketch.sh ata format=3 includeself perfile records=99999 *.fasta |
| 17 | |
| 18 | Usage: picksubset.sh in=<file> out=<file> invalid=<file> files=<number> |
| 19 | |
| 20 | Parameters: |
| 21 | in= Input file comparing all-to-all comparisons. |
| 22 | out= Output file for the list of files to retain. |
| 23 | invalid= Output file for the list of files to discard. |
| 24 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 25 | overwrite an existing file. |
| 26 | files=0 Number of files to retain. |
| 27 | ani=0 Maximum pairwise ANI allowed, expressed as a percent. |
| 28 | NOTE: files or ani, or both, must be set. |
| 29 | |
| 30 | Java Parameters: |
| 31 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 32 | -Xmx20g will |
| 33 | specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 34 | The max is typically around 85% of physical memory. |
| 35 | -eoom This flag will cause the process to exit if an out-of-memory |
| 36 | exception occurs. Requires Java 8u92+. |
| 37 | -da Disable assertions. |
| 38 | |
| 39 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 40 | " |
| 41 | } |
| 42 | |
| 43 | #This block allows symlinked shellscripts to correctly set classpath. |
| 44 | pushd . > /dev/null |
| 45 | DIR="${BASH_SOURCE[0]}" |
| 46 | while [ -h "$DIR" ]; do |
| 47 | cd "$(dirname "$DIR")" |
| 48 | DIR="$(readlink "$(basename "$DIR")")" |
| 49 | done |
| 50 | cd "$(dirname "$DIR")" |
| 51 | DIR="$(pwd)/" |
| 52 | popd > /dev/null |
| 53 | |
| 54 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 55 | CP="$DIR""current/" |
| 56 | |
| 57 | z="-Xmx2g" |
| 58 | z2="-Xms2g" |
| 59 | set=0 |
| 60 | |
| 61 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 62 | usage |
| 63 | exit |
| 64 | fi |
| 65 | |
| 66 | calcXmx () { |
| 67 | source "$DIR""/calcmem.sh" |
| 68 | setEnvironment |
| 69 | parseXmx "$@" |
| 70 | } |
| 71 | calcXmx "$@" |
| 72 | |
| 73 | picksubset() { |
| 74 | local CMD="java $EA $EOOM $z -cp $CP jgi.PickSubset $@" |
| 75 | echo $CMD >&2 |
| 76 | eval $CMD |
| 77 | } |
| 78 | |
| 79 | picksubset "$@" |