samtools

Convert, sort, and summarize SAM/BAM files, calculate depth, and create BAM/FASTA indexes.

API/CLI tool ID: samtools

The input fields depend on the value of command.

Understanding inputs and outputs

SAM and BAM record where reads—short nucleotide sequences produced by a sequencer—align on a reference sequence. SAM is text; BAM is a compressed binary format. samtools sort rearranges these records by coordinate. It does not find new alignments as BWA or Bowtie2 does.

CommandPurpose and required inputPrimary output file
viewConverts SAM/BAM to BAM. Selecting a region requires coordinate-sorted BAM.output.bam
sortSorts SAM/BAM records by reference coordinate.output.bam
indexBuilds an index for fast region access in coordinate-sorted BAM.output.bam.bai
faidxIndexes FASTA. If region is specified, extracts that sequence interval.reference.fa.fai / region.fa
flagstatSummarizes SAM/BAM read records by their status flags.flagstat.txt
depthCounts reads covering each reference position.depth.tsv

FASTA is a text format containing sequence names and bases. An index helps access the original file efficiently; it does not replace the FASTA or BAM data.

The region chr1:1000-2000 includes positions 1000 through 2000 on reference chr1, including both endpoints. Use reference names and lengths from the input file. Depth counts reads covering a position; a larger value does not mean a higher likelihood of a variant or disease.

For general command behavior, see the official samtools manual. For how depth is counted, see the depth manual.

Input settings

SettingFormatRequiredDefaultDescription and constraints
commandtaskOptional"view"samtools subcommand — Allowed values view · sort · index · faidx · flagstat · depth
inputFilefileRequired—view/sort/flagstat/depth: SAM or BAM; index: coordinate-sorted BAM; faidx: FASTA with uniform line lengths. At most 16 MiB; the original file is not modified — Extensions bam · sam · fa · fasta
regionstringOptional—Region for view/faidx/depth (chr1:1000-2000, 1-based and inclusive). view/depth need a coordinate-sorted BAM. Must name a reference and lie within its length — Applies to view · faidx · depth

Output files

ColumnDisplay nameDescription
output_fileOutput fileResult file name for each command

This field contains an output filename, not a score or confidence value. Open the file to inspect its contents.

Execution availability

Open an execution plan in your project to see available tool versions and costs. Review and approve the inputs, settings, and terms before running.

License

Code, model weights, and accompanying data have their own terms. The table summarizes terms from official sources; check your execution plan for the configuration you will use. License texts are available in Third-party notices.

ComponentLicenseCommercial useSourceNotes
CodeMITAllowed, subject to notice requirementsLicense textLicensed under MIT/Expat. Retain copyright and permission notices when using it.

Checked on 2026-10-21.

References

On this page