Recovery of gene haplotypes from a metagenome