BBDUK.SH(1)
π BBDUK.SH β the bbduk.sh manual, bestie edition π
okay so you opened the manual for bbduk.sh and it's giving long. don't panic. we're gonna walk through it together, every single flag, no skips, no cap. π«Ά
β¨ NAME β¨
bbduk.sh β filters, trims, or masks reads with kmer matches to an artifact/contaminant file π§
β¨ SYNOPSIS β¨
bbduk.sh in=<input file> out=<output file> ref=<contaminant files>
β¨ DESCRIPTION β¨
So what does this icon actually do? It takes your reads and compares them to the kmers in a reference dataset β and yes, you can optionally allow an edit distance, we love a flexible queen. π
Then it splits your reads into two outputs: the ones that match the reference, and the ones that don't. Simple. Clean. Two piles.
It can also trim (remove) the matching parts of the reads instead of binning whole reads β so instead of yeeting the entire read, it just snips out the contaminant bit. π
π Please read bbmap/docs/guides/BBDukGuide.txt for more information. fr fr, it's right there, go read it.
Now, about input β it can be stdin, or a fasta or fastq file, compressed or uncompressed. but here's the thing: if you pipe via stdin/stdout, please include the file type. Like, for gzipped fasta input, set in=stdin.fa.gz. the file type is the vibe check, don't skip it. π
β¨ OPTIONS β¨
πΈ Input parameters πΈ
in=<file>β your main input.in=stdin.fqwill pipe from stdin, slay.in2=<file>β input for the 2nd read of pairs when it lives in a different file.ref=<file,file>β comma-delimited list of reference files. And bestie, in addition to filenames you can also use these keywords:adapters,artifacts,phix,lambda,pjet,mtst,kapaβ¨literal=<seq,seq>β comma-delimited list of literal reference sequences. Polymers are also allowed with thepolyprefix; for example,literal=ATGGT,polyGCwill add bothATGGTandGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCβ 32+ of them, enough replicates to ensure that all kmers are present. iconic behavior honestly.touppercase=fβ (tuc) change all bases upper-case. uppercase era. πinterleaved=autoβ (int)t/foverrides interleaved autodetection. Must be set manually when streaming fastq input β like, do not let the autodetect guess, just tell it. πqin=autoβ input quality offset:33(Sanger),64, orauto.reads=-1β if positive, quit after processing X reads or pairs.copyundefined=fβ (cu) process non-AGCT IUPAC reference bases by making all possible unambiguous copies. Intended for short motifs or adapter barcodes, as time/memory use is exponential. so like, use it, but know what you're doing πsamplerate=1β set lower to only process a fraction of input reads.samref=<file>β optional reference fasta for processing sam files.
π Output parameters π
out=<file>β (outnonmatch) write reads here that do not contain kmers matching the database.out=stdout.fqwill pipe to standard out.out2=<file>β (outnonmatch2) use this to write the 2nd read of pairs to a different file.outm=<file>β (outmatch) write reads here that fail filters. In defaultkfiltermode, this means any read with a matching kmer. In any mode, it also includes reads that fail filters such asminlength,mingc,maxgc,entropy, etc. In other words, it includes all reads that do not go toout. it's the everything-else bucket. πͺ£outm2=<file>β (outmatch2) use this to write the 2nd read of pairs to a different file.outs=<file>β (outsingle) use this to write singleton reads whose mate was trimmed shorter thanminlen. poor little guys, they get their own file π₯Ίstats=<file>β write statistics about which contamininants were detected.refstats=<file>β write statistics on a per-reference-file basis.rpkm=<file>β write RPKM for each reference sequence (for RNA-seq).dump=<file>β dump kmer tables to a file, in fasta format.duk=<file>β write statistics in duk's format. DEPRECATED β οΈ like, it's still here, but it's giving legacy energy.nzo=tβ only write statistics about ref sequences with nonzero hits.overwrite=tβ (ow) grant permission to overwrite files. you're the main character, you get to say yes. πshowspeed=tβ (ss)fsuppresses display of processing speed.ziplevel=2β (zl) compression level;1(min) through9(max).fastawrap=70β length of lines in fasta output.qout=autoβ output quality offset:33(Sanger),64, orauto.statscolumns=3β (cols) number of columns for stats output,3or5.5includes base counts.rename=fβ rename reads to indicate which sequences they matched.refnames=fβ use names of reference files rather than scaffold IDs.trd=fβ truncate read and ref names at the first whitespace.ordered=fβ set to true to output reads in same order as input.maxbasesout=-1β if positive, quit after writing approximately this many bases toout(outu/outnonmatch).maxbasesoutm=-1β if positive, quit after writing approximately this many bases tooutm(outmatch).json=fβ print to screen in json format. β¨
π¦ Histogram output parameters π¦
bhist=<file>β base composition histogram by position.qhist=<file>β quality histogram by position.qchist=<file>β count of bases with each quality value.aqhist=<file>β histogram of average read quality.bqhist=<file>β quality histogram designed for box plots.lhist=<file>β read length histogram.phist=<file>β polymer length histogram.gchist=<file>β read GC content histogram.enthist=<file>β read entropy histogram.ihist=<file>β insert size histogram, for paired reads in mapped sam.gcbins=100β numbergchistbins. set toautoto use read length.maxhistlen=6000β set an upper bound for histogram lengths; higher uses more memory. The default is6000for some histograms and80000for others. π
π Histograms for mapped sam/bam files only π
histbefore=tβ calculate histograms from reads before processing.ehist=<file>β errors-per-read histogram.qahist=<file>β quality accuracy histogram of error rates versus quality score.indelhist=<file>β indel length histogram.mhist=<file>β histogram of match, sub, del, and ins rates by position.idhist=<file>β histogram of read count versus percent identity.idbins=100β numberidhistbins. set toautoto use read length.varfile=<file>β ignore substitution errors listed in this file when calculating error rates. Can be generated withCallVariants.vcf=<file>β ignore substitution errors listed in this VCF file when calculating error rates.ignorevcfindels=tβ also ignore indels listed in the VCF.
π Processing parameters π
k=27β kmer length used for finding contaminants. Contaminants shorter thankwill not be found.kmust be at least1.rcomp=tβ look for reverse-complements of kmers in addition to forward kmers.maskmiddle=tβ (mm) treat the middle base of a kmer as a wildcard, to increase sensitivity in the presence of errors. This may also be set to a number, e.g.mm=3, to mask that many bp. The defaultmm=tcorresponds tomm=1for odd-length kmers andmm=2for even-length kmers (as of v39.04), whilemm=fis always equivalent tomm=0. ok that's a lot of mm lore but it matters π«Άminkmerhits=1β (mkh) reads need at least this many matching kmers to be considered as matching the reference.minkmerfraction=0.0β (mkf) a reads needs at least this fraction of its total kmers to hit a ref, in order to be considered a match. If this andminkmerhitsare set, the greater is used.mincovfraction=0.0β (mcf) a reads needs at least this fraction of its total bases to be covered by ref kmers to be considered a match. If specified,mcfoverridesmkhandmkf.hammingdistance=0β (hdist) maximum Hamming distance for ref kmers (subs only). Memory use is proportional to(3*K)^hdist. so like, be mindful bestie.qhdist=0β Hamming distance for query kmers; impacts speed, not memory.editdistance=0β (edist) maximum edit distance from ref kmers (subs and indels). Memory use is proportional to(8*K)^edist. β οΈ that exponent goes crazyhammingdistance2=0β (hdist2) setshdistfor short kmers, when usingmink.qhdist2=0β setsqhdistfor short kmers, when usingmink.editdistance2=0β (edist2) setsedistfor short kmers, when usingmink.forbidn=fβ (fn) forbids matching of read kmers containingN. By default, these will match a referenceAifhdist>0oredist>0, to increase sensitivity.removeifeitherbad=tβ (rieb) paired reads get sent tooutmatchif either is match (or either is trimmed shorter thanminlen). Set to false to require both.trimfailures=fβ instead of discarding failed reads, trim them to1bp. This makes the statistics a bit odd. π yeah it's weird but that's what it doesfindbestmatch=fβ (fbm) if multiple matches, associate read with sequence sharing most kmers. Reduces speed.skipr1=fβ don't do kmer-based operations on read 1.skipr2=fβ don't do kmer-based operations on read 2.ecco=fβ for overlapping paired reads only. Performs errorcorrection withBBMergeprior to kmer operations.recalibrate=fβ (recal) recalibrate quality scores. Requires calibration matrices generated byCalcTrueQuality.sam=<file,file>β if recalibration is desired, and matrices have not already been generated, BBDuk will create them from the sam file.amino=fβ run in amino acid mode. Some features have not been tested, but kmer-matching works fine. Maximumkis12.
π₯ Speed and Memory parameters π₯
threads=autoβ (t) set number of threads to use; default is number of logical processors. let it cook. π³prealloc=fβ preallocate memory in table. Allows faster table loading and more efficient memory usage, for a large reference.monitor=fβ kill this process if it crashes.monitor=600,0.01would kill after 600 seconds under 1% usage. it's giving surveillance but for your own good πminrskip=1β (mns) force minimal skip interval when indexing reference kmers.1means use all,2means use every other kmer, etc.maxrskip=1β (mxs) restrict maximal skip interval when indexing reference kmers. Normally all are used forscaffolds<100kb, but with longer scaffolds, up tomaxrskip-1are skipped.rskip=β set bothminrskipandmaxrskipto the same value. If not set,rskipwill vary based on sequence length.qskip=1β skip query kmers to increase speed.1means use all.speed=0β ignore this fraction of kmer space (0-15out of16) in both reads and reference. Increases speed and reduces memory.
β οΈ Note: Do not use more than one ofspeed,qskip, andrskip. pick a lane bestie, seriously.
β¨ Trimming / Filtering / Masking parameters β¨
okay bestie, real talk: if ktrim, kmask, and ksplit are all left unset, the default vibe is kfilter. All kmer processing modes are mutually exclusive β pick one, you cannot have two. And heads up: reads only get sent to outm purely based on kmer matches in kfilter mode. That's the whole rule, periodt. π
ktrim=fβ Trim reads to remove bases matching reference kmers, plus all bases to the left or right. Values are:f(don't trim),r(trim to the right),l(trim to the left). πktrimtips=0β Set this to a positive number to performktrimon both ends, examining only the outermost X bases. π¦kmask=β Replace bases matching ref kmers with another symbol. It allows any non-whitespace character, and processes short kmers on both ends ifminkis set. And<cyan>kmask=lc</cyan>will convert masked bases to lowercase. lowercase era fr fr πΈmaskfullycovered=fβ (akamfc) Only mask bases that are fully covered by kmers.ksplit=fβ For single-ended reads only. Reads will be split into pairs around the kmer. If the kmer is at the end of the read, it will be trimmed instead. Singletons will go toout, and pairs will go tooutm. π«Ά
β οΈ Do not use ksplit with other operations such as quality-trimming or filtering. Just don't, bestie.
mink=0β Look for shorter kmers at read tips down to this length, when k-trimming or masking.0means disabled. Enabling this will disablemaskmiddle. πqtrim=fβ Trim read ends to remove bases with quality belowtrimq. This is performed AFTER looking for kmers. Values:rl(trim both ends),f(neither end),r(right end only),l(left end only),w(sliding window). β¨trimq=6β Regions with average quality BELOW this will be trimmed, ifqtrimis set to something other thanf. Can be a floating-point number like7.3. πquantizeβ Bin quality scores to reduce file size.quantize=2will eliminate all odd quality scores, whilequantize=0,10,37will only allow quality scores of0,10, or37. πtrimclip=fβ Trim soft-clipped bases from sam files.minlength=10β (akaml) Reads shorter than this after trimming will be discarded. Pairs will be discarded if both are shorter. πmlf=0β (akaminlengthfraction) Reads shorter than this fraction of original length after trimming will be discarded.maxlength=β Reads longer than this after trimming will be discarded.minavgquality=0β (akamaq) Reads with average quality (after trimming) below this will be discarded.maqb=0β If positive, calculatemaqfrom this many initial bases.minbasequality=0β (akambq) Reads with any base below this quality (after trimming) will be discarded. brutal πmaxns=-1β If non-negative, reads with more Ns than this (after trimming) will be discarded.mcb=0β (akaminconsecutivebases) Discard reads without at least this many consecutive called bases.ottm=fβ (akaoutputtrimmedtomatch) Output reads trimmed to shorter thanminlengthtooutmrather than discarding.tp=0β (akatrimpad) Trim this much extra around matching kmers.tbo=fβ (akatrimbyoverlap) Trim adapters based on where paired reads overlap.strictoverlap=tβ Adjust sensitivity fortrimbyoverlapmode.minoverlap=14β Require this many bases of overlap for detection.mininsert=40β Require insert size of at least this for overlap. Should be reduced to16for small RNA sequencing. π§tpe=fβ (akatrimpairsevenly) When kmer right-trimming, trim both reads to the minimum length of either.forcetrimleft=0β (akaftl) If positive, trim bases to the left of this position (exclusive, 0-based).forcetrimright=0β (akaftr) If positive, trim bases to the right of this position (exclusive, 0-based).forcetrimright2=0β (akaftr2) If positive, trim this many bases on the right end.forcetrimmod=0β (akaftm) If positive, right-trim length to be equal to zero, modulo this number. math era πrestrictleft=0β If positive, only look for kmer matches in the leftmost X bases.restrictright=0β If positive, only look for kmer matches in the rightmost X bases.
π NOTE:restrictleftandrestrictrightare mutually exclusive. If trimming both ends is desired, usektrimtips. bestie I'm telling you this once. π«Ά
mingc=0β Discard reads with GC content below this.maxgc=1β Discard reads with GC content above this.gcpairs=tβ Use average GC of paired reads. Also affectsgchist. πtossjunk=fβ Discard reads with invalid characters as bases. trash, get it out ποΈswift=fβ Trim Swift sequences: Trailing C/T/N R1, leading G/A/N R2.
π Header-parsing parameters π
these require Illumina headers, no exceptions iykyk
chastityfilter=fβ (akacf) Discard reads with id containing' 1:Y:'or' 2:Y:'.barcodefilter=fβ Remove reads with unexpected barcodes ifbarcodesis set, or barcodes containing'N'otherwise. A barcode must be the last part of the read header. Values:tremoves reads with bad barcodes,fignores barcodes, andcrashwill literally crash upon encountering bad barcodes. πbarcodes=β Comma-delimited list of barcodes or files of barcodes.xmin=-1β If positive, discard reads with a lesser X coordinate.ymin=-1β If positive, discard reads with a lesser Y coordinate.xmax=-1β If positive, discard reads with a greater X coordinate.ymax=-1β If positive, discard reads with a greater Y coordinate.
πΈ Polymer trimming πΈ
trimpolya=0β If greater than 0, trim poly-A or poly-T tails of at least this length on either end of reads.trimpolygleft=0β If greater than 0, trim poly-G prefixes of at least this length on the left end of reads. Does not trim poly-C.trimpolygright=0β If greater than 0, trim poly-G tails of at least this length on the right end of reads. Does not trim poly-C.trimpolyg=0β This sets both left and right at once. one setting to rule them both π«Άfilterpolyg=0β If greater than 0, remove reads with a poly-G prefix of at least this length (on the left).
π Note: there are also equivalent poly-C flags. don't forget them bestie
π Polymer tracking π
pratio=base,baseβpratio=G,Cwill print the ratio of G to C polymers.plen=20β Length of homopolymers to count.
β¨ Entropy / Complexity parameters β¨
entropy=-1β Set between0and1to filter reads with entropy below that value. Higher is more stringent.entropywindow=50β Calculate entropy using a sliding window of this length.entropyk=5β Calculate entropy using kmers of this length.minbasefrequency=0β Discard reads with a minimum base frequency below this.entropytrim=fβ Values:f(false) do not entropy-trim,r(right) trim low entropy on the right end only,l(left) trim low entropy on the left end only,rl(both) trim low entropy on both ends. πentropymask=fβ Values:f(filter) discard low-entropy sequences,t(true) mask low-entropy parts of sequences withN,lcchange low-entropy parts of sequences to lowercase.entropymark=fβ Mark each base with its entropy value. This is on a scale of0-41and is reported as quality scores, so the output should befastqorfasta+qual. π
π NOTE: If set,entropytrimoverridesentropymask. queen takes precedence π
π¦ Cardinality estimation π¦
cardinality=fβ (akaloglog) Count unique kmers using the LogLog algorithm.cardinalityout=fβ (akaloglogout) Count unique kmers in output reads.loglogk=31β Use this kmer length for counting.loglogbuckets=2048β Use this many buckets for counting.khist=<file>β Kmer frequency histogram; plots number of kmers versus kmer depth. This is approximate. πkhistout=<file>β Kmer frequency histogram for output reads.
π Side Channel π
sideout=<file>β Output for aligned reads.sideref=phixβ Reference for side-channel alignment; must be a single sequence and virtually repeat-free at selected k.sidek1=17β Kmer length for seeding alignment to reference.sidek2=13β Kmer length for seeding alignment of unaligned reads with an aligned mate.sideminid1=0.66β Minimum identity to accept individual alignments.sideminid2=0.58β Minimum identity for aligning reads with aligned mates.sidemm1=1β Middle mask length forsidek1.sidemm2=1β Middle mask length forsidek2.
π Note: The side channel is a special additional output that allows alignment to a secondary reference while also doing trimming. Alignment does not affect whether reads go to the normal outputs (out,outm). The main purpose is to simplify pipelines that need trimmed, aligned phiX reads for recalibration. main character side quest energy fr fr π
π Java Parameters π
-Xmxβ This will set Java's memory usage, overriding autodetection.-Xmx20gwill specify 20 gigs of RAM, and-Xmx200mwill specify 200 megs. The max is typically 85% of physical memory.-eoomβ This flag will cause the process to exit if an out-of-memory exception occurs. Requires Java8u92+.-daβ Disable assertions.
π AUTHOR π
Written by Brian Bushnell, Last modified October 9, 2024. Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems. π«Ά
This manpage was written by Andreas Tille for the Debian distribution and can be used for any other usage of the program. β¨
and that's the whole page bestie!! π bbduk.sh version 39.11, dated October 2024 β go forth and trim, you absolute icon ππ
π¦ where this page comes from
- debian trixie: bbmap 39.20+dfsg-2 Β· BSD-3-Clause
- ubuntu questing: bbmap 39.20+dfsg-2
- ubuntu resolute: bbmap 39.20+dfsg-3 Β· BSD-3-Clause
- ubuntu stonking: bbmap 39.20+dfsg-3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms