Debian Codegraph @

gi2taxid.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell.
6 Last modified December 19, 2019
7
8 Description: Renames sequences to indicate their NCBI taxIDs.
9 The headers must be in NCBI or Silva format with gi numbers,
10 accessions, or organism names. Only supports fasta and gff files.
11
12 Usage: gi2taxid.sh in=<file> out=<file> server
13
14 Parameters:
15 in=<file> Input sequences; required parameter. Must be fasta.
16 This can alternatively be a comma-delimited list,
17 or just a bunch of space-delimited filenames, e.g.:
18 gi2taxid.sh x.fa y.fa z.fa out=tid.fa tree=auto table=auto
19 out=<file> Destination for renamed sequences.
20 invalid=<file> Destination for headers with no taxid.
21 keepall=t Keep sequences with no taxid in normal output.
22 prefix=t Append the taxid as a prefix to the old header, but keep
23 the old header.
24 title=tid Set the title of the new number (e.g. ncbi, taxid, tid).
25 ziplevel=2 (zl) Compression level for gzip output.
26 pigz=t Spawn a pigz (parallel gzip) process for faster
27 compression than Java. Requires pigz to be installed.
28 silva=f Parse headers in Silva format.
29 shrinknames=f Replace multiple concatenated headers with the first.
30 deleteinvalid=f Delete the output file if there are any invalid headers.
31
32 Taxonomy file flags:
33 server=f Use the taxonomy server instead of local files.
34 Server mode only works for accessions (like RefSeq).
35 tree= Specify a taxtree file. On Genepool, use 'auto'.
36 gi= Specify a gitable file. On Genepool, use 'auto'.
37 accession= Specify one or more comma-delimited NCBI accession to
38 taxid files. On Genepool, use 'auto'.
39
40 Java Parameters:
41 -Xmx This will set Java's memory usage, overriding autodetection.
42 -Xmx20g will specify 20 gigs of RAM, and -Xmx800m will specify 800 megs.
43 The max is typically 85% of physical memory.
44 -eoom This flag will cause the process to exit if an out-of-memory
45 exception occurs. Requires Java 8u92+.
46 -da Disable assertions.
47
48 Please contact Brian Bushnell at [email protected] if you encounter any problems.
49 "
50 }
51
52 #This block allows symlinked shellscripts to correctly set classpath.
53 pushd . > /dev/null
54 DIR="${BASH_SOURCE[0]}"
55 while [ -h "$DIR" ]; do
56 cd "$(dirname "$DIR")"
57 DIR="$(readlink "$(basename "$DIR")")"
58 done
59 cd "$(dirname "$DIR")"
60 DIR="$(pwd)/"
61 popd > /dev/null
62
63 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
64 CP="$DIR""current/"
65 JNI="-Djava.library.path=""$DIR""jni/"
66 JNI=""
67
68 z="-Xmx7g"
69 z2="-Xms7g"
70 set=0
71
72 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
73 usage
74 exit
75 fi
76
77 calcXmx () {
78 source "$DIR""/calcmem.sh"
79 setEnvironment
80 parseXmx "$@"
81 if [[ $set == 1 ]]; then
82 return
83 fi
84 freeRam 7000m 84
85 z="-Xmx${RAM}m"
86 z2="-Xms${RAM}m"
87 }
88 calcXmx "$@"
89
90
91 gi2taxid() {
92 local CMD="java $EA $EOOM $z $z2 -cp $CP tax.RenameGiToTaxid $@"
93 echo $CMD >&2
94 eval $CMD
95 }
96
97 gi2taxid "$@"