Debian Codegraph @

sendsketch.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified October 10, 2024
7
8 Description: Compares query sketches to reference sketches hosted on a
9 remote server via the Internet. The input can be sketches made by sketch.sh,
10 or fasta/fastq files from which SendSketch will generate sketches.
11 Only sketches will sent, not sequences.
12
13 Please read bbmap/docs/guides/BBSketchGuide.txt for more information.
14
15 Usage:
16 sendsketch.sh in=file
17
18 To change nucleotide servers, add the server name, e.g.:
19 sendsketch.sh in=file nt
20
21 For the protein server with nucleotide input:
22 sendsketch.sh in=file protein
23
24 for the protein server with amino input:
25 sendsketch.sh in=file amino protein
26
27
28 Standard parameters:
29 in=<file> Sketch or fasta file to compare.
30 out=stdout Comparison output. Can be set to a file instead.
31 outsketch= Optional, to write the sketch to a file.
32 local=f For local files, have the server load the sketches.
33 Allows use of whitelists; recommended for Silva.
34 Local can only be used when the client and server access
35 the same filesystem - e.g., Genepool and Cori.
36 address= Address of remote server. Default address:
37 https://refseq-sketch.jgi.doe.gov/sketch
38 You can also specify these abbreviations:
39 nt: nt server
40 refseq: Refseq server
41 silva: Silva server
42 protein: RefSeq prokaryotic amino acid sketches
43 img: IMG server (Not Yet Available)
44 mito: RefSeq mitochondrial server (NYA)
45 fungi: RefSeq fungi sketches (NYA)
46 Using an abbreviation automatically sets the address,
47 the blacklist, and k.
48 aws=f Set aws=t to use the aws servers instead of NERSC.
49 When, for example, NERSC (or the whole SF Bay area) is down.
50
51 Sketch-making parameters:
52 mode=single Possible modes, for fasta input:
53 single: Generate one sketch per file.
54 sequence: Generate one sketch per sequence.
55 k=31 Kmer length, 1-32. This is automatic and does not need to
56 be set for JGI servers, only for locally-hosted servers.
57 samplerate=1 Set to a lower value to sample a fraction of input reads.
58 For raw reads (rather than an assembly), 1-3x coverage
59 gives best results, by reducing error kmers. Somewhat
60 higher is better for high-error-rate data like PacBio.
61 minkeycount=1 Ignore kmers that occur fewer times than this. Values
62 over 1 can be used with raw reads to avoid error kmers.
63 minprob=0.0001 Ignore kmers below this probability of correctness.
64 minqual=0 Ignore kmers spanning bases below this quality.
65 entropy=0.66 Ignore sequence with entropy below this value.
66 merge=f Merge paired reads prior to sketching.
67 amino=f Use amino acid mode. Input should be amino acids.
68 translate=f Call genes and translate to proteins. Input should be
69 nucleotides. Designed for prokaryotes.
70 sixframes=f Translate all 6 frames instead of predicting genes.
71 ssu=t Scan for and retain full-length SSU sequence.
72 printssusequence=f Print the query SSU sequence (JSON mode only).
73 refid= Instead of a query file, specify a reference sketch by name
74 or taxid; e.g. refid=h.sapiens or refid=9606.
75
76 Size parameters:
77 size=10000 Desired size of sketches (if not using autosize).
78 mgf=0.01 (maxfraction) Max fraction of genomic kmers to use.
79 minsize=100 Do not generate sketches for genomes smaller than this.
80 autosize=t Use flexible sizing instead of fixed-length. This is
81 nonlinear; a human sketch is only ~6x a bacterial sketch.
82 sizemult=1 Multiply the autosized size of sketches by this factor.
83 Normally a bacterial-size genome will get a sketch size
84 of around 10000; if autosizefactor=2, it would be ~20000.
85 density= If this flag is set (to a number between 0 and 1),
86 autosize and sizemult are ignored, and this fraction of
87 genomic kmers are used. For example, at density=0.001,
88 a 4.5Mbp bacteria will get a 4500-kmer sketch.
89 sketchheapfactor=4 If minkeycount>1, temporarily track this many kmers until
90 counts are known and low-count kmers are discarded.
91
92 Taxonomy and filtering parameters:
93 level=2 Only report the best record per taxa at this level.
94 Either level names or numbers may be used.
95 0: disabled
96 1: subspecies
97 2: species
98 3: genus
99 ...etc
100 include= Restrict output to organisms in these clades.
101 May be a comma-delimited list of names or NCBI TaxIDs.
102 includelevel=0 Promote the include list to this taxonomic level.
103 For example, include=h.sapiens includelevel=phylum
104 would only include organisms in the same phylum as human.
105 includestring= Only report records whose name contains this string.
106 exclude= Ignore organisms in these clades.
107 May be a comma-delimited list of names or NCBI TaxIDs.
108 excludelevel=0 Promote the exclude list to this taxonomic level.
109 For example, exclude=h.sapiens excludelevel=phylum
110 would exclude all organisms in the same phylum as human.
111 excludestring= Do not records whose name contains this string.
112 banunclassified=f Ignore organisms descending from nodes like
113 'unclassified Bacteria'
114 banvirus=f Ignore viruses.
115 requiressu=f Ignore records without SSUs.
116 minrefsize=0 Ignore ref sketches smaller than this (unique kmers).
117 minrefsizebases=0 Ignore ref sketches smaller than this (total base pairs).
118
119 Output format:
120 format=2 2: Default format with, per query, one query header line;
121 one column header line; and one reference line per hit.
122 3: One line per hit, with columns query, reference, ANI,
123 and sizeRatio.
124 4: JSON (format=json also works).
125 5: Constellation (format=constellation also works).
126 usetaxidname=f For format 3, print the taxID in the name column.
127 usetaxname for format 3, print the taxonomic name in the name column.
128 useimgname For format 3, print the img ID in the name column.
129 d3=f Output in JSON format, with a tree for visualization.
130
131 Output columns (for format=2):
132 printall=f Enable all output columns.
133 printani=t (ani) Print average nucleotide identity estimate.
134 completeness=t Genome completeness estimate.
135 score=f Score (used for sorting the output).
136 printmatches=t Number of kmer matches to reference.
137 printlength=f Number of kmers compared.
138 printtaxid=t NCBI taxID.
139 printimg=f IMG identifier (only for IMG data).
140 printgbases=f Number of genomic bases.
141 printgkmers=f Number of genomic kmers.
142 printgsize=t Estimated number of unique genomic kmers.
143 printgseqs=t Number of sequences (scaffolds/reads).
144 printtaxname=t Name associated with this taxID.
145 printname0=f (pn0) Original seqeuence name.
146 printqfname=t Query filename.
147 printrfname=f Reference filename.
148 printtaxa=f Full taxonomy of each record.
149 printcontam=t Print contamination estimate, and factor contaminant kmers
150 into calculations. Kmers are considered contaminant if
151 present in some ref sketch but not the current one.
152 printunique=t Number of matches unique to this reference.
153 printunique2=f Number of matches unique to this reference's taxa.
154 printunique3=f Number of query kmers unique to this reference's taxa,
155 regardless of whether they are in this reference sketch.
156 printnohit=f Number of kmers that don't hit anything.
157 printrefhits=f Average number of ref sketches hit by shared kmers.
158 printgc=f GC content.
159 printucontam=f Contam hits that hit exactly one reference sketch.
160 printcontam2=f Print contamination estimate using only kmer hits
161 to unrelated taxa.
162 contamlevel=species Taxonomic level to use for contam2/unique2/unique3.
163 NOTE: unique2/unique3/contam2/refhits require an index.
164
165 printdepth=f (depth) Print average depth of sketch kmers; intended
166 for shotgun read input.
167 printdepth2=f (depth2) Print depth compensating for genomic repeats.
168 Requires reference sketches to be generated with depth.
169 actualdepth=t If this is false, the raw average count is printed.
170 If true, the raw average (observed depth) is converted
171 to estimated actual depth (including uncovered areas).
172 printvolume=f (volume) Product of average depth and matches.
173 printca=f Print common ancestor, if query taxID is known.
174 printcal=f Print common ancestor tax level, if query taxID is known.
175 recordsperlevel=0 If query TaxID is known, and this is positive, print at
176 most this many records per common ancestor level.
177
178 Sorting:
179 sortbyscore=t Default sort order is by score.
180 sortbydepth=f Include depth as a factor in sort order.
181 sortbydepth2=f Include depth2 as a factor in sort order.
182 sortbyvolume=f Include volume as a factor in sort order.
183 sortbykid=f Sort strictly by KID.
184 sortbyani=f Sort strictly by ANI/AAI/WKID.
185 sortbyhits=f Sort strictly by the number of kmer hits.
186
187 Other output parameters:
188 minhits=3 (hits) Only report records with at least this many hits.
189 minani=0 (ani) Only report records with at least this ANI (0-1).
190 minwkid=0.0001 (wkid) Only report records with at least this WKID (0-1).
191 anifromwkid=t Calculate ani from wkid. If false, use kid.
192 minbases=0 Ignore ref sketches of sequences shortert than this.
193 minsizeratio=0 Don't compare sketches if the smaller genome is less than
194 this fraction of the size of the larger.
195 records=20 Report at most this many best-matching records.
196 color=family Color records at the family level. color=f will disable.
197 Colors work in most terminals but may cause odd characters
198 to appear in text editors. So, color defaults to f if
199 writing to a file.
200 intersect=f Print sketch intersections. delta=f is suggested.
201
202 Metadata parameters (optional, for the query sketch header):
203 taxid=-1 Set the NCBI taxid.
204 imgid=-1 Set the IMG id.
205 spid=-1 Set the sequencing project id (JGI-specific).
206 name= Set the name (taxname).
207 name0= Set name0 (normally the first sequence header).
208 fname= Set fname (normally the file name).
209 meta_= Set an arbitrary metadata field.
210 For example, meta_Month=March.
211
212 Other parameters:
213 requiredmeta= (rmeta) Required optional metadata values. For example:
214 rmeta=subunit:ssu,source:silva
215 bannedmeta= (bmeta) Forbidden optional metadata values.
216
217 Java Parameters:
218 -Xmx This will set Java's memory usage, overriding autodetection.
219 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs.
220 The max is typically 85% of physical memory.
221 -eoom This flag will cause the process to exit if an out-of-memory
222 exception occurs. Requires Java 8u92+.
223 -da Disable assertions.
224
225 For more detailed information, please read /bbmap/docs/guides/BBSketchGuide.txt.
226 Please contact Brian Bushnell at [email protected] if you encounter any problems.
227 "
228 }
229
230 #This block allows symlinked shellscripts to correctly set classpath.
231 pushd . > /dev/null
232 DIR="${BASH_SOURCE[0]}"
233 while [ -h "$DIR" ]; do
234 cd "$(dirname "$DIR")"
235 DIR="$(readlink "$(basename "$DIR")")"
236 done
237 cd "$(dirname "$DIR")"
238 DIR="$(pwd)/"
239 popd > /dev/null
240
241 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
242 CP="$DIR""current/"
243
244 z="-Xmx4g"
245 z2="-Xms4g"
246 set=0
247
248 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
249 usage
250 exit
251 fi
252
253 calcXmx () {
254 source "$DIR""/calcmem.sh"
255 setEnvironment
256 parseXmx "$@"
257 if [[ $set == 1 ]]; then
258 return
259 fi
260 freeRam 3200m 84
261 z="-Xmx${RAM}m"
262 z2="-Xms${RAM}m"
263 }
264 calcXmx "$@"
265
266 sendsketch() {
267 local CMD="java $EA $EOOM $z -cp $CP sketch.SendSketch $@"
268 # echo $CMD >&2
269 eval $CMD
270 }
271
272 sendsketch "$@"