A computer-implemented method for assigning, to an input sample genotype, one or more labels from a set of labels, wherein each label of the set of labels is an identification of a respective group of genetically similar haplotypes, the method comprising: accessing an input sample genotype; dividing the input sample genotype into a plurality of windows of sequential single nucleotide polymorphisms; building, for each window, a diploid hidden Markov model based on the input sample genotype, wherein each diploid state in the diploid hidden Markov model corresponds to a pair of haploid states from a haploid Markov model for the window; calculating, for each diploid state in each diploid hidden Markov model , a diploid state probability indicating the likelihood that the input sample genotype corresponds to the diploid state; accessing, for each window, a set of annotations, each annotation corresponding to a haploid state from the haploid Markov model for the window and to a label of the set of labels, wherein the annotation indicates the probability that a haplotype having the label corresponds to the haploid state; calculating, for each window, a label pair probability distribution based on the annotations for the window and the diploid state probabilities for the diploid hidden Markov model of the window, wherein the label pair probability distribution maps each pair of labels of the label pair probability distribution to the probability that the single nucleotide polymorphisms in the window correspond to the pair of labels; building an inter-window hidden Markov model, the inter-window hidden Markov model including a plurality of states that each correspond to a pair of labels and a window, wherein the inter-window hidden Markov model is based on the label pair probability distribution for each window; and assigning the one or more labels to the input sample genotype based on the inter-window hidden Markov model. accessing an input sample genotype; dividing the input sample genotype into a plurality of windows of sequential single nucleotide polymorphisms; building, for each window, a diploid hidden Markov model based on the input sample genotype, wherein each diploid state in the diploid hidden Markov model corresponds to a pair of haploid states from a haploid Markov model for the window; calculating, for each diploid state in each diploid hidden Markov model , a diploid state probability indicating the likelihood that the input sample genotype corresponds to the diploid state; accessing, for each window, a set of annotations, each annotation corresponding to a haploid state from the haploid Markov model for the window and to a label of the set of labels, wherein the annotation indicates the probability that a haplotype having the label corresponds to the haploid state; calculating, for each window, a label pair probability distribution based on the annotations for the window and the diploid state probabilities for the diploid hidden Markov model of the window, wherein the label pair probability distribution maps each pair of labels of the label pair probability distribution to the probability that the single nucleotide polymorphisms in the window correspond to the pair of labels; building an inter-window hidden Markov model, the inter-window hidden Markov model including a plurality of states that each correspond to a pair of labels and a window, wherein the inter-window hidden Markov model is based on the label pair probability distribution for each window; and assigning the one or more labels to the input sample genotype based on the inter-window hidden Markov model. <EOS>