Scroll to navigation

BBMAP(1) User Commands BBMAP(1)


bbmap - Fast and accurate splice-aware read aligner.


To index: ref=<reference fasta>

To map: in=<reads> out=<output sam>

To map without writing an index: ref=<reference fasta> in=<reads> out=<output sam> nodisk


in=stdin will accept reads from standard in, and out=stdout will write to standard out, but file extensions are still needed to specify the format of the input and output files e.g. in=stdin.fa.gz will read gzipped fasta from standard in; out=stdout.sam.gz will write gzipped sam.

Indexing Parameters (required when building the index):

Set to true to build index in memory and write nothing to disk except output.
Specify the reference sequence. Only do this ONCE, when building the index (unless using 'nodisk').
If multiple references are indexed in the same directory, each needs a unique numeric ID (unless using 'nodisk').
Kmer length, range 8-15. Longer is faster but uses more memory. Shorter is more sensitive.
If indexing and mapping are done in two steps, K should be specified each time.
Specify the location to write the index, if you don't want it in the current working directory.
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.
Force a rebuild of the index (ref= should be set).

Input Parameters:

Designate index to use. Corresponds to the number specified when building the index.
Primary reads input; required parameter.
For paired reads in two files.
True forces paired/interleaved input; false forces single-ended mapping. If not specified, interleaved status will be autodetected from read names.
Break up FASTA reads longer than this. Max is 500 for BBMap and 6000 for BBMapPacBio. Only works for FASTA input (use 'maxlen' for FASTQ input). The default for is 500, and for is 6000.
Spawn a pigz (parallel gzip) process for faster decompression than using Java. Requires pigz to be installed.
(tuc) Convert lowercase letters in reads to upper case (otherwise they will not match the reference).

Sampling Parameters:

Set to a positive number N to only process the first N reads (or pairs), then quit. -1 means use all reads.
Set to a number from 0 to 1 to randomly select that fraction of reads for mapping. 1 uses all reads.
Set to a number N to skip the first N reads (or pairs), then map the rest.

Mapping Parameters:

