Use when working with SAM, BAM, or CRAM alignment files to sort, index, view, convert, or compute statistics.
samtools/home/vimalinx/miniforge3/envs/bio/bin/samtoolsreferences/help.md for full command documentation and optionssamtools is a dispatcher, not a single operation.# 1) Convert SAM to BAM
samtools view -b -o sample.bam sample.sam
# 2) Sort and index a BAM
samtools sort -@ 8 -o sample.sorted.bam sample.bam
samtools index sample.sorted.bam
# 3) Inspect basic mapping statistics
samtools flagstat sample.sorted.bam
samtools stats sample.sorted.bam > sample.stats.txt
# 4) Extract one region
samtools view sample.sorted.bam chr1:100000-110000
flagstat, stats, coverage, or depth to sanity-check the alignment.fastq, fasta, faidx, or dict only when the workflow specifically needs them.samtools quickcheck is a cheap integrity test before burning compute on a broken BAM/CRAM.-@ for thread-aware subcommands, but do not assume every subcommand parallelizes the same way.