samtools-reference(1)
β¨ NAME β¨
okay so bestie, this page is samtools-reference(1) β the samtools reference command literally extracts an embedded reference from a CRAM file. itβs giving reference-rescue main character energy π
πΈ SYNOPSIS πΈ
samtools reference [-q] [-r region] [-o out.fa] in.cram
π¦ DESCRIPTION π¦
so hereβs the tea: this creates the reference from aligned data using either the MD:Z auxiliary tags or an embedded reference in a CRAM file. the output is a FASTA file. periodt.
for the embedded reference mode (-e) this operation is fast, but it only works on CRAMs produced using --output-fmt-option embed_ref=1. note that this may not be the complete reference used. each CRAM slice will hold the entire reference that spans the slice coordinates, but gaps in coverage can lead to gaps between slices. however, this reference should be suitable for passing into a CRAM decode (samtools view -T ref.fa). π«Ά
for SAM/BAM files or CRAMs without reference, using the MD:Z tag may also produce an incomplete reference. unlike embedded reference, this reference may not be sufficient for decoding a CRAM file, because the CRAM slice headers store the MD5sum of the portion of reference that spans that slice, but the slice may not have 100% coverage β leading to Ns in the computed reference. however, it should still be possible to decode such CRAMs by ignoring the md5 mismatches using e.g. samtools view --input-fmt-option ignore_md5=1. no cap, thatβs the loophole π
π OPTIONS π
-eβ enable CRAM embedded reference mode. iconic. β¨-qβ enables quiet mode and will produce no output. by default, a line per reference is reporting, describing the percentage with non-N bases. lowkey useful unless you want silence π€«-r regionβ specifies a single region to produce the reference from. if specified, an index file must be present.-o FILEβ write the FASTA records toFILE. by default this is sent to stdout.-@ INTβ the number of BAM/CRAM decompression threads to use in addition to the main thread [0].
note this does not multi-thread the main reference generation steps, so scaling may be capped by 2 or 3 threads, depending on the data. it will also not affect the -e option for CRAM embedded reference, although this is already the fastest method. so yeah, donβt expect infinite thread slay here π
π AUTHOR π
written by James Bonfield from the Sanger Institute.
π SEE ALSO π
samtools(1)- Samtools website:
<http://www.htslib.org/>
made with π and reference-reconstruction vibes β source/version samtools-1.24, dated 9 July 2026. bye bestie, go extract that reference! π«Άπ
π¦ where this page comes from
- epel 10: samtools 1.24-2.el10_3 Β· MIT
- nixpkgs unstable: samtools 1.24
- Copyright (C) 2022 Genome Research Ltd
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms