samtools(1)

๐Ÿ’– NAME ๐Ÿ’–

samtools โ€” bestie, it's the toolkit for the Sequence Alignment/Map (SAM) format โœจ (yes, this is the samtools(1) page, the mothership one, sit down and get comfy ๐Ÿซถ)


๐ŸŒธ SYNOPSIS ๐ŸŒธ

okay so there are so many little sub-commands, here's the whole squad in one place, no cap:

samtools addreplacerg -r 'ID:fish' -r 'LB:1334' -r 'SM:alpha' -o
output.bam input.bam

samtools ampliconclip -b bed.file input.bam

samtools ampliconstats primers.bed in.bam

samtools bedcov aln.sorted.bam

samtools calmd in.sorted.bam ref.fasta

samtools cat out.bam in1.bam in2.bam in3.bam

samtools checksum in.bam

samtools collate -o aln.name_collated.bam aln.sorted.bam

samtools consensus -o out.fasta in.bam

samtools coverage aln.sorted.bam

samtools cram-size -v -o out.size in.cram

samtools depad input.bam

samtools depth aln.sorted.bam

samtools dict -a GRCh38 -s "Homo sapiens" ref.fasta

samtools faidx ref.fasta

samtools fasta input.bam > output.fasta

samtools fastq input.bam > output.fastq

samtools fixmate in.namesorted.sam out.bam

samtools flags PAIRED,UNMAP,MUNMAP

samtools flagstat aln.sorted.bam

samtools fqidx ref.fastq

samtools head in.bam

samtools idxstats aln.sorted.bam

samtools import input.fastq > output.bam

samtools index aln.sorted.bam

samtools markdup in.algnsorted.bam out.bam

samtools merge out.bam in1.bam in2.bam in3.bam

samtools mpileup -f ref.fasta -r chr3:1,000-2,000 in1.bam in2.bam

samtools phase input.bam

samtools quickcheck in1.bam in2.cram

samtools reference -o ref.fa in.cram

samtools reheader in.header.sam in.bam > out.bam

samtools reset -o /tmp/reset.bam processed.bam

samtools samples input.bam

samtools sort -T /tmp/aln.sorted -o aln.sorted.bam aln.bam

samtools split merged.bam

samtools stats aln.sorted.bam

samtools targetcut input.bam

samtools tview aln.sorted.bam ref.fasta

samtools view -bt ref_list.txt -o aln.bam aln.sam.gz

like, look at all of them ๐Ÿ’… iconic behaviour, every single one.


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so samtools is basically a whole set of utilities that manipulate alignments in the SAM (Sequence Alignment/Map), BAM, and CRAM formats. it converts between the formats, it does sorting, merging and indexing, and it can retrieve reads in any regions swiftly. literally the full package bestie ๐Ÿ”ฅ

Samtools is designed to work on a stream. it treats an input file <code>-</code> as the standard input (stdin) and an output file <code>-</code> as the standard output (stdout). several commands can thus be combined with Unix pipes, which is giving main character energy ngl. and Samtools always outputs warning and error messages to the standard error output (stderr) โ€” so keep an eye on that channel, bestie ๐Ÿ‘€

Samtools is also able to open files on remote FTP or HTTP(S) servers if the file name starts with <code>ftp://</code>, <code>http://</code>, etc. Samtools checks the current working directory for the index file and will download the index upon absence. Samtools does not retrieve the entire alignment file unless it is asked to do so โ€” it's lowkey polite like that ๐ŸŽ€

If an index is needed, samtools looks for the index suffix appended to the filename, and if that isn't found it tries again without the filename suffix (for example <code>in.bam.bai</code> followed by <code>in.bai</code>). However if an index is in a completely different location or has a different name, both the main data filename and index filename can be pasted together with <code>##idx##</code>. For example <code>/data/in.bam##idx##/indices/in.bam.bai</code> may be used to explicitly indicate where the data and index files reside. so if you're ever like "where is my index ๐Ÿ˜ญ" โ€” that's the move. iykyk.


๐Ÿ‘‘ COMMANDS ๐Ÿ‘‘

Each command has its own man page which can be viewed using e.g. <code>man samtools-view</code> or with a recent GNU man using <code>man samtools view</code>. below we have a brief summary of syntax and sub-command description โœจ

Options common to all sub-commands are documented below in the GLOBAL COMMAND OPTIONS section โ€” so don't come for me if a flag isn't listed here, it's chillin' in that section ๐Ÿ’œ


๐Ÿ’… view

samtools view [options] in.sam|in.bam|in.cram [region...]

With no options or regions specified, it prints all alignments in the specified input alignment file (in SAM, BAM, or CRAM format) to standard output in SAM format (with no header by default). the humble default, we stan ๐Ÿซถ

You may specify one or more space-separated region specifications after the input filename to restrict output to only those alignments which overlap the specified region(s). โš ๏ธ use of region specifications requires a coordinate-sorted and indexed input file โ€” no index, no vibes, that's the rule.

Options exist to change the output format from SAM to BAM or CRAM, so this command also acts as a file format conversion utility. multi-talented fr fr ๐Ÿ’…


๐Ÿงš tview

samtools tview [-p chr:pos] [-s STR] [-d display]
               <in.sorted.bam> [ref.fasta]

Text alignment viewer (based on the ncurses library) โ€” yes bestie, a whole viewer, right there in your terminal ๐ŸŒˆ in the viewer, press ? for help and press g to check the alignment start from a region in the format like <code>chr10:10,000,000</code> or <code>=10,000,000</code> when viewing the same reference sequence. so cute, so useful.


โญ quickcheck

samtools quickcheck [options] in.sam|in.bam|in.cram [ ... ]

Quickly check that input files appear to be intact. it checks that beginning of the file contains a valid header (all formats) containing at least one target sequence, and then seeks to the end of the file and checks that an end-of-file (EOF) is present and intact (BAM only). the vibe check of commands, literally ๐Ÿฆ‹

Data in the middle of the file is not read since that would be much more time consuming, so please note that this command will not detect internal corruption โ€” but it is useful for testing that files are not truncated before performing more intensive tasks on them. so it's a sniff test, not a full medical exam, got it? ๐Ÿ’€

This command will exit with a non-zero exit code if any input files don't have a valid header or are missing an EOF block. otherwise it will exit successfully (with a zero exit code) ๐ŸŽ€


๐Ÿ”ฅ checksum

samtools checksum [options] in.sam|in.bam|in.cram

<s>samtools</s> samtools checksum produces a CRC32 based checksum of data contained within a BAM file. this can either be order and orientation agnostic โ€” for purposes of validating all the sequencing data has passed through the entire pipeline from FASTQ through alignment and sorting โ€” or full alignment information and order aware, for the purposes of validating format conversions and while file data processing. pick your fighter, both slay โœจ


samtools head [options] in.sam|in.bam|in.cram

Prints the input file's headers and optionally also its first few alignment records. This command always displays the headers as they are in the file, never adding an extra @PG header itself โ€” no notes, no edits, just the raw truth, periodt ๐Ÿ’…


๐Ÿ’œ index

samtools index [-bc] [-m INT] aln.sam.gz|aln.bam|aln.cram
               [out.index]

Index a coordinate-sorted SAM, BAM or CRAM file for fast random access. ๐Ÿšจ note for SAM this only works if the file has been BGZF compressed first. (Starting from Samtools 1.16, this command can also be given several alignment filenames, which are indexed individually โ€” glow up ๐ŸŒธ)

This index is needed when region arguments are used to limit samtools view and similar commands to particular regions of interest. no index = no region peeking, sorry bestie.

If an output filename is given, the index file will be written to out.index. Otherwise, for a CRAM file aln.cram, index file aln.cram.crai will be created; for a BAM or SAM file aln.bam, either aln.bam.bai or aln.bam.csi will be created, depending on the index format selected. so it picks the name for you, we love a self-sufficient icon ๐Ÿ‘‘


๐ŸŒˆ sort

samtools sort [-l level] [-m maxMem] [-o out.bam] [-O format]
              [-n] [-t tag] [-T tmpprefix] [-@ threads]
              [in.sam|in.bam|in.cram]

Sort alignments by leftmost coordinates, or by read name when -n is used. An appropriate @HD-SO sort order header tag will be added or an existing one updated if necessary โ€” it keeps the receipts tidy ๐Ÿงพโœจ

The sorted output is written to standard output by default, or to the specified file (out.bam) when -o is used. This command will also create temporary files tmpprefix.%d.bam as needed when the entire alignment data cannot fit into memory (as controlled via the -m option). so yeah, it spills to disk, that's the whole point ๐Ÿ’€

Consider using samtools collate instead if you need name collated data without a full lexicographical sort. different vibe, different tool ๐Ÿฆ‹

โš ๏ธ Note that if the sorted output file is to be indexed with samtools index, the default coordinate sort must be used. Thus the -n and -t options are incompatible with samtools index. like, they literally cannot sit at the same table, bestie ๐Ÿ˜ญ

๐ŸŽ€ collate

samtools collate [options] in.sam|in.bam|in.cram [<prefix>]

Shuffles and groups reads together by their names. a faster alternative to a full query name sort, collate ensures that reads of the same name are grouped together in contiguous groups, but doesn't make any guarantees about the order of read names between groups โ€” so like, the friend groups are together, but the seating chart between groups is chaos ๐Ÿ™ˆ

The output from this command should be suitable for any operation that requires all reads from the same template to be grouped together. that's the whole assignment and it ate ๐Ÿ’…


๐Ÿซถ cram-size

samtools cram-size [options] in.cram

Produces a summary of CRAM block Content ID numbers and their associated Data Series stored within them. Optionally a more detailed breakdown of how each data series is encoded per container may also be listed using the -e or --encodings option. for the data girlies who want โœจdetailโœจ


๐ŸŒธ idxstats

samtools idxstats in.sam|in.bam|in.cram

Retrieve and print stats in the index file corresponding to the input file. Before calling idxstats, the input BAM file should be indexed by samtools index. gotta do the homework first ๐Ÿ“š

If run on a SAM or CRAM file or an unindexed BAM file, this command will still produce the same summary statistics, but does so by reading through the entire file. This is far slower than using the BAM indices โ€” so like, it works, but it's giving walking instead of taking the bus ๐Ÿ˜ญ

The output is TAB-delimited with each line consisting of reference sequence name, sequence length, # mapped reads and # unmapped reads. It is written to stdout. clean, simple, four little fields, we love a minimalist ๐ŸŽ€


๐Ÿงš flagstat

samtools flagstat in.sam|in.bam|in.cram

Does a full pass through the input file to calculate and print statistics to stdout. full send, no shortcuts ๐Ÿ’…

Provides counts for each of 13 categories based primarily on bit flags in the FLAG field. Each category in the output is broken down into QC pass and QC fail, which is presented as #PASS + #FAIL followed by a description of the category. thirteen categories, all accounted for, no notes ๐Ÿ‘‘


โญ flags

samtools flags INT|STR[,...]

Convert between textual and numeric flag representation. tiny command, huge service โ€” the translator of the group chat ๐Ÿฆ‹โœจ


more parts coming bestie, don't go anywhere ๐Ÿ’–

๐Ÿšฉ FLAGS ๐Ÿšฉ

Okay bestie, these are the flag bits โ€” tiny little power-ups packed into one number, and each one means something very specific. No cap, memorize the ones you use. ๐Ÿ’…

  • 0x1, PAIRED โ€” paired-end (or multiple-segment) sequencing technology
  • 0x2, PROPER_PAIR โ€” each segment properly aligned according to the aligner
  • 0x4, UNMAP โ€” segment unmapped
  • 0x8, MUNMAP โ€” next segment in the template unmapped
  • 0x10, REVERSE โ€” SEQ is reverse complemented
  • 0x20, MREVERSE โ€” SEQ of the next segment in the template is reverse complemented
  • 0x40, READ1 โ€” the first segment in the template
  • 0x80, READ2 โ€” the last segment in the template
  • 0x100, SECONDARY โ€” secondary alignment
  • 0x200, QCFAIL โ€” not passing quality controls
  • 0x400, DUP โ€” PCR or optical duplicate
  • 0x800, SUPPLEMENTARY โ€” supplementary alignment

๐ŸŒธ stats

samtools stats [options] in.sam|in.bam|in.cram [region...]

<pink>samtools stats</pink> collects statistics from BAM files and outputs them in a text format. The output can be visualized graphically using plot-bamstats. It's giving โ€œI ran the numbers and made them cute.โ€ โœจ


๐Ÿงš bedcov

samtools bedcov [options] region.bed in1.sam|in1.bam|in1.cram[...]

Reports the total read base count (i.e. the sum of per base read depths) for each genomic region specified in the supplied BED file. The regions are output as they appear in the BED file and are 0-based. Counts for each alignment file supplied are reported in separate columns. Columns? We love a clean little spreadsheet moment. ๐Ÿ“Š


๐Ÿ’œ depth

samtools depth [options] [in1.sam|in1.bam|in1.cram [in2.sam|in2.bam|in2.cram] [...]]

Computes the read depth at each position or region. Depth check, but make it genomic. ๐Ÿ’…


๐Ÿฆ‹ ampliconstats

samtools ampliconstats [options] primers.bed in.sam|in.bam|in.cram[...]

<hotpink>samtools ampliconstats</hotpink> collects statistics from one or more input alignment files and produces tables in text format. The output can be visualized graphically using plot-ampliconstats. ๐ŸŒˆ

The alignment files should have previously been clipped of primer sequence, for example by samtools ampliconclip, and the sites of these primers should be specified as a bed file in the arguments. Primer sites go in the BED file โ€” that's the assignment. ๐ŸŽ€


๐ŸŽ€ mpileup

samtools mpileup [-EB] [-C capQcoef] [-r reg] [-f in.fa] [-l list] [-Q minBaseQ] [-q minMapQ] in.bam [in2.bam [...]]

Generate textual pileup for one or multiple BAM files. For VCF and BCF output, please use the bcftools mpileup command instead. Not me trying to make VCFs with the wrong tool โ€” use bcftools mpileup, bestie. ๐Ÿ’€

Alignment records are grouped by sample (SM) identifiers in @RG header lines. If sample identifiers are absent, each input file is regarded as one sample. See the samtools-mpileup man page for a description of the pileup format and options. ๐Ÿ“š


๐ŸŒŸ consensus

samtools consensus [options] in.bam

Generate consensus from a SAM, BAM or CRAM file based on the contents of the alignment records. The consensus is written either as FASTA, FASTQ, or a pileup oriented format. Consensus is literally the main character here. ๐Ÿ‘‘

The default output for FASTA and FASTQ formats include one base per non-gap consensus. Hence insertions with respect to the aligned reference will be included and deletions removed. This behaviour can be adjusted. โœจ

Two consensus calling algorithms are offered. The default computes a heterozygous consensus in a Bayesian manner, derived from the "Gap5" consensus algorithm. A simpler base frequency counting method is also available. Bayesian heterozygous? Obsessed. ๐Ÿงฌ


๐Ÿ“ reference

samtools reference [options] in.bam

Generate a reference from a SAM, BAM or CRAM file based on the contents of the SEQuence field and the MD:Z: auxiliary tags, or from the embedded reference blocks within a CRAM file (provided it was constructed using the embed_ref=1 option). Embedded reference blocks, iykyk. ๐Ÿงš


๐ŸŒˆ coverage

samtools coverage [options] [in1.sam|in1.bam|in1.cram [in2.sam|in2.bam|in2.cram] [...]]

Produces a histogram or table of coverage per chromosome. Chromosome-by-chromosome coverage? Slay. ๐Ÿ’…


๐Ÿ”ฅ merge

samtools merge [-nur1f] [-h inh.sam] [-t tag] [-R reg] [-b list] out.bam in1.bam [in2.bam in3.bam ... inN.bam]

Merge multiple sorted alignment files, producing a single sorted output file that contains all the input records and maintains the existing sort order. <orange>One file to rule them all.</orange> ๐Ÿ‘‘

If -h is specified the @SQ headers of input files will be merged into the specified header, otherwise they will be merged into a composite header created from the input headers. If the @SQ headers differ in order this may require the output file to be re-sorted after merge. Header order drama = possible re-sort. Don't ignore it. ๐Ÿ˜ญ

The ordering of the records in the input files must match the usage of the -n and -t command-line options. If they do not, the output order will be undefined. See sort for information about record ordering. โš ๏ธ


๐ŸŽ€ split

samtools split [options] merged.sam|merged.bam|merged.cram

Splits a file by read group, producing one or more output files matching a common prefix (by default based on the input filename) each containing one read-group. Divide and conquer, read-group edition. ๐ŸŽ€


๐Ÿฆ‹ cat

samtools cat [-b list] [-h header.sam] [-o out.bam] in1.bam in2.bam [ ... ]

Concatenate BAMs or CRAMs. Although this works on either BAM or CRAM, all input files must be the same format as each other. The sequence dictionary of each input file must be identical, although this command does not check this. This command uses a similar trick to reheader which enables fast BAM concatenation. Fast BAM concatenation is the vibe. โšก


๐Ÿ’œ import

samtools import [options] in.fastq [ ... ]

Converts one or more FASTQ files to unaligned SAM, BAM or CRAM. These formats offer a richer capability of tracking sample meta-data via the SAM header and per-read meta-data via the auxiliary tags. The fastq command may be used to reverse this conversion. FASTQ to unaligned alignment format โ€” meta-data glow-up. โœจ


๐ŸŒธ fastq/a

samtools fastq [options] in.bam
samtools fasta [options] in.bam

Converts a BAM or CRAM into either FASTQ or FASTA format depending on the command invoked. The files will be automatically compressed if the file names have a .gz, .bgz, or .bgzf extension. Auto-compression? We love convenience. ๐ŸŽ€

The input to this program must be collated by name. Use samtools collate or samtools sort -n to ensure this. Bestie, if it's not collated by name, fix that first. No cap. ๐Ÿ’€


๐Ÿงš faidx

samtools faidx <ref.fasta> [region1 [...]]

Index reference sequence in the FASTA format or extract subsequence from indexed reference sequence. If no region is specified, faidx will index the file and create <ref.fasta>.fai on the disk. If regions are specified, the subsequences will be retrieved and printed to stdout in the FASTA format. Index it or extract it โ€” either way, it's iconic. ๐Ÿ’…

The input file can be compressed in the BGZF format. ๐ŸŒˆ

FASTQ files can be read and indexed by this command. Without using --fastq any extracted subsequence will be in FASTA format. ๐ŸŽ€


๐Ÿ“ fqidx

samtools fqidx <ref.fastq> [region1 [...]]

Index reference sequence in the FASTQ format or extract subsequence from indexed reference sequence. If no region is specified, fqidx will index the file and create <ref.fastq>.fai on the disk. If regions are specified, the subsequences will be retrieved and printed to stdout in the FASTQ format. FASTQ indexing, but make it specific. โœจ

The input file can be compressed in the BGZF format. ๐ŸŒธ

โš ๏ธ samtools fqidx should only be used on fastq files with a small number of entries. Trying to use it on a file containing millions of short sequencing reads will produce an index that is almost as big as the original file, and searches using the index will be very slow and use a lot of memory. This is not a drill โ€” small fastq files only, bestie. ๐Ÿ˜ญ

