Each read comes from one of the two haplotypes of a diploid sample and shows the reference (R) or alternate (A) allele at the heterozygous SNPs it covers. The page phases the SNPs by minimising the number of read bases that disagree with the two haplotypes. It does this by alternating between choosing the best phase for every read given the SNP phases, and the best phase for every SNP given the read phases. Random restarts help it escape local optima. Keys: → step, ← back, f run all, r reset, s random reset (new initial SNP phases).
δi ∈ {1, −1} is the phase of SNP i: 1 if haplotype 1 carries the reference allele, −1 if it carries the alternate. σk ∈ {1, −1} is the phase of read k: 1 if it comes from haplotype 1, −1 from haplotype 2. Coding R as 1 and A as −1, read k should show δiσk at SNP i, and each disagreement is an error: qki(δiσk) = 0 if the read base bki = δiσk, and 1 otherwise.
MEC: find δ and σ that minimise Σk Σi∈Ik qki(δiσk), where Ik is the set of SNPs on read k. The problem is NP-hard, but the read phases are easy given the SNP phases, and vice versa: