samtools-reference(1) | Bioinformatics tools | samtools-reference(1) |
samtools-reference - extracts an embedded reference from a CRAM file
samtools reference [-q] [-r region] [-o out.fa] in.cram
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.
For the embedded reference mode (-e) this operation is fast, but only works on CRAMs produced using --output-fmt-option embed_ref=1. Note 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 as the CRAM slice headers store the MD5sum of the portion of reference than 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.
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.
Written by James Bonfield from the Sanger Institute.
Samtools website: <http://www.htslib.org/>
2 September 2022 | samtools-1.16.1 |