Home / Tools / samtools
Samtools is a set of utilities that manipulate alignments in the BAM format. It imports from and exports to the SAM (Sequence Alignment/Map) format, does sorting, merging and indexing, and allows to retrieve reads in any regions swiftly. Samtools is designed to work on a stream. It regards an input file `-' as the standard input (stdin) and an output file `-' as the standard output (stdout). Several commands can thus be combined with Unix pipes. Samtools always output warning and error messages to the standard error output (stderr). Samtools is also able to open a BAM (not SAM) file on a remote FTP or HTTP server if the BAM file name starts with `ftp://' or `http://'. 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.
  • samtools index

    samtools index [-bc] [-m INT] aln.bam|aln.cram [out.index] Index a coordinate-sorted BAM or CRAM file for fast random access. (Note that this does not work with SAM files even if they are bgzip compressed — to index such files, use tabix(1) instead.) This index is needed when region arguments are used to limit samtools view and similar commands to particular regions of interest. If an output fi

  • samtools flagstat

    samtools flagstat in.sam|in.bam|in.cram Does a full pass through the input file to calculate and print statistics to stdout. 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. The first row of output gives th

  • samtools view

    samtools view [options] in.sam|in.bam|in.cram [region...] With no options or regions specified, prints all alignments in the specified input alignment file (in SAM, BAM, or CRAM format) to standard output in SAM format (with no header). You may specify one or more space-separated region specifications after the input filename to restrict output to only those alignments which overlap the specifie

  • samtools 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. The sorted output is written to standard output by default, or to the specified file (out.bam) wh

Tool Uses

No tool instances found


No workflows found

  • HL
    Heng Li

    wrote most of the initial source codes of SAMtools and various converters.

  • BH
    Bob Handsaker

    A major contributor to the SAM/BAM specification. He designed and implemented the BGZF format, the underlying indexable compression format for the BAM format. BGZF does not support arithmetic between file offsets.

  • JR
    Jue Ruan

    Designed and implemented the RAZF format, an alternative indexable compression format. RAZF is no longer used by or provided with SAMtools. Source code remains available in older SAMtools 0.1.x releases and from the standalone branch in the repository.

  • CH
    Colin Hercus

    updated to support gapped alignment by novoalign.

  • PD
    Petr Danecek

    contributed the header parsing library sam_header.c and script.