def calculate_posterior(bayes_factor, prior_prob):
    """
    Calculate the posterior probability of association from the bayes factor
    and prior probability of association.
    """
    if bayes_factor == float('inf'):
        return 1.0
    posterior_odds = bayes_factor * prior_prob / (1.0 - prior_prob)
    return posterior_odds / (1.0 + posterior_odds)