samtools-calmd(1)

πŸ’… samtools-calmd(1) β€” the samtools calmd page, bestie edition πŸŽ€

okay so you're looking at the manual for samtools calmd, which literally just calculates MD and NM tags. that's the whole gig. iconic, honestly.


✨ NAME ✨

samtools calmd β€” calculates MD and NM tags 🧬


🌸 SYNOPSIS 🌸

samtools calmd [-Eeubr] [-C capQcoef] aln.bam ref.fasta

that's it, that's the vibe check. two files in, tags out πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so what it does is generate the MD tag. and if the MD tag is already there? it'll give you a lil warning if the MD tag it generated is different from the existing one. no drama, just a heads-up 🫢 Output is SAM by default.

Calmd can also read and write CRAM files, although in most cases it's giving pointless, because CRAM recalculates MD and NM tags on the fly anyway. the one exception to this β€” the single scenario where it's actually doing something β€” is where both input and output CRAM files have been / are being created with the no_ref option. iykyk.

πŸ’€ real talk: some aligners do not include sequence or confidence values in secondary and supplementary alignment records. where this happens in SAM files, you'll see a * character chillin' in the SEQ and QUAL columns. those records get skipped, because there's literally no way to recalculate the MD and NM tags without access to the query sequence. samtools calmd will emit a warning if any records have been skipped for this reason. so if you see that warning, that's why, don't panic πŸ™ˆ

Calmd works best on position-sorted input files, because with these it can stream through the reference sequence and so doesn't have to store much reference data at any one time. ✨ main character streaming energy ✨

For other orderings though? it may have to switch to a caching mode which keeps the reference sequences in memory. and that means calmd uses more memory β€” up to the full size of the reference β€” than it would in the position-sorted case. lowkey expensive 😭

⚠️ also, versions of samtools calmd up to 1.16.1 should only be used on position sorted inputs, as they could be very slow when run on other orderings. like, painfully slow. so if you're on an old version, sort first, bestie.

πŸ’… OPTIONS πŸ’…

  • -A β€” when used jointly with -r, this option overwrites the original base quality. rude but valid.
  • -e β€” convert a the read base to = if it is identical to the aligned reference base. (yes, the original says "a the", we're keeping the lore.) ⚠️ the indel caller does not support the = bases at the moment, so heads up.
  • -u β€” output uncompressed BAM
  • -b β€” output compressed BAM
  • -C INT β€” coefficient to cap mapping quality of poorly mapped reads. see the mpileup command for details. [0] πŸ’«
  • -r β€” compute the BQ tag (without -A) or cap base quality by BAQ (with -A).
  • -E β€” extended BAQ calculation. this option trades specificity for sensitivity, though the effect is minor. tiny slay.
  • --no-PG β€” do not add a @PG line to the header of the output file. 🚫
  • -@, --threads INT β€” number of input/output compression threads to use in addition to main thread [0]. more threads = more go ✨

🌈 EXAMPLES 🌈

  • dump BAQ applied alignment for other SNP callers:
samtools calmd -bAr aln.bam > aln.baq.bam

it adds and corrects the NM and MD tags at the same time. the calmd command also comes with the -C option, the same as the one in mpileup. apply if it helps. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Written by Heng Li from the Sanger Institute. legend behavior, fr fr.


⭐ SEE ALSO ⭐

samtools(1), samtools-mpileup(1)

Samtools website: <http://www.htslib.org/> 🌐


and that's the whole page, bestie!! πŸŽ€πŸ’– go forth and tag your MDs and NMs. this was samtools-1.24, dated 9 July 2026 β€” see you in the next release, mwah πŸ’‹πŸ¦‹

πŸ“¦ where this page comes from