This flag is a macro which sets other paramters to run faster, at reduced sensitivity. Bad for RNA-seq.
This flag is a macro which sets other paramters to run slower, at greater sensitivity. 'vslow' is even slower.
Don't look for indels longer than this. Lower is faster.
Set to >=100k for RNAseq with long introns like mammals.
When enabled, do not allow indels longer than 'maxindel'.
By default these are not sought, but may be found anyway.
Look this far for read-end deletions with anchors shorter than K, using brute force.
Approximate minimum alignment identity to look for.
Higher is faster and less sensitive.
Minimum number of seed hits required for candidate sites.
Higher is faster.
Set to true to use local, rather than global, alignments.
This will soft-clip ugly ends of poor alignments.
Allow only perfect mappings when set to true (very fast).
Allow only perfect and semiperfect (perfect except for N's in the reference) mappings.
(t) Set to number of threads desired. By default, uses all cores available.
(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)
(ssp) Specify whether paired reads should map to the same strand or opposite strands.
(rcs) Forbid pairing of reads without correct strand orientation.
Set to false for long-mate-pair libraries.
(kbp) If a read pair is mapped with an inappropriate insert size or orientation, the read with the lower mapping quality is marked unmapped.
(po) Treat unpaired reads as unmapped. Thus they will be sent to 'outu' but not 'outm'.
Reverse complement both reads prior to mapping (for LMP outward-facing libraries).
Reverse complement read2 prior to mapping.
Set max allowed distance between paired reads.
(insert size)=(pairlen)+(read1 length)+(read2 length)
Don't try to rescue paired reads if avg. insert size greater than this. Lower is faster.
Maximum mismatches allowed in a rescued read. Lower is faster.
(apd) Initial average distance between paired reads.
Varies dynamically; does not need to be specified.
Run in deterministic mode. In this case it is good to set averagepairdist. BBMap is deterministic without this flag if using single-ended reads, or run singlethreaded.
(bwr) If above zero, restrict alignment band to this fraction of read length. Faster but less accurate.
(bw) Set the bandwidth directly. fraction of read length. Faster but less accurate.
(jni) Do alignments faster, in C code.
Don't analyze (or print) more than this many alignments per read.
(ifk) Discard low-information kmers that occur often.
(ef) Fraction of kmers to ignore. For example, 0.03 will ignore the most common 3% of kmers.
Use a greedy algorithm to discard the least-useful kmers on a per-read basis.
If positive, potential mapping sites must have at least this many consecutive exact matches.

Quality and Trimming Parameters:

Set to 33 or 64 to specify input quality value ASCII offset. 33 is Sanger, 64 is old Solexa.
Set to 33 or 64 to specify output quality value ASCII offset (only if output format is fastq).
Quality-trim ends before mapping. Options are:" 'f' (false), 'l' (left), 'r' (right), and 'lr' (both).
Undo trimming after mapping. Untrimmed bases will be soft-clipped in cigar strings.
Trim regions with average quality below this (phred algorithm).
(mintl) Don't trim reads to be shorter than this.
(ffq) Set to a positive number 1-50 to generate fake quality strings for fasta input reads.
(ibq) Keep going, rather than crashing, if a read has out-of-range quality values.
Use quality scores when determining which read kmers to use as seeds.
(maq) Do not map reads with average quality below this.
If positive, calculate maq from this many initial bases.

Output Parameters:

Write all reads to this file.
Write only unmapped reads to this file. Does not include unmapped paired reads with a mapped mate.
Write only mapped reads to this file. Includes unmapped paired reads with a mapped mate.
If true, treats 'out' like 'outm'.
(bs) Write a shell script to <file> that will turn the sam output into a sorted, indexed bam file.
Set to true to output reads in same order as input. Slower and uses more memory.
(ow) Allow process to overwrite existing files.
Print secondary alignments.
(secondarysitescoreratio) Print only secondary alignments with score of at least this fraction of primary.
(secondarysiteasambiguousonly) Only print secondary alignments for ambiguously-mapped reads.
Maximum number of total alignments to print per read. Only relevant when secondary=t.
Generate cigar strings more quickly.
(trd) Truncate read and ref names at the first whitespace, assuming that the remainder is a comment or description.
(zl) Compression level for zip or gzip output.
Spawn a pigz (parallel gzip) process for faster compression than Java.
Set to true to output statistics in machine-friendly 'key=value' format.
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.
If positive, print a '.' every X reads.
If positive, print the number of seconds since the last progress update (instead of a '.').
Renames reads based on their mapped insert size.

Bloom-Filtering Parameters ( is the standalone version).

Use a Bloom filter to ignore reads not sharing kmers with the reference. This uses more memory, but speeds mapping when most reads don't match the reference.
Number of hash functions.
Number of consecutive hits to be considered matched.
Bloom filter kmer length.
Use the serialized Bloom filter for greater loading speed, if available. If not, generate and write one.

Post-Filtering Parameters:

Independant of minid; sets exact minimum identity allowed for alignments to be printed. Range 0 to 1.
Ban alignments with more than this many substitutions.
Ban alignments with more than this many insertions.
Ban alignments with more than this many deletions.
Ban alignments with more than this many indels.
Ban alignments with more than this many edits.
Ban alignments with an insertion longer than this.
Ban alignments with a deletion longer than this.
Ban alignments with more than this many ns. This includes nocall, noref, and off scaffold ends.

Sam flags and settings:

Disable generation of header lines.
Set to 1.4 to write Sam version 1.4 cigar strings, with = and X, or 1.3 to use M.
(secondaryalignmentasterisks) Use asterisks instead of bases for sam secondary alignments.
Set to 'f' to skip generation of cigar strings (faster).
Keep original names of paired reads, rather than ensuring both reads have the same name.
Set to a lower number like 10 to change 'D' to 'N' in cigar strings for deletions of at least that length.
Set readgroup ID. All other readgroup fields can be set similarly, with the flag rgXX=
Write MD tags.
Write NH tags.
Write XM tags (may only work correctly with ambig=all).
Write AM tags.
Write NM tags.
Set to 'xs=fs', 'xs=ss', or 'xs=us' to write XS tags for RNAseq using firststrand, secondstrand, or unstranded libraries. Needed by Cufflinks. JGI mainly uses 'firststrand'.
Write a tag indicating read stop location, prefixed by YS:i:
Write a tag indicating (query,ref) alignment lengths, prefixed by YL:Z:
Write a tag indicating percent identity, prefixed by YI:f:
Write a tag indicating insert size, prefixed by X8:Z:
Write a tag indicating BBMap's raw score, prefixed by YR:i:
Write a tag indicating this read's mapping time, prefixed by X0:i:
Write a tag indicating whether either read in the pair goes off the end of the reference, prefixed by XB:Z:
Turn off all optional tags.

Histogram and statistics output parameters:

Statistics on how many reads mapped to which scaffold.
Statistics on how many reads mapped to which reference file; only for BBSplit.
Sort scaffolds or references by read count.
Base composition histogram by position.
Quality histogram by position.
Histogram of average read quality.
Quality histogram designed for box plots.
Read length histogram.
Write histogram of insert sizes (for paired reads).
Errors-per-read histogram.
Quality accuracy histogram of error rates versus quality score.
Indel length histogram.
Histogram of match, sub, del, and ins rates by read location.
Read GC content histogram.
Number gchist bins. Set to 'auto' to use read length.
Use average GC of paired reads.
Histogram of read count versus percent identity.
Number idhist bins. Set to 'auto' to use read length.
Mapping statistics are printed here.

Coverage output parameters (these may reduce speed and use more RAM):

Per-scaffold coverage info.
Per-scaffold RPKM/FPKM counts.
Histogram of # occurrences of each depth level.
Coverage per base location.
Print binned coverage per location (one line per X bases).
Set the binsize for binned coverage output.
Only print scaffolds with nonzero coverage.
Change to true to print only ID and Avg_fold instead of all 6 columns to the 'out=' file.
Set to true if you need per-base coverage over 64k.
Track coverage for plus and minus strand independently.
Only track start positions of reads.
Include coverage of secondary alignments.
Calculate physical coverage for paired reads. This includes the unsequenced bases.
(delcov) Count bases covered by deletions as covered. True is faster than false.
If positive, calculate kmer coverage statistics.

Java Parameters:

This will set Java's memory usage, overriding autodetection. -Xmx20g will specify 20 gigs of RAM, and -Xmx800m will specify 800 megs. The max is typically 85% of physical memory. The human genome requires around 24g, or 12g with the 'usemodulo' flag. The index uses roughly 6 bytes per reference base.
This flag will cause the process to exit if an out-of-memory exception occurs. Requires Java 8u92+.
Disable assertions.


Please read bbmap/docs/guides/BBMapGuide.txt for more information.


Written by Brian Bushnell, from Dec. 2010 - present

Please contact Brian Bushnell at if you encounter any problems, or post at:

This manpage was written by Andreas Tille for the Debian distribution and can be used for any other usage of the program.

March 2019 bbmap 38.43