def new_ccf(rw, purity):
    """
    Compute CCF with estimate of purity
    :param rw: row (variant)
    :param purity: purity
    :return: CCF of each variant
    """

    vaf = rw['t_alt_reads']/(rw['t_ref_reads']+rw['t_alt_reads'])

    # definition of CCF
    rw['ccf'] = vaf*(purity*rw['cnv_facets'] + (1-purity)*2)/purity
    return rw