๐Ÿ‘‘ dict

samtools dict ref.fasta|ref.fasta.gz

Create a sequence dictionary file from a fasta file. Short, sweet, dictionary-core. ๐Ÿ“š


๐Ÿ’… calmd

samtools calmd [-Eeubr] [-C capQcoef] aln.bam ref.fasta

Generate the MD tag. If the MD tag is already present, this command will give a warning if the MD tag generated is different from the existing tag. Output SAM by default. MD tag check โ€” and yes, it will warn you if something's off. โš ๏ธ

Calmd can also read and write CRAM files although in most cases it is pointless as CRAM recalculates MD and NM tags on the fly. The one exception to this case is where both input and output CRAM files have been / are being created with the no_ref option. CRAM usually handles it itself โ€” no_ref is the exception. ๐Ÿงฌ


๐Ÿฆ‹ fixmate

samtools fixmate [-rpcm] [-O format] in.nameSrt.bam out.bam

Fill in mate coordinates, ISIZE and mate related flags from a name-sorted alignment. Mate info goes in, chaos goes out. ๐Ÿ’…


๐Ÿ”ฅ markdup

samtools markdup [-l length] [-r] [-s] [-T] [-S] in.algsort.bam out.bam

Mark duplicate alignments from a coordinate sorted file that has been run through samtools fixmate with the -m option. This program relies on the MC and ms tags that fixmate provides. Coordinate sorted + fixmate -m first โ€” markdup is not doing guesswork for you. โš ๏ธ


๐Ÿ’€ rmdup

samtools rmdup [-sS] <input.srt.bam> <out.bam>

This command is obsolete. Use markdup instead. Obsolete era โ€” we don't gatekeep, but we do use markdup now. ๐Ÿ’…


๐ŸŽ€ addreplacerg

samtools addreplacerg [-r rg-line | -R rg-ID] [-m mode] [-l level] [-o out.bam] in.bam

Adds or replaces read group tags in a file. Read group tags: added, replaced, handled. ๐Ÿซถ


๐ŸŒŸ reheader

samtools reheader [-iP] in.header.sam in.bam

Replace the header in in.bam with the header in in.header.sam. This command is much faster than replacing the header with a BAMโ†’SAMโ†’BAM conversion. Faster than the whole conversion pipeline โ€” we love efficiency. โšก

By default this command outputs the BAM or CRAM file to standard output (stdout), but for CRAM format files it has the option to perform an in-place edit, both reading and writing to the same file. No validity checking is performed on the header, nor that it is suitable to use with the sequence data itself. It does not validate the header or check that it fits the sequence data โ€” that's on you, bestie. ๐Ÿ˜ญ


๐ŸŒธ targetcut

samtools targetcut [-Q minBaseQ] [-i inPenalty] [-0 em0] [-1 em1] [-2 em2] [-f ref] in.bam

This command identifies target regions by examining the continuity of read depth, computes haploid consensus sequences of targets and outputs a SAM with each sequence corresponding to a target. When option -f is in use, BAQ will be applied. This command is only designed for cutting fosmid clones from fosmid pool sequencing [Ref. Kitzman et al. (2010)]. Very specific fosmid-clone mission โ€” not a general-purpose icon. ๐Ÿงš


๐Ÿ’œ phase

samtools phase [-AF] [-k len] [-b prefix] [-q minLOD] [-Q minBaseQ] in.bam

Call and phase heterozygous SNPs. ๐Ÿ’…


๐Ÿงฌ depad

samtools depad [-SsCu1] [-T ref.fa] [-o output] in.bam

Okay so picture this: your BAM was aligned against a padded reference (you know, the ones with literal * gap characters baked in), and you want it aligned against the depadded one instead. That's the whole gig. โœจ

Here's the tea though โ€” the padded reference can contain verbatim * bases, and those * bases also count in the reference numbering. Which means a sequence base-call that aligned against a reference * gets treated as a cigar match (M or X) operator, but only if the base-call is A, C, G or T. Then after depadding, those reference * bases get deleted, and those aligned sequence base-calls become insertions. Same kind of transformation applies to deletions and padding cigar operations. ๐ŸŽ€


โœ‚๏ธ ampliconclip

samtools ampliconclip [-o out.file] [-f stat.file] [--soft-clip] [--hard-clip] [--both-ends] [--strand] [--clipped] [--fail] [--no-PG] -b bed.file in.file

Clips reads in a SAM-compatible file, based on data from a BED file. That's it, that's the vibe. ๐Ÿฆ‹


๐Ÿงช samples

samtools samples [-o out.file] [-i] [-T TAG] [-f refs.fasta] [-F refs_list] [-X]

Prints the samples out of alignment files. Iconic. ๐Ÿ‘‘


๐Ÿ”„ reset

samtools reset [-o FILE] [-x/--remove-tag tag_list] [--keep-tag tag_list] [--reject-PG pgid] [--no-RG] [--no-PG] [...]

This one strips the alignment info off of records, giving you back an unaligned SAM, BAM or CRAM file. Flags get reset, header tags get updated or removed as appropriate, and aux tags get removed or retained however you specified. ๐Ÿซถ

Heads up bestie: the sort order is unchanged. It stays exactly as it was. No cap.

โœจ SAMTOOLS OPTIONS โœจ

These are the options you pass after samtools but before any sub-command gets named. Little pre-game options, if you will. ๐Ÿ’…

  • help, --help โ€” Shows a brief usage message listing all the samtools commands you've got available. And if you also give it a command name โ€” like samtools help view โ€” it'll show you the detailed usage message for that specific command instead. ๐ŸŽ€
  • --version โ€” Displays the version numbers and copyright info for samtools plus all the important libraries it uses. Main character energy for real.
  • --version-only โ€” Displays the full samtools version number in a machine-readable format. Lowkey the most useful one for scripting ngl. ๐Ÿค–

๐ŸŒ GLOBAL COMMAND OPTIONS ๐ŸŒ

So a bunch of long-options are shared between multiple samtools sub-commands: --input-fmt, --input-fmt-option, --output-fmt, --output-fmt-option, --reference, --write-index and --verbosity. ๐Ÿ’–

The input format gets auto-detected, so specifying the format is unnecessary โ€” which is why this option is rarely offered. And just so you know: not all subcommands have all options. Consult the subcommand help for the details, iykyk. ๐Ÿ”

