Mathematical Notes on SAMtools Algorithms