| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified September 4, 2019 |
| 7 | |
| 8 | Description: Makes a representative set of taxa from all-to-all identity |
| 9 | comparison. Input should be in 3+ column TSV format (first 3 are required): |
| 10 | (query, ref, ANI, qsize, rsize, qbases, rbases) |
| 11 | ...as produced by CompareSketch with format=3 and usetaxidname. |
| 12 | Additional columns are allowed and will be ignored. |
| 13 | |
| 14 | Usage: representative.sh in=<input file> out=<output file> |
| 15 | |
| 16 | Parameters: |
| 17 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 18 | overwrite an existing file. |
| 19 | threshold=0 Ignore edges under threshold value. This also affects the |
| 20 | choice of centroids; a high threshold gives more weight to |
| 21 | higher-value edges. |
| 22 | minratio=0 Ignores edges with a ratio below this value. |
| 23 | invertratio=f Invert the ratio when greater than 1. |
| 24 | printheader=t Print a header line in the output. |
| 25 | printsize=t Print the size of retained nodes. |
| 26 | printclusters=t Print the nodes subsumed by each retained node. |
| 27 | minsize=0 Ignore nodes under this size (in unique kmers). |
| 28 | maxsize=0 If positive, ignore nodes over this size (unique kmers). |
| 29 | minbases=0 Ignore nodes under this size (in total bases). |
| 30 | maxbases=0 If positive, ignore nodes over this size (total bases). |
| 31 | |
| 32 | Taxonomy parameters: |
| 33 | level= Taxonomic level, such as phylum. Filtering will operate on |
| 34 | sequences within the same taxonomic level as specified ids. |
| 35 | If not set, only matches to a node or its descendants will |
| 36 | be considered. |
| 37 | ids= Comma-delimited list of NCBI numeric IDs. Can also be a |
| 38 | file with one taxID per line. |
| 39 | names= Alternately, a list of names (such as 'Homo sapiens'). |
| 40 | Note that spaces need special handling. |
| 41 | include=f 'f' will discard filtered sequences, 't' will keep them. |
| 42 | tree=<file> Specify a TaxTree file like tree.taxtree.gz. |
| 43 | On Genepool, use 'auto'. |
| 44 | |
| 45 | Java Parameters: |
| 46 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 47 | -Xmx20g will |
| 48 | specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 49 | The max is typically around 85% of physical memory. |
| 50 | -eoom This flag will cause the process to exit if an out-of-memory |
| 51 | exception occurs. Requires Java 8u92+. |
| 52 | -da Disable assertions. |
| 53 | |
| 54 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 55 | " |
| 56 | } |
| 57 | |
| 58 | #This block allows symlinked shellscripts to correctly set classpath. |
| 59 | pushd . > /dev/null |
| 60 | DIR="${BASH_SOURCE[0]}" |
| 61 | while [ -h "$DIR" ]; do |
| 62 | cd "$(dirname "$DIR")" |
| 63 | DIR="$(readlink "$(basename "$DIR")")" |
| 64 | done |
| 65 | cd "$(dirname "$DIR")" |
| 66 | DIR="$(pwd)/" |
| 67 | popd > /dev/null |
| 68 | |
| 69 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 70 | CP="$DIR""current/" |
| 71 | |
| 72 | z="-Xmx4g" |
| 73 | z2="-Xms4g" |
| 74 | set=0 |
| 75 | |
| 76 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 77 | usage |
| 78 | exit |
| 79 | fi |
| 80 | |
| 81 | calcXmx () { |
| 82 | source "$DIR""/calcmem.sh" |
| 83 | setEnvironment |
| 84 | parseXmx "$@" |
| 85 | if [[ $set == 1 ]]; then |
| 86 | return |
| 87 | fi |
| 88 | freeRam 4000m 84 |
| 89 | z="-Xmx${RAM}m" |
| 90 | z2="-Xms${RAM}m" |
| 91 | } |
| 92 | calcXmx "$@" |
| 93 | |
| 94 | a_sample_mt() { |
| 95 | local CMD="java $EA $EOOM $z -cp $CP jgi.RepresentativeSet $@" |
| 96 | echo $CMD >&2 |
| 97 | eval $CMD |
| 98 | } |
| 99 | |
| 100 | a_sample_mt "$@" |