The format strings it recognises are "sam", "sam.gz", "bam" and "cram". You can follow those with a comma-separated list of options, written as either key or key=value. Examples are down below. โญ

The fmt-option arguments accept either a single option, or option=value. And note: some options only work on some file formats, and only on read or write streams โ€” so don't come for me if yours doesn't do the thing. If the value is unspecified for a boolean option, the value is assumed to be 1. The valid options are as follows, bestie: ๐Ÿ‘‡

๐ŸŽš๏ธ level=INT

Output only. Specifies the compression level, from 1 to 9, or 0 for uncompressed. Oh and if the output format is SAM, this also enables BGZF compression โ€” otherwise SAM defaults to uncompressed. ๐Ÿ—œ๏ธ

๐Ÿงต nthreads=INT

Specifies the number of threads to use while encoding and/or decoding. For BAM it'll be encoding only. In CRAM the threads are dynamically shared between the encoder and the decoder. Parallel slay. โšก

๐Ÿงน filter=STRING

Applies the filter STRING to all incoming records, rejecting any that don't satisfy the expression. See the FILTER EXPRESSIONS section below for the specifics. ๐Ÿ•ต๏ธ

๐Ÿงฌ reference=fasta_file

Specifies a FASTA reference file to use in CRAM encoding or decoding. It's usually not required for decoding, except in the situation where the MD5 can't be obtained via the REF_PATH or REF_CACHE environment variables. ๐ŸŒธ

๐Ÿ”Ž decode_md=0|1

CRAM input only; defaults to 1 (on). CRAM doesn't typically store MD and NM tags โ€” it prefers to generate them on the fly. When this option is 0, missing MD, NM tags will not be generated. It can be particularly useful when combined with a file encoded using store_md=1 and store_nm=1. ๐Ÿ’ซ

๐Ÿ’พ store_md=0|1

CRAM output only; defaults to 0 (off). CRAM normally only stores MD tags when the reference is unknown, and lets the decoder generate these values on-the-fly (see decode_md). ๐Ÿ“

๐Ÿ’พ store_nm=0|1

CRAM output only; defaults to 0 (off). CRAM normally only stores NM tags when the reference is unknown, and lets the decoder generate these values on-the-fly (see decode_md). ๐Ÿ“

๐Ÿ™ˆ ignore_md5=0|1

CRAM input only; defaults to 0 (off). When enabled, md5 checksum errors on the reference sequence and block checksum errors within CRAM are ignored.

Bestie. Use of this option is strongly discouraged. Like, strongly. I'm serious. ๐Ÿ˜ญ

๐Ÿ“‹ required_fields=bit-field

CRAM input only. Specifies which SAM columns need to be populated. By default all fields are used, and limiting the decode to specific columns can give you significant performance gains. ๐Ÿ”ฅ

The bit-field is a numerical value constructed from this table:

  • 0x1 โ€” SAM_QNAME
  • 0x2 โ€” SAM_FLAG
  • 0x4 โ€” SAM_RNAME
  • 0x8 โ€” SAM_POS
  • 0x10 โ€” SAM_MAPQ
  • 0x20 โ€” SAM_CIGAR
  • 0x40 โ€” SAM_RNEXT
  • 0x80 โ€” SAM_PNEXT
  • 0x100 โ€” SAM_TLEN
  • 0x200 โ€” SAM_SEQ
  • 0x400 โ€” SAM_QUAL
  • 0x800 โ€” SAM_AUX
  • 0x1000 โ€” SAM_RGAUX

๐Ÿท๏ธ name_prefix=string

CRAM input only; defaults to the output filename. Any sequences with auto-generated read names will use string as the name prefix. โœจ

๐Ÿงบ multi_seq_per_slice=0|1

CRAM output only; defaults to 0 (off). By default CRAM generates one container per reference sequence โ€” except in the case of many small references (like a fragmented assembly). ๐Ÿงš

๐Ÿ“ฆ version=major.minor

CRAM output only. Specifies the CRAM version number. The acceptable values are "2.1", "3.0" and "3.1". ๐ŸŽ€

๐Ÿ”ข seqs_per_slice=INT

CRAM output only; defaults to 10000.

๐Ÿ—‚๏ธ slices_per_container=INT

CRAM output only; defaults to 1. The effect of having multiple slices per container is that the compression header block gets shared between multiple slices. This is unlikely to have any significant impact unless the number of sequences per slice is reduced. (Together, these two options control the granularity of random access.) ๐ŸŽฏ

๐Ÿงท embed_ref=0|1

CRAM output only; defaults to 0 (off). If 1, this stores portions of the reference sequence in each slice, permitting decode without having to require an external copy of the reference sequence. ๐Ÿ’œ

๐Ÿšซ no_ref=0|1

CRAM output only; defaults to 0 (off). If 1, sequences will be stored verbatim with no reference encoding. Can be useful if no reference is available for the file. ๐Ÿ™Œ

๐Ÿ—œ๏ธ use_bzip2=0|1

CRAM output only; defaults to 0 (off). Permits use of bzip2 in CRAM block compression.

๐Ÿ—œ๏ธ use_lzma=0|1

CRAM output only; defaults to 0 (off). Permits use of lzma in CRAM block compression.

โž— use_arith=0|1

CRAM โ‰ฅ 3.1 output only; enables use of arithmetic entropy coding in CRAM block compression. This is off by default, but enabled for archive mode. It's significantly slower but sometimes smaller than the standard rANS entropy encoder. ๐ŸŒ

๐ŸŽต use_fqz=0|1

CRAM โ‰ฅ 3.1 output only; enables and disables the fqzcomp quality compression method. This is on by default for version 3.1 and above, but only when the small and archive profiles are in use. ๐ŸŽถ

๐Ÿ”ค use_tok=0|1

CRAM โ‰ฅ 3.1 output only; enables and disables the name tokeniser compression method. This is on by default for version 3.1 and above. ๐Ÿ”ก

๐Ÿซฅ lossy_names=0|1

CRAM output only; defaults to 0 (off). If 1, templates with all members within the same CRAM slice will have their read names removed. New names get automatically generated during decoding. Also see the name_prefix option. ๐Ÿ’…

๐ŸŽ›๏ธ fast, normal, small, archive

