From SAM Optional Fields Specification the NM field is
Edit distance to the reference, including ambiguous bases but excluding clipping
Assuming both the MD and CIGAR are present, is the edit distance simply the number of characters
[A-Z] appearing in the MD field plus the number of bases inserted (
xI, if any) from the CIGAR string? Are there any other complications?