BBMAP.SH(1)
๐ BBMAP.SH(1) โ bbmap.sh ๐
okay bestie, buckle UP, because bbmap.sh from the BBMAP.SH(1) manual is literally the fast and accurate splice-aware read aligner and we are going to get you fluent in it. this is part 1, so no, we are not done, keep scrolling energy ๐ซถ
โจ NAME โจ
bbmap.sh โ Fast and accurate splice-aware read aligner. that's it, that's the whole vibe. she aligns reads, she handles splices, she's fast, she's accurate. icon behavior ๐
๐ธ SYNOPSIS ๐ธ
To index:
bbmap.sh ref=<reference fasta>
To map:
bbmap.sh in=<reads> out=<output sam>
To map without writing an index:
bbmap.sh ref=<reference fasta> in=<reads> out=<output sam> nodisk
๐ OPTIONS ๐
so <pink>in=stdin</pink> will accept reads from standard in, and <pink>out=stdout</pink> will write to standard out โ but bestie, file extensions are STILL needed to specify the format of the input and output files, okay? like <purple>in=stdin.fa.gz</purple> will read gzipped fasta from standard in, and <purple>out=stdout.sam.gz</purple> will write gzipped sam. don't skip the extension, she needs it ๐
๐ง Indexing Parameters (required when building the index) ๐ง
these are the ones you need when you're building the index, no cap:
nodisk=fโ set to true to build the index in memory and write nothing to disk except output. lowkey a vibe if you don't want index files lying around.ref=<file>โ specify the reference sequence. only do this ONCE, when building the index (unless you're using<cyan>nodisk</cyan>). one and done, bestie.build=1โ if multiple references are indexed in the same directory, each one needs a unique numeric ID (unless you're using<cyan>nodisk</cyan>). gotta keep them distinguishable, iykyk.k=13โ kmer length, range<yellow>8-15</yellow>. longer is faster but uses more memory. shorter is more sensitive. the eternal tradeoff, she's giving balance โ๏ธ- if indexing and mapping are done in two steps, K should be specified each time. both times, don't forget.
path=<.>โ specify the location to write the index, if you don't want it in the current working directory. send her somewhere else ๐ฆusemodulo=fโ throw away ~80% of kmers based on remainder modulo a number (reduces RAM by 50% and sensitivity slightly). should be enabled both when building the index AND when mapping. both times. both. ๐rebuild=fโ force a rebuild of the index (ref=should be set). out with the old, in with the new โจ
๐ Input Parameters ๐
build=1โ designate index to use. corresponds to the number specified when building the index.in=<file>โ primary reads input; required parameter. required required, like actually required ๐in2=<file>โ for paired reads in two files.interleaved=autoโ true forces paired/interleaved input; false forces single-ended mapping. if not specified, interleaved status will be autodetected from read names. she'll figure it out herself, main character energy.fastareadlen=500โ break up FASTA reads longer than this. max is<yellow>500</yellow>for BBMap and<yellow>6000</yellow>for BBMapPacBio. only works for FASTA input (use<purple>maxlen</purple>for FASTQ input). the default forbbmap.shis<yellow>500</yellow>, and formapPacBio.shis<yellow>6000</yellow>.unpigz=fโ spawn a pigz (parallel gzip) process for faster decompression than using Java. requires pigz to be installed. no pigz, no party ๐ทtouppercase=tโ (tuc) convert lowercase letters in reads to upper case (otherwise they will not match the reference). lowercase letters just will not match, fr fr.
๐ Sampling Parameters ๐
reads=-1โ set to a positive number N to only process the first N reads (or pairs), then quit.<yellow>-1</yellow>means use all reads. all of them. every last one.samplerate=1โ set to a number from<yellow>0</yellow>to<yellow>1</yellow>to randomly select that fraction of reads for mapping.<yellow>1</yellow>uses all reads.skipreads=0โ set to a number N to skip the first N reads (or pairs), then map the rest. bye to the first N, hello to the rest ๐
๐ฅ Mapping Parameters ๐ฅ
fast=fโ this flag is a macro which sets other parameters to run faster, at reduced sensitivity. bad for RNA-seq. noted. don't do it for RNA-seq.slow=fโ this flag is a macro which sets other parameters to run slower, at greater sensitivity.<cyan>vslow</cyan>is even slower. she can go slower. she can go even slower than that.maxindel=16000โ don't look for indels longer than this. lower is faster.- set to
<yellow>>=100k</yellow>for RNAseq with long introns like mammals. mammals are built different.
- set to
strictmaxindel=fโ when enabled, do not allow indels longer than<cyan>maxindel</cyan>.- by default these are not sought, but may be found anyway. sneaky little indels ๐
tipsearch=100โ look this far for read-end deletions with anchors shorter than K, using brute force. brute force, but make it fashion.minid=0.76โ approximate minimum alignment identity to look for.- higher is faster and less sensitive.
minhits=1โ minimum number of seed hits required for candidate sites.- higher is faster.
local=fโ set to true to use local, rather than global, alignments.- this will soft-clip ugly ends of poor alignments. giving those ends a little glow-up โ๏ธ
perfectmode=fโ allow only perfect mappings when set to true (very fast). perfectionism but productive.semiperfectmode=fโ allow only perfect and semiperfect (perfect except for N's in the reference) mappings. perfection, with exceptions, for N's only.threads=autoโ (t) set to number of threads desired. by default, uses all cores available. all of them. she's hungry.ambiguous=bestโ (ambig) set behavior on ambiguously-mapped reads (with multiple top-scoring mapping locations).best(use the first best site)toss(consider unmapped)random(select one top-scoring site randomly)all(retain all top-scoring sites)
samestrandpairs=fโ (ssp) specify whether paired reads should map to the same strand or opposite strands.requirecorrectstrand=tโ (rcs) forbid pairing of reads without correct strand orientation.- set to false for long-mate-pair libraries.
killbadpairs=fโ (kbp) if a read pair is mapped with an inappropriate insert size or orientation, the read with the lower mapping quality is marked unmapped. it's giving consequences.pairedonly=fโ (po) treat unpaired reads as unmapped. thus they will be sent to<cyan>outu</cyan>but not<cyan>outm</cyan>.rcomp=fโ reverse complement both reads prior to mapping (for LMP outward-facing libraries).rcompmate=fโ reverse complement read2 prior to mapping.pairlen=32000โ set max allowed distance between paired reads.- (insert size)=(pairlen)+(read1 length)+(read2 length). do the math, bestie ๐งฎ
rescuedist=1200โ don't try to rescue paired reads if avg. insert size greater than this. lower is faster.rescuemismatches=32โ maximum mismatches allowed in a rescued read. lower is faster.averagepairdist=100โ (apd) initial average distance between paired reads.- varies dynamically; does not need to be specified.
deterministic=fโ run in deterministic mode. in this case it is good to set<cyan>averagepairdist</cyan>. BBMap is deterministic without this flag if using single-ended reads, or run singlethreaded.bandwidthratio=0โ (bwr) if above zero, restrict alignment band to this fraction of read length. faster but less accurate.bandwidth=0โ (bw) set the bandwidth directly. fraction of read length. faster but less accurate.usejni=fโ (jni) do alignments faster, in C code. requires compiling the C code; details are in/jni/README.txt.maxsites2=800โ don't analyze (or print) more than this many alignments per read.ignorefrequentkmers=tโ (ifk) discard low-information kmers that occur often.excludefraction=0.03โ (ef) fraction of kmers to ignore. for example,<yellow>0.03</yellow>will ignore the most common 3% of kmers.greedy=tโ use a greedy algorithm to discard the least-useful kmers on a per-read basis. greedy in a cute way ๐kfilter=0โ if positive, potential mapping sites must have at least this many consecutive exact matches.
๐ฆ Quality and Trimming Parameters ๐ฆ
qin=autoโ set to<yellow>33</yellow>or<yellow>64</yellow>to specify input quality value ASCII offset.<yellow>33</yellow>is Sanger,<yellow>64</yellow>is old Solexa.qout=autoโ set to<yellow>33</yellow>or<yellow>64</yellow>to specify output quality value ASCII offset (only if output format is fastq).qtrim=fโ quality-trim ends before mapping. options are:<yellow>'f'</yellow>(false),<yellow>'l'</yellow>(left),<yellow>'r'</yellow>(right), and<yellow>'lr'</yellow>(both).untrim=fโ undo trimming after mapping. untrimmed bases will be soft-clipped in cigar strings.trimq=6โ trim regions with average quality below this (phred algorithm).mintrimlength=60โ (mintl) don't trim reads to be shorter than this. she has boundaries.fakefastaquality=-1โ (ffq) set to a positive number<yellow>1-50</yellow>to generate fake quality strings for fasta input reads. fake it till you make it โจignorebadquality=fโ (ibq) keep going, rather than crashing, if a read has out-of-range quality values. we do not crash in this house.usequality=tโ use quality scores when determining which read kmers to use as seeds.minaveragequality=0โ (maq) do not map reads with average quality below this.maqb=0โ if positive, calculate maq from this many initial bases.
๐ Output Parameters ๐
out=<file>โ write all reads to this file.outu=<file>โ write only unmapped reads to this file. does not include unmapped paired reads with a mapped mate.outm=<file>โ write only mapped reads to this file. includes unmapped paired reads with a mapped mate.mappedonly=fโ if true, treats<cyan>out</cyan>like<cyan>outm</cyan>.bamscript=<file>โ (bs) write a shell script to <file> that will turn the sam output into a sorted, indexed bam file. she writes the script for you, you're welcome.ordered=fโ set to true to output reads in same order as input. slower and uses more memory.overwrite=fโ (ow) allow process to overwrite existing files. only if you say so.secondary=fโ print secondary alignments.sssr=0.95โ (secondarysitescoreratio) print only secondary alignments with score of at least this fraction of primary.ssao=fโ (secondarysiteasambiguousonly) only print secondary alignments for ambiguously-mapped reads.maxsites=5โ maximum number of total alignments to print per read. only relevant when<cyan>secondary=t</cyan>.quickmatch=fโ generate cigar strings more quickly.trimreaddescriptions=fโ (trd) truncate read and ref names at the first whitespace, assuming that the remainder is a comment or description.ziplevel=2โ (zl) compression level for zip or gzip output.pigz=fโ spawn a pigz (parallel gzip) process for faster compression than Java. requires pigz to be installed.machineout=fโ set to true to output statistics in machine-friendly<yellow>'key=value'</yellow>format.printunmappedcount=fโ print the total number of unmapped reads and bases.- if input is paired, the number will be of pairs for which both reads are unmapped.
showprogress=0โ if positive, print a<yellow>'.'</yellow>every X reads. little dots of encouragement ๐showprogress2=0โ if positive, print the number of seconds since the last progress update (instead of a<yellow>'.'</yellow>).renamebyinsert=fโ renames reads based on their mapped insert size.
and that's part 1, bestie โ there's more coming, so don't go anywhere ๐
๐ธ Bloom-Filtering Parameters (bloomfilter.sh is the standalone version) ๐ธ
bloom=fโ turn on a Bloom filter so reads that share zero kmers with the reference get yeeted before they even get a chance. It eats more memory, but if most of your reads aren't matching anything, this makes mapping go so much faster. Bestie it's a whole timesaver ๐bloomhashes=2โ how many hash functions you want.bloomminhits=3โ how many hits in a row count as "okay yeah this one matched".bloomk=31โ the kmer length used by the Bloom filter.bloomserial=tโ use the serialized Bloom filter because loading it is way speedier, if you happen to have one. If you don't, it'll just make one and write it out for you. ๐ซถ
โจ Post-Filtering Parameters โจ
idfilter=0โ totally separate fromminid; this sets the exact minimum identity an alignment needs before it's allowed to be printed. Range is0to1.subfilter=-1โ ban any alignment rocking more than this many substitutions.insfilter=-1โ ban any alignment with more than this many insertions.delfilter=-1โ ban any alignment with more than this many deletions.indelfilter=-1โ ban any alignment with more than this many indels.editfilter=-1โ ban any alignment with more than this many edits.inslenfilter=-1โ ban any alignment whose insertion is longer than this.dellenfilter=-1โ ban any alignment whose deletion is longer than this.nfilter=-1โ ban any alignment with more than this manyns. And bestie, that count includesnocall,noref, and anything hanging off the ends of scaffolds. ๐
๐ Sam flags and settings ๐
noheader=fโ stop generating header lines.sam=1.4โ set it to1.4and you get Sam version 1.4 cigar strings, complete with=andX. Set it to1.3if you want plain oldMinstead.saa=t(secondaryalignmentasterisks) โ use asterisks instead of bases for sam secondary alignments. Slay.cigar=tโ set it to'f'to skip making cigar strings entirely (which, yes, is faster).keepnames=fโ keep the original names of paired reads instead of forcing both reads to share one name.intronlen=999999999โ drop this to something small like10and'D'becomes'N'in cigar strings for any deletion at least that long.rgid=โ set the readgroup ID. Every other readgroup field works the same way, just with the flagrgXX=. And if you set a readgroup flag to the word'filename'โ likergid=filenameโ then the input file name gets used instead. ๐mdtag=fโ write MD tags.nhtag=fโ write NH tags.xmtag=fโ write XM tags (heads up: this may only work correctly withambig=all).amtag=fโ write AM tags.nmtag=fโ write NM tags.xstag=fโ set it to'xs=fs','xs=ss', or'xs=us'to write XS tags for RNAseq using firststrand, secondstrand, or unstranded libraries. Cufflinks literally needs this. And JGI mainly uses'firststrand'.stoptag=fโ write a tag showing where the read stops, prefixed withYS:i:.lengthtag=fโ write a tag showing(query,ref)alignment lengths, prefixed withYL:Z:.idtag=fโ write a tag showing percent identity, prefixed withYI:f:.inserttag=fโ write a tag showing insert size, prefixed withX8:Z:.scoretag=fโ write a tag showing BBMap's raw score, prefixed withYR:i:.timetag=fโ write a tag showing how long this read took to map, prefixed withX0:i:.boundstag=fโ write a tag showing whether either read in the pair runs off the end of the reference, prefixed withXB:Z:.notags=fโ turn off all the optional tags at once. One flag, no tags, iconic.
๐ฆ Histogram and statistics output parameters ๐ฆ
scafstats=<file>โ stats on how many reads mapped to which scaffold.refstats=<file>โ stats on how many reads mapped to which reference file; this one's only for BBSplit.sortscafs=tโ sort scaffolds or references by read count.bhist=<file>โ base composition histogram, by position.qhist=<file>โ quality histogram, by position.aqhist=<file>โ histogram of average read quality.bqhist=<file>โ a quality histogram designed for box plots.lhist=<file>โ read length histogram.ihist=<file>โ write a histogram of insert sizes (for paired reads).ehist=<file>โ errors-per-read histogram.qahist=<file>โ quality accuracy histogram of error rates vs quality score.indelhist=<file>โ indel length histogram.mhist=<file>โ histogram of match, sub, del, and ins rates by read location.gchist=<file>โ read GC content histogram.gcbins=100โ how manygchistbins. Set it to'auto'to use read length.gcpairs=tโ use the average GC of paired reads.idhist=<file>โ histogram of read count vs percent identity.idbins=100โ how manyidhistbins. Set it to'auto'to use read length.statsfile=stderrโ mapping statistics get printed right here.
๐ Coverage output parameters (these may reduce speed and use more RAM) ๐
Fr fr, these ones can slow you down and gobble up extra RAM, so only turn on the ones you actually want. ๐
covstats=<file>โ per-scaffold coverage info.rpkm=<file>โ per-scaffold RPKM/FPKM counts.covhist=<file>โ histogram of the number of occurrences of each depth level.basecov=<file>โ coverage per base location.bincov=<file>โ print binned coverage per location (one line per X bases).covbinsize=1000โ set the binsize for binned coverage output.nzo=tโ only print scaffolds with nonzero coverage.twocolumn=fโ change to true to print only ID and Avg_fold instead of all 6 columns to the'out='file.32bit=fโ set to true if you need per-base coverage over 64k.strandedcov=fโ track coverage for plus and minus strand separately.startcov=fโ only track start positions of reads.secondarycov=tโ include coverage of secondary alignments.physcov=fโ calculate physical coverage for paired reads. This includes the unsequenced bases.delcoverage=t(delcov) โ count bases covered by deletions as covered. True is faster than false, bestie.covk=0โ if positive, calculate kmer coverage statistics.
โญ Java Parameters โญ
-Xmxโ this sets Java's memory usage and overrides autodetection.-Xmx20ggives you 20 gigs of RAM,-Xmx800mgives you 800 megs. The max is typically 85% of physical memory. The human genome needs around24g, or12gif you use the'usemodulo'flag. And the index uses roughly 6 bytes per reference base. ๐ง-eoomโ this flag makes the process exit if an out-of-memory exception happens. Requires Java 8u92+.-daโ disable assertions.
๐ SEE ALSO ๐
Please read bbmap/docs/guides/BBMapGuide.txt for more information.
๐ AUTHOR ๐
Written by Brian Bushnell, from Dec. 2010 - present
Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems, or post at: http://seqanswers.com/forums/showthread.php?t=41057
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 a wrap on bbmap.sh, bestie โ this is version 39.11 from September 2022, aka the BBMAP.SH(1) era. Go map some reads and slay. ๐
โจ
๐ฆ 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