CRAM output only. Sets the CRAM compression profile โ€” it's a simplified way of setting many output options at once. It changes the following options depending on which profile is in use. The normal profile is the default. ๐ŸŒˆ

  • fast โ€” level 1, use_bzip2 off, use_lzma off, use_tok(*) off, use_fqz(*) off, use_arith(*) off, seqs_per_slice 10000
  • normal โ€” level 5, use_bzip2 off, use_lzma off, use_tok(*) on, use_fqz(*) off, use_arith(*) off, seqs_per_slice 10000
  • small โ€” level 6, use_bzip2 on, use_lzma off, use_tok(*) on, use_fqz(*) on, use_arith(*) off, seqs_per_slice 25000
  • archive โ€” level 7, use_bzip2 on, use_lzma on if level>7, use_tok(*) on, use_fqz(*) on, use_arith(*) on, seqs_per_slice 100000
(*) use_tok, use_fqz and use_arith are only enabled for CRAM version 3.1 and above. โญ

The level listed is only the default value, and it won't be set if it's already been explicitly changed. Additionally, bases_per_slice is set to 500*seqs_per_slice unless it was previously explicitly set. ๐ŸŽ€

๐Ÿ“– fastq_name2

FASTQ input only. Says that the names are not the first word in the header, but the second. This is a FASTQ variant commonly used in the SRA and ENA archives. ๐Ÿ—ƒ๏ธ

๐Ÿงฌ fastq_casava

FASTQ input and output only. The Illumina CASAVA identifiers are stored in the second word of the FASTQ header lines and they store read meta-data. The CASAVA tag defines the data held in the READ1, READ2 and QCFAIL flags and the barcode auxiliary tag ("BC" by default). This option may be used to both read and write CASAVA identifiers. ๐Ÿ’ซ

๐Ÿท๏ธ fastq_barcode=TAG

FASTQ input and output only. When the fastq_casava option is used, this controls the name of the barcode aux tag to be used. TAG defaults to "BC" if not specified. ๐Ÿ“

๐Ÿ”– fastq_aux=LIST

FASTQ input and output only. Processes SAM format auxiliary tags that follow the other fields on the record identifier lines. If no =LIST is specified, or LIST is "1", then all aux tags listed are copied to/from the SAM record. Otherwise it's a comma-separated list of 2-letter tag types, and it's used to control which tags get processed โ€” any others being omitted. ๐ŸŽฏ

