| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified Jan 7, 2020 |
| 7 | |
| 8 | Description: Prints the full taxonomy of a string. |
| 9 | String may be a gi number, NCBI taxID, or Latin name. |
| 10 | An NCBI identifier should just be a number or ncbi|number. |
| 11 | A gi number should be gi|number. |
| 12 | Please read bbmap/docs/guides/TaxonomyGuide.txt for more information. |
| 13 | Not: It is more convenient to use taxonomy.jgi-psf.org. |
| 14 | |
| 15 | Usage: taxonomy.sh tree=<tree file> <identifier> |
| 16 | Alternate usage: taxonomy.sh tree=<tree file> in=<file> |
| 17 | |
| 18 | Usage examples: |
| 19 | taxonomy.sh tree=tree.taxtree.gz homo_sapiens canis_lupus 9606 |
| 20 | taxonomy.sh tree=tree.taxtree.gz gi=gitable.int1.d.gz in=refseq.fasta |
| 21 | |
| 22 | Processing parameters: |
| 23 | in=<file> A file containing named sequences, or just the names. |
| 24 | out=<file> Output file. If blank, use stdout. |
| 25 | tree=<file> Specify a TaxTree file like tree.taxtree.gz. |
| 26 | On Genepool, use 'auto'. |
| 27 | gi=<file> Specify a gitable file like gitable.int1d.gz. Only needed |
| 28 | if gi numbers will be used. On Genepool, use 'auto'. |
| 29 | accession= Specify one or more comma-delimited NCBI accession to taxid |
| 30 | files. Only needed if accesions will be used; requires ~45GB |
| 31 | of memory. On Genepool, use 'auto'. |
| 32 | level=null Set to a taxonomic level like phylum to just print that level. |
| 33 | minlevel=-1 For multi-level printing, do not print levels below this. |
| 34 | maxlevel=life For multi-level printing, do not print levels above this. |
| 35 | silva=f Parse headers using Silva or semicolon-delimited syntax. |
| 36 | taxpath=auto Set the path to taxonomy files; auto only works at NERSC. |
| 37 | |
| 38 | Parameters without an '=' symbol will be considered organism identifiers. |
| 39 | |
| 40 | * Note * |
| 41 | Tree and table files are in /global/projectb/sandbox/gaag/bbtools/tax |
| 42 | For non-Genepool users, or to make new ones, use taxtree.sh and gitable.sh |
| 43 | |
| 44 | Java Parameters: |
| 45 | -Xmx This will set Java's memory usage, |
| 46 | overriding autodetection. |
| 47 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify |
| 48 | 200 megs. The max is typically 85% of physical memory. |
| 49 | -eoom This flag will cause the process to exit if an out-of-memory |
| 50 | exception occurs. Requires Java 8u92+. |
| 51 | -da Disable assertions. |
| 52 | |
| 53 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 54 | " |
| 55 | } |
| 56 | |
| 57 | #This block allows symlinked shellscripts to correctly set classpath. |
| 58 | pushd . > /dev/null |
| 59 | DIR="${BASH_SOURCE[0]}" |
| 60 | while [ -h "$DIR" ]; do |
| 61 | cd "$(dirname "$DIR")" |
| 62 | DIR="$(readlink "$(basename "$DIR")")" |
| 63 | done |
| 64 | cd "$(dirname "$DIR")" |
| 65 | DIR="$(pwd)/" |
| 66 | popd > /dev/null |
| 67 | |
| 68 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 69 | CP="$DIR""current/" |
| 70 | |
| 71 | z="-Xmx8g" |
| 72 | z2="-Xms8g" |
| 73 | set=0 |
| 74 | |
| 75 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 76 | usage |
| 77 | exit |
| 78 | fi |
| 79 | |
| 80 | calcXmx () { |
| 81 | source "$DIR""/calcmem.sh" |
| 82 | setEnvironment |
| 83 | parseXmx "$@" |
| 84 | if [[ $set == 1 ]]; then |
| 85 | return |
| 86 | fi |
| 87 | freeRam 2000m 84 |
| 88 | z="-Xmx${RAM}m" |
| 89 | z2="-Xms${RAM}m" |
| 90 | } |
| 91 | calcXmx "$@" |
| 92 | |
| 93 | taxonomy() { |
| 94 | local CMD="java $EA $EOOM $z -cp $CP tax.PrintTaxonomy $@" |
| 95 | echo $CMD >&2 |
| 96 | eval $CMD |
| 97 | } |
| 98 | |
| 99 | taxonomy "$@" |