Debian Codegraph @

filterbytaxa.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified June 18, 2018
7
8 Description: Filters sequences according to their taxonomy,
9 as determined by the sequence name. Sequences should
10 be labeled with a gi number, NCBI taxID, or species name.
11
12 Usage: filterbytaxa.sh in=<input file> out=<output file> tree=<tree file> table=<table file> ids=<numbers> level=<name or number>
13
14 I/O parameters:
15 in=<file> Primary input, or read 1 input.
16 out=<file> Primary output, or read 1 output.
17 results=<file> Optional; prints a list indicating which taxa were retained.
18 overwrite=f (ow) Set to false to force the program to abort rather than
19 overwrite an existing file.
20 showspeed=t (ss) Set to 'f' to suppress display of processing speed.
21 ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression
22 level; lower compression is faster.
23
24 Processing parameters:
25 level= Taxonomic level, such as phylum. Filtering will operate on
26 sequences within the same taxonomic level as specified ids.
27 If not set, only matches to a node or its descendants will
28 be considered.
29 reqlevel= Require nodes to have ancestors at these levels. For example,
30 reqlevel=species,genus would ban nodes that are not defined
31 at both the species and genus levels.
32 ids= Comma-delimited list of NCBI numeric IDs. Can also be a
33 file with one taxID per line. Names (like bacteria) are also
34 acceptable.
35 include=f 'f' will discard filtered sequences, 't' will keep them.
36 besteffort=f Intended for include mode. Iteratively increases level
37 while the input file has no hits to the tax list.
38 tree=<file> Specify a TaxTree file like tree.taxtree.gz.
39 On Genepool, use 'auto'.
40 gi=<file> Specify a gitable file like gitable.int1d.gz. Only needed
41 if gi numbers will be used. On Genepool, use 'auto'.
42 accession= Specify one or more comma-delimited NCBI accession to taxid
43 files. Only needed if accesions will be used; requires ~45GB
44 of memory. On Genepool, use 'auto'.
45 printnodes=t Print the names of nodes added to the filter.
46 requirepresent=t Crash with an error message if a header cannot be resolved
47 to a taxid.
48
49 String-matching parameters:
50 regex= Filter names matching this Java regular expression.
51 contains= Filter names containing this substring (case-insensitive).
52
53 * Note *
54 Tree and table files are in /global/projectb/sandbox/gaag/bbtools/tax
55 For non-Genepool users, or to make new ones, use taxtree.sh and gitable.sh
56
57 Java Parameters:
58 -Xmx This will set Java's memory usage, overriding autodetection.
59 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
60 specify 200 megs. The max is typically 85% of physical memory.
61 -eoom This flag will cause the process to exit if an out-of-memory
62 exception occurs. Requires Java 8u92+.
63 -da Disable assertions.
64
65 Please contact Brian Bushnell at [email protected] if you encounter any problems.
66 "
67 }
68
69 #This block allows symlinked shellscripts to correctly set classpath.
70 pushd . > /dev/null
71 DIR="${BASH_SOURCE[0]}"
72 while [ -h "$DIR" ]; do
73 cd "$(dirname "$DIR")"
74 DIR="$(readlink "$(basename "$DIR")")"
75 done
76 cd "$(dirname "$DIR")"
77 DIR="$(pwd)/"
78 popd > /dev/null
79
80 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
81 CP="$DIR""current/"
82
83 z="-Xmx4g"
84 z2="-Xms4g"
85 set=0
86
87 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
88 usage
89 exit
90 fi
91
92 calcXmx () {
93 source "$DIR""/calcmem.sh"
94 setEnvironment
95 parseXmx "$@"
96 if [[ $set == 1 ]]; then
97 return
98 fi
99 freeRam 1000m 84
100 z="-Xmx${RAM}m"
101 z2="-Xms${RAM}m"
102 }
103 calcXmx "$@"
104
105 filterbytaxa() {
106 local CMD="java $EA $EOOM $z -cp $CP tax.FilterByTaxa $@"
107 echo $CMD >&2
108 eval $CMD
109 }
110
111 filterbytaxa "$@"