Real talk: because commas are used to separate options in the --output-fmt string (which details file format and options combined together), you'll need to use the --output-fmt-option option if you want to specify a comma-separated list of tag types. Not me warning you twice. ๐Ÿ˜ญ
  • fastq_rnum โ€” FASTQ output only, bestie. If you set this, paired reads get /1 and /2 glued onto their read names. It does nothing to unpaired reads. And when you're reading FASTQ, those suffixes get automatically detected and processed no matter what fastq_rnum says. ๐Ÿ’…
  • fastq_umi=TAGLIST โ€” FASTQ input and output only. ๐ŸŽ€ When reading from a FASTQ file, this tells it to pull the UMI tag out of the read name and drop it into the tag you name (which defaults to RX if you don't give a tag name at all). The UMI is assumed to be the 8th colon-separated element, matching Illumina BCL-to-FASTQ conversion specs. But hey โ€” peep the fastq_umi_regexp option if you wanna change that up. When converting from SAM to FASTQ, TAGLIST is a comma separated list of tags that get checked in turn for their presence. The string from the first tag found gets appended to the end of the read-name. No regexp available in this case, sorry โ€” the data is always appended to the end of the name, or, if a hash-number is present (like name#49), to just before the hash character. TAGLIST defaults to OX,RX.
  • fastq_umi_regex=REGEX โ€” FASTQ input only. Specifies the regular expression used for finding UMI strings in a read name. Any text inside the single bracketed element gets used as the UMI string. Text matched by that string is removed from the read name, and everything to the right of it shifts leftwards. โœจ This defaults to ^[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:([^:#/]+).

For example:

samtools view --input-fmt-option decode_md=0
    --output-fmt cram,version=3.0 --output-fmt-option embed_ref
    --output-fmt-option seqs_per_slice=2000 -o foo.cram foo.bam

samtools view -O cram,small -o bar.cram bar.bam

The --write-index option enables automatic index creation while writing out BAM, CRAM or bgzf SAM files. ๐Ÿซถ Quick heads up though: to get compressed SAM as the output format you gotta manually request a compression level โ€” otherwise all SAM files are uncompressed. By default SAM and BAM use CSI indices while CRAM uses CRAI indices. And if you need BAI indices, note that you can specify the name of the index being written to (and therefore the format) by using the filename##idx##indexname notation. iykyk ๐Ÿ’–

For example, to convert a BAM to a compressed SAM with CSI indexing:

samtools view -h -O sam,level=6 --write-index in.bam -o out.sam.gz

To convert a SAM to a compressed BAM using BAI indexing:

samtools view --write-index in.sam -o out.bam##idx##out.bam.bai

The --verbosity INT option sets the verbosity level for samtools and HTSlib. Default is 3 (HTS_LOG_WARNING); 2 reduces warning messages, and 0 or 1 also reduce some error messages, while values greater than 3 produce increasing numbers of additional warnings and logging messages. ๐Ÿ“ข


๐ŸŒˆ FILTER EXPRESSIONS ๐ŸŒˆ

Filter expressions are the on-the-fly vibe check for incoming SAM, BAM or CRAM records โ€” anything that doesn't match the expression you specified gets yeeted. ๐Ÿ’€

The language is primarily C style, but with a few differences in the precedence rules for bit operators, plus regular expression matching is in the mix.

The operator precedence, from strongest binding to weakest, is:

  • Grouping โ€” (, ) โ€” E.g. "(1+2)*3"
  • Values โ€” literals, vars โ€” numbers, strings and variables
  • Unary ops โ€” +, -, !, ~ โ€” E.g. -10 +10, !10 (not), ~5 (bit not)
  • Math ops โ€” *, /, % โ€” multiply, division and (integer) modulo
  • Math ops โ€” +, - โ€” addition / subtraction
  • Bit-wise โ€” & โ€” integer AND
  • Bit-wise โ€” ^ โ€” integer XOR
  • Bit-wise โ€” | โ€” integer OR
  • Conditionals โ€” >, >=, <, <=
  • Equality โ€” ==, !=, =~, !~ โ€” =~ and !~ match regular expressions
  • Boolean โ€” &&, || โ€” logical AND / OR

Expressions are computed using floating point mathematics, so "10 / 4" evaluates to 2.5 rather than 2. ๐Ÿงฎ They may be written as integers in decimal or "0x" plus hexadecimal, and floating point with or without exponents. However, operations that require integers first do an implicit type conversion, so "7.9 % 5" is 2 and "7.9 & 4.1" is equivalent to "7 & 4", which is 4. Strings are always specified using double quotes. To get a double quote in a string, use backslash. Similarly a double backslash is used to get a literal backslash. For example ab\"c\\d is the string ab"c\d.

Comparison operators are evaluated as a match being 1 and a mismatch being 0, thus "(2 > 1) + (3 < 5)" evaluates as 2. All comparisons involving undefined (null) values are deemed to be false.

The variables are where the file format specifics get accessed from inside the expression. ๐Ÿ” The variables correspond to SAM fields โ€” for example, to find paired alignments with high mapping quality and a very large insert size, we may use the expression "mapq >= 30 && (tlen >= 100000 || tlen <= -100000)". Valid variable names and their data types are:

  • endpos โ€” int โ€” alignment end position (1-based)
  • flag โ€” int โ€” combined FLAG field
  • flag.paired โ€” int โ€” single bit, 0 or 1
  • flag.proper_pair โ€” int โ€” single bit, 0 or 2
  • flag.unmap โ€” int โ€” single bit, 0 or 4
  • flag.munmap โ€” int โ€” single bit, 0 or 8
  • flag.reverse โ€” int โ€” single bit, 0 or 16
  • flag.mreverse โ€” int โ€” single bit, 0 or 32
  • flag.read1 โ€” int โ€” single bit, 0 or 64
  • flag.read2 โ€” int โ€” single bit, 0 or 128
  • flag.secondary โ€” int โ€” single bit, 0 or 256
  • flag.qcfail โ€” int โ€” single bit, 0 or 512
  • flag.dup โ€” int โ€” single bit, 0 or 1024
  • flag.supplementary โ€” int โ€” single bit, 0 or 2048
  • hclen โ€” int โ€” number of hard-clipped bases
  • library โ€” string โ€” library (LB header via RG)
  • mapq โ€” int โ€” mapping quality
  • mpos โ€” int โ€” synonym for pnext
  • mrefid โ€” int โ€” mate reference number (0 based)
  • mrname โ€” string โ€” synonym for rnext
  • ncigar โ€” int โ€” number of cigar operations
  • pnext โ€” int โ€” mate's alignment position (1-based)
  • pos โ€” int โ€” alignment position (1-based)
  • qlen โ€” int โ€” alignment length: no. query bases
  • qname โ€” string โ€” query name
  • qual โ€” string โ€” quality values (raw, 0 based)
  • refid โ€” int โ€” integer reference number (0 based)
  • rlen โ€” int โ€” alignment length: no. reference bases
  • rname โ€” string โ€” reference name
  • rnext โ€” string โ€” mate's reference name
  • sclen โ€” int โ€” number of soft-clipped bases
  • seq โ€” string โ€” sequence
  • tlen โ€” int โ€” template length (insert size)
  • [XX] โ€” int / string โ€” XX tag value

Flags are returned either as the whole flag value or by checking for a single bit. Hence the filter expression flag.dup is equivalent to flag & 1024. ๐Ÿ‘‘

"qlen" and "rlen" are measured using the CIGAR string to count the number of query (sequence) and reference bases consumed. Note that "qlen" may not exactly match the length of the "seq" field if the sequence is "*".

"sclen" and "hclen" are the number of soft and hard-clipped bases respectively. The formula "qlen-sclen" gives the number of sequence bases used in the alignment, distinguishing between global alignment and local alignment length. ๐Ÿฆ‹

"endpos" is the (1-based inclusive) position of the rightmost mapped base of the read, as measured using the CIGAR string, and for mapped reads is equivalent to "pos+rlen-1". For unmapped reads, it's the same as "pos".

Reference names may be matched either by their string forms ("rname" and "mrname") or as the Nth @SQ line (counting from zero) as stored in BAM using "tid" and "mtid" respectively.

Auxiliary tags are described in square brackets, and these expand to either integer or string as defined by the tag itself (XX:Z:string or XX:i:int). For example [NM]>=10 can be used to look for alignments with many mismatches, and [RG]=~"grp[ABC]-" will match the read-group string. ๐ŸŽฏ

If no comparison is used with an auxiliary tag, it's taken simply to be a test for the existence of that tag. So [NM] will return any record containing an NM tag, even if that tag is zero (NM:i:0). In htslib <= 1.15, negating this with ![NM] gave misleading results, because it was true if the tag did not exist or did exist but was zero. Now this is strictly does-not-exist. An explicit exists([NM]) and !exists([NM]) function has also been added to make this intention clear.

Similarly in htslib <= 1.15, using [NM]!=0 was true both when the tag existed and was not zero as well as when the tag did not exist. From 1.16 onwards, all comparison operators are only true for tags that exist, so [NM]!=0 works as expected. ๐Ÿ™Œ

Some simple functions are available to operate on strings. These treat the strings as arrays of bytes, permitting their length, minimum, maximum and average values to be computed. These are useful for processing Quality Scores. โญ

  • length(x) โ€” length of the string (excluding nul char)
  • min(x) โ€” minimum byte value in the string
  • max(x) โ€” maximum byte value in the string
  • avg(x) โ€” average byte value in the string

Note that "avg" is a floating point value and it may be NAN for empty strings. This means that "avg(qual)" does not produce an error for records that have both seq and qual of "*". NAN values will fail any conditional checks, so e.g. "avg(qual) > 20" works and will not report these records. NAN also fails all equality, < and > comparisons, and returns zero when given as an argument to the exists function. It can be negated with !x in which case it becomes true. ๐Ÿ’œ

Functions that operate on both strings and numerics:

  • exists(x) โ€” true if the value exists (or is explicitly true).
  • default(x,d) โ€” value x if it exists or d if not.

Functions that apply only to numeric values:

  • sqrt(x) โ€” square root of x
  • log(x) โ€” natural logarithm of x
  • pow(x, y) โ€” power function, x to the power of y
  • exp(x) โ€” base-e exponential, equivalent to pow(e,x)

๐ŸŒธ ENVIRONMENT VARIABLES ๐ŸŒธ

Ok bestie listen up, these are the env vars that control where samtools goes looking for stuff ๐Ÿ’…

  • HTS_PATH โ€” a colon-separated list of directories where it should search for HTSlib plugins. And here's the โœจfunโœจ part: if $HTS_PATH starts or ends with a colon, or has a double colon in it (::), then the built-in list of directories gets searched at that point in the search. Cute, right? ๐ŸŽ€

And if there's no HTS_PATH defined at all, it just uses the built-in list of directories that were specified when HTSlib got built โ€” which typically includes /usr/local/libexec/htslib and similar directories. ๐Ÿ’–

  • REF_PATH โ€” a colon separated list (semi-colon on Windows ๐ŸชŸ) of locations to look for sequences identified by their MD5sums. Each location can be a directory or a URL. Heads up tho: if a URL is in there, then the colon in http:// and ftp:// and any optional port number is treated as part of the URL and not as a PATH field separator. Alternatively you can use a double colon to mean a single colon character. no cap ๐Ÿซถ

If REF_PATH includes %nums then it gets replaced with the next num elements of the md5sum. And an implicit /%s is also added to each path element if any md5sum digits are unused. So like, for example "REF_PATH=/some/dir/%4s/%s" or "REF_PATH=/some/dir/%4s" will search a directory structure with the first 4 characters of the md5sum as a subdirectory and the remaining 28 as the filename within that directory. slay ๐Ÿฆ‹

๐Ÿ’€ ok important lore: version 1.21 and earlier defaulted to using the EBI's CRAM reference server if no REF_PATH was specified. That default has been removed to reduce load on the EBI's service. It's recommended that a site-wide proxy is set up so downloaded references get shared better โ€” for example the ref-cache server provided with HTSlib. The original behaviour can be restored by including http://www.ebi.ac.uk/ena/cram/md5/%s in your REF_PATH. And if you do that, it is strongly encouraged you also specify a local REF_CACHE directory. periodt.

See <https://www.htslib.org/doc/reference_seqs.html> and REFERENCE SEQUENCES below for more info. ๐Ÿ“š

  • REF_CACHE โ€” set this to a single location that houses a local cache of references. When REF_CACHE is set, any non-local reference will create a file in the local REF_CACHE named after the sequence md5sum. This cache gets searched prior to REF_PATH. And if you want to search REF_CACHE but not keep populating it, just add the directory to the start of REF_PATH instead. ๐Ÿง 

Same as REF_PATH, the percent notation (e.g. "dir/%2s/%2s/%s") may be used to avoid too many files within a single directory.

To pre-populate the REF_CACHE there's a script misc/seq_cache_populate.pl provided in the Samtools distribution. It takes a fasta file or a directory of fasta files and generates the MD5sum named files. ๐Ÿ”ฅ

For example, if you use seq_cache_populate -subdirs 2 -root /local/ref_cache to create 2 nested subdirectories (the default), each consuming 2 characters of the MD5sum, then REF_CACHE must be set to /local/ref_cache/%2s/%2s/%s. iykyk ๐Ÿ’…


๐Ÿงš REFERENCE SEQUENCES ๐Ÿงš

The CRAM format requires use of a reference sequence for both reading and writing. Like, non-negotiable. ๐ŸŒˆ

When reading a CRAM, the @SQ headers are interrogated to identify the reference sequence MD5sum (M5: tag) and the local reference sequence filename (UR: tag). Note that non-local URIs in the UR tag are not used, but file:// is supported. This is a change in behaviour, but not documentation, to htslib 1.21. ๐Ÿ™ˆ

To create a CRAM the @SQ headers will also be read to identify the reference sequences, but M5: and UR: tags may not be present. In that case the -T and -t options of samtools view may be used to specify the fasta or fasta.fai filenames respectively (provided the .fasta.fai file is also backed up by a .fasta file). ๐Ÿ’–

The search order to obtain a reference is:

  1. Use any local file specified by the command line options (eg -T).
  2. Look for MD5 via the REF_CACHE environment variable.
  3. Look for MD5 in each element of the REF_PATH environment variable.
  4. Look for a local file listed in the UR: header tag.

Obsessed with how orderly that is tbh ๐Ÿ‘‘


โœจ EXAMPLES โœจ

  • Import SAM to BAM when @SQ lines are present in the header:
samtools view -b aln.sam > aln.bam

If @SQ lines are absent:

samtools faidx ref.fa
samtools view -bt ref.fa.fai aln.sam > aln.bam

where ref.fa.fai is generated automatically by the faidx command. ๐ŸŽ€

  • Convert a BAM file to a CRAM file using a local reference sequence:
samtools view -C -T ref.fa aln.bam > aln.cram

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Heng Li from the Sanger Institute wrote the original C version of samtools. Bob Handsaker from the Broad Institute implemented the BGZF library. Petr Danecek and Heng Li wrote the VCF/BCF implementation. James Bonfield from the Sanger Institute developed the CRAM implementation. Other large code contributions have been made by John Marshall, Rob Davies, Martin Pollard, Andrew Whitwham, Valeriu Ohan, Vasudeva Sarma (all while primarily at the Sanger Institute), with numerous other smaller but valuable contributions. See the per-command manual pages for further authorship. ๐Ÿซถ legends, every single one ๐Ÿ’œ


๐Ÿ’ซ SEE ALSO ๐Ÿ’ซ

samtools-addreplacerg(1), samtools-ampliconclip(1), samtools-ampliconstats(1), samtools-bedcov(1), samtools-calmd(1), samtools-cat(1), samtools-checksum(1), samtools-collate(1), samtools-consensus(1), samtools-coverage(1), samtools-cram-size(1), samtools-depad(1), samtools-depth(1), samtools-dict(1), samtools-faidx(1), samtools-fasta(1), samtools-fastq(1), samtools-fixmate(1), samtools-flags(1), samtools-flagstat(1), samtools-fqidx(1), samtools-head(1), samtools-idxstats(1), samtools-import(1), samtools-index(1), samtools-markdup(1), samtools-merge(1), samtools-mpileup(1), samtools-phase(1), samtools-quickcheck(1), samtools-reference(1), samtools-reheader(1), samtools-reset(1), samtools-rmdup(1), samtools-sort(1), samtools-split(1), samtools-stats(1), samtools-targetcut(1), samtools-tview(1), samtools-view(1), bcftools(1), sam(5), tabix(1) ref-cache(1)

Samtools website: <http://www.htslib.org/> ๐ŸŒ

File format specification of SAM/BAM,CRAM,VCF/BCF: <http://samtools.github.io/hts-specs> ๐Ÿ“„

Samtools latest source: <https://github.com/samtools/samtools> โญ

HTSlib latest source: <https://github.com/samtools/htslib> โญ

Bcftools website: <http://samtools.github.io/bcftools> ๐ŸŒธ


and that's the whole page bestie!! ๐ŸŽ‰ this edition is samtools-1.24, dated 9 July 2026, and it's the samtools(1) manual โ€” go forth and align things, you've got this ๐Ÿ’–๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from