import math


def prob_concentration(concentration, num_mismatches):
    """Computes the concentration factor of the total cut probability
    Args:
        concentration: intranuclear gRNA-cas9 steady state concentration in nM
        num_mismatches: mismatches between gRNA and target
    Returns:
        float in [0.0, 1.0]
    Notes:
        - the formulas were generated using regression and fitting 
        in Excel with data from Wu et al 2014
    """
    glob_scale = 2/math.pi # ensure it's between 0 and 1
    mismatch_scale = 354.3859 - 15.8762*num_mismatches # generated using regression in Excel
    return (glob_scale*math.atan(concentration/mismatch_scale))
    #Holding on to old R regression formulas for now in case the new suggested
    #formula is not acceptable, and for easy reference
    #if num_mismatches == 0:  # no mismatches case
    #    return (10**(-0.9935))*(concentration**0.465691)
    #else:
    #    return (10**(0.036775*num_mismatches-1.616842))*(concentration**0.29122)