A sequential coalescent algorithm for chromosomal inversions