From phenotype to genotype: a Bayesian solution