Пример #1
0
def s2NOEfit(transformed_coors, native_sse_order, exp_data):
    import warnings
    """
    Depr
    :param transformed_coors:
    :param native_sse_order:
    :param exp_data:
    :return:
    """
    warnings.warn("deprecated", DeprecationWarning)

    noe_cutoff = False

    sse_coors = copy.deepcopy(transformed_coors)
    noe_matrix = exp_data['noe_data']
    noes_found = []
    noes_total = []
    for i in range(0, len(sse_coors) - 1):
        res_c, ca1 = getNHandresi(sse_coors[i])
        res_n, ca2 = getNHandresi(sse_coors[i + 1])
        ss1_list = range(native_sse_order[i][4], native_sse_order[i][5] + 1)
        ss2_list = range(native_sse_order[i + 1][4],
                         native_sse_order[i + 1][5] + 1)
        try:
            for res1 in ss1_list:
                # print ss1_list, res1, res_c, res_c[ss1_list.index(res1)]
                # print ss1_list.index(res1)
                ca_res1 = [
                    ca1[0][ss1_list.index(res1)], ca1[1][ss1_list.index(res1)],
                    ca1[2][ss1_list.index(res1)]
                ]
                for res2 in ss2_list:
                    if noe_matrix[res1, res2]:
                        noe_cutoff = noe_matrix[res1, res2]
                    elif noe_matrix[res2, res1]:
                        noe_cutoff = noe_matrix[res2, res1]
                    else:
                        noe_cutoff = False
                    if noe_cutoff:
                        ca_res2 = [
                            ca2[0][ss2_list.index(res2)],
                            ca2[1][ss2_list.index(res2)],
                            ca2[2][ss2_list.index(res2)]
                        ]
                        dist = get_dist(ca_res1, ca_res2)
                        if dist < noe_cutoff:
                            noes_found.append((res1, res2))
                            noes_total.append((res1, res2))
                        else:
                            noes_total.append((res1, res2))
        except:
            return []
    if len(noes_found) == 0:
        return []

    fmeasure = calcFmeasure(noes_found, noes_total)

    return fmeasure
Пример #2
0
def S1ILVANOEprob(s1_def, s2_def, smotif, exp_data):
    """

    :param s1_def:
    :param s2_def:
    :param smotif:
    :param exp_data:
    :return:
    """

    noe_data = exp_data['noe_data']
    print "Working on new one"
    print noe_data
    noes = noe_data[0]
    total_noes = noe_data[1]
    noes_found = 0.0
    smotif_noes = 0.0
    ss1_list = range(s1_def[4], s1_def[5] + 1)
    ss2_list = range(s2_def[4], s2_def[5] + 1)

    #smotif_ss1 = range(int(smotif[0][1]), int(smotif[0][2]) + 1)
    #smotif_ss2 = range(int(smotif[0][3]), int(smotif[0][4]) + 1)

    coor_matrix = getHCoorMatrix(ss1_list, smotif[1])
    coor2_matrix = getHCoorMatrix(ss2_list, smotif[2])
    coor_matrix.update(coor2_matrix)
    resi = coor_matrix.keys()

    for noe in noes:
        res1, atm1, res2, atom2, noe_cutoff, tol = noe[0], noe[1], noe[2], noe[
            3], noe[4], noe[5]
        if res1 in resi and res2 in resi:
            smotif_noes += 1.0
            coo1 = coor_matrix[res1]
            coo2 = coor_matrix[res2]
            dist = get_dist(coo1, coo2)
            if dist <= noe_cutoff + tol:
                noes_found += 1.0

    if smotif_noes > 0:
        local_prob = (noes_found / smotif_noes)
    else:
        local_prob = 0.0
    return (noes_found / total_noes), local_prob, noes_found
Пример #3
0
def SxNOEprob(transformed_coors, native_sse_order, current_ss, exp_data):
    """

    :param transformed_coors:
    :param native_sse_order:
    :param current_ss:
    :param exp_data:
    :return:
    """
    import copy
    sse_coors = copy.deepcopy(transformed_coors)

    noe_data = exp_data['noe_data']
    noes = noe_data[0]
    total_noes = noe_data[1]
    noes_found = 0.0
    smotif_noes = 0.0
    coor_matrix = {}

    for i in range(0, len(sse_coors)):
        tcoor = getSxCoorMatrix(sse_coors[i], native_sse_order[i])
        coor_matrix.update(tcoor)

    resi = coor_matrix.keys()

    for noe in noes:
        res1, res2, noe_cutoff, tol = noe[0], noe[2], noe[4], noe[5]

        if (res1 in resi) and (
                res2 in resi):  # this make sure that the resi are in the SSEs
            smotif_noes += 1.0
            coo1 = coor_matrix[res1]
            coo2 = coor_matrix[res2]
            dist = get_dist(coo1, coo2)
            if dist <= noe_cutoff + tol:
                noes_found += 1.0

    if smotif_noes > 0:
        local_prob = (noes_found / smotif_noes)
    else:
        local_prob = 0.0

    #return (noes_found / total_noes), local_prob, noes_found
    return local_prob, local_prob, noes_found
Пример #4
0
def s2EVcouplings(transformed_coors, native_sse_order, contact_matrix, plm_score_matrix, contacts_cutoff):
    # print native_sse_order
    import copy
    sse_coors = copy.deepcopy(transformed_coors)

    contacts_found = []
    total_contacts = []
    for i in range(0, len(sse_coors) - 1):

        res_c, ca1 = getCAandresi(sse_coors[i])
        res_n, ca2 = getCAandresi(sse_coors[i + 1])
        ss1_list = range(native_sse_order[i][4], native_sse_order[i][5] + 1)
        ss2_list = range(native_sse_order[i + 1][4], native_sse_order[i + 1][5] + 1)

        for res1 in ss1_list:
            # print ss1_list, res1, res_c, res_c[ss1_list.index(res1)]
            # print ss1_list.index(res1)
            ca_res1 = [ca1[0][ss1_list.index(res1)], ca1[1][ss1_list.index(res1)], ca1[2][ss1_list.index(res1)]]
            for res2 in ss2_list:
                ca_res2 = [ca2[0][ss2_list.index(res2)], ca2[1][ss2_list.index(res2)], ca2[2][ss2_list.index(res2)]]
                dist = get_dist(ca_res1, ca_res2)

                if contact_matrix[res1, res2] or contact_matrix[res2, res1]:
                    total_contacts.append((res1, res2))

                if dist < contacts_cutoff:
                    contacts_found.append((res1, res2))

    # print len(total_contacts), total_contacts
    # print len(contacts_found), contacts_found

    fmeasure = calcFmeasure(contacts_found, total_contacts)
    if fmeasure:
        plm_score = calcPLMscore(contacts_found, plm_score_matrix)
        return fmeasure, plm_score
    else:
        return 0.0, 0.0
Пример #5
0
def s2NOEfit(transformed_coors, native_sse_order, exp_data):

    noe_cutoff = 5.0
    import copy
    sse_coors = copy.deepcopy(transformed_coors)
    noe_matrix = exp_data['noe_data']

    noes_found = []
    noes_total = []
    for i in range(0, len(sse_coors) - 1):
        res_c, ca1 = getNHandresi(sse_coors[i])
        res_n, ca2 = getNHandresi(sse_coors[i + 1])
        ss1_list = range(native_sse_order[i][4], native_sse_order[i][5] + 1)
        ss2_list = range(native_sse_order[i + 1][4], native_sse_order[i + 1][5] + 1)
        try:
            for res1 in ss1_list:
                # print ss1_list, res1, res_c, res_c[ss1_list.index(res1)]
                # print ss1_list.index(res1)
                ca_res1 = [ca1[0][ss1_list.index(res1)], ca1[1][ss1_list.index(res1)], ca1[2][ss1_list.index(res1)]]
                for res2 in ss2_list:
                    ca_res2 = [ca2[0][ss2_list.index(res2)], ca2[1][ss2_list.index(res2)], ca2[2][ss2_list.index(res2)]]
                    dist = get_dist(ca_res1, ca_res2)

                    if noe_matrix[res1, res2] or noe_matrix[res2, res1]:
                        noes_total.append((res1, res2))

                    if dist < noe_cutoff:
                        noes_found.append((res1, res2))
        except:
            return []
    if len(noes_found) == 0:
        return []

    fmeasure = calcFmeasure(noes_found, noes_total)


    return fmeasure
Пример #6
0
def s1NOEfit(s1_def, s2_def, smotif, exp_data):
    """

    :param s1_def:
    :param s2_def:
    :param smotif:
    :param exp_data:
    :return:
    """
    noe_matrix = exp_data['noe_data']
    ss1_list = range(s1_def[4], s1_def[5] + 1)
    ss2_list = range(s2_def[4], s2_def[5] + 1)

    smotif_ss1 = range(int(smotif[0][1]), int(smotif[0][2]) + 1)
    smotif_ss2 = range(int(smotif[0][3]), int(smotif[0][4]) + 1)

    noes_found = []
    noes_total = []

    # Scoring intra-SSE NOEs
    coo1 = [999, 999, 999]
    coo2 = [0.0, 0.0, 0.0]

    for i in range(0, len(smotif_ss1) - 1):
        sres1 = smotif_ss1[i]
        nres1 = ss1_list[i]
        for j in range(i + 1, len(smotif_ss1)):
            sres2 = smotif_ss1[j]
            nres2 = ss1_list[j]
            if noe_matrix[nres1, nres2]:
                noe_cutoff = noe_matrix[nres1, nres2]
                for entry1 in smotif[1]:
                    if entry1[2] == 'H' and entry1[0] == sres1:
                        coo1 = [entry1[3], entry1[4], entry1[5]]
                    if entry1[2] == 'H' and entry1[0] == sres2:
                        coo2 = [entry1[3], entry1[4], entry1[5]]

                dist = get_dist(coo1, coo2)
                # print sres1, sres2, noe_cutoff, coo1, coo2, dist
                if noe_cutoff > 10000:
                    real_noe = noe_cutoff - 10000
                    # backmapping side chain noes to amides
                    if real_noe - 4.0 <= dist <= real_noe + 4.0:
                        noes_found.append((sres1, sres2))
                        noes_total.append((sres1, sres2))
                    else:
                        noes_total.append((sres1, sres2))
                elif dist <= noe_cutoff:
                    noes_found.append((sres1, sres2))
                    noes_total.append((sres1, sres2))
                else:
                    noes_total.append((sres1, sres2))
    coo1 = [999, 999, 999]
    coo2 = [0.0, 0.0, 0.0]

    for i in range(0, len(smotif_ss2) - 1):
        sres1 = smotif_ss2[i]
        nres1 = ss2_list[i]
        for j in range(i + 1, len(smotif_ss2)):
            sres2 = smotif_ss2[j]
            nres2 = ss2_list[j]
            if noe_matrix[nres1, nres2]:
                noe_cutoff = noe_matrix[nres1, nres2]
                for entry1 in smotif[2]:
                    if entry1[2] == 'H' and entry1[0] == sres1:
                        coo1 = [entry1[3], entry1[4], entry1[5]]
                    if entry1[2] == 'H' and entry1[0] == sres2:
                        coo2 = [entry1[3], entry1[4], entry1[5]]

                dist = get_dist(coo1, coo2)
                # print sres1, sres2, noe_cutoff, coo1, coo2, dist
                if noe_cutoff > 10000:
                    real_noe = noe_cutoff - 10000
                    # backmapping side chain noes to amides
                    if real_noe - 4.0 <= dist <= real_noe + 4.0:
                        noes_found.append((sres1, sres2))
                        noes_total.append((sres1, sres2))
                    else:
                        noes_total.append((sres1, sres2))
                elif dist <= noe_cutoff:
                    noes_found.append((sres1, sres2))
                    noes_total.append((sres1, sres2))
                else:
                    noes_total.append((sres1, sres2))
    # end of Scoring intra-SSE NOEs

    for res in smotif_ss1:
        for entry1 in smotif[1]:
            if entry1[2] == 'H' and entry1[0] == res:
                coo1 = [entry1[3], entry1[4], entry1[5]]
                for entry2 in smotif[2]:
                    if entry2[2] == 'H':
                        coo2 = [entry2[3], entry2[4], entry2[5]]
                        res1 = ss1_list[smotif_ss1.index(entry1[0])]
                        res2 = ss2_list[smotif_ss2.index(entry2[0])]
                        if noe_matrix[res1, res2]:
                            noe_cutoff = noe_matrix[res1, res2]
                        else:
                            noe_cutoff = False
                        if noe_cutoff:
                            dist = get_dist(coo1, coo2)
                            if noe_cutoff > 10000:
                                real_noe = noe_cutoff - 10000
                                # backmapping side chain noes to amides
                                if real_noe - 4.0 <= dist <= real_noe + 4.0:
                                    noes_found.append((res1, res2))
                                    noes_total.append((res1, res2))
                                else:
                                    noes_total.append((res1, res2))
                            elif dist <= noe_cutoff:
                                noes_found.append((res1, res2))
                                noes_total.append((res1, res2))
                            else:
                                noes_total.append((res1, res2))
    if len(noes_found) == 0:
        return 0.00, 0.00

    # fmeasure = calcFmeasure(noes_found, noes_total)
    fmeasure = (float(len(noes_found)) / float(len(noes_total)))
    return fmeasure, len(noes_found)
Пример #7
0
def sXGlobalNOEfit(transformed_coors, native_sse_order, current_ss, exp_data):
    import copy
    sse_coors = copy.deepcopy(transformed_coors)
    noe_matrix = exp_data['noe_data']
    noes_found = []
    noes_total = []

    # current_ss ['strand', 13, 4, 10, 36, 48]
    cresi = range(current_ss[4], current_ss[5] + 1)

    # Score Intra SSE NOEs first
    score_intra_sse = False
    for i in range(0, len(sse_coors)):
        ss1_list = range(native_sse_order[i][4], native_sse_order[i][5] + 1)
        res_c, ca1 = getNHandresi(sse_coors[i])
        try:
            for j in range(0, len(cresi) - 1):
                res1 = cresi[j]
                coo1 = [
                    ca1[0][ss1_list.index(res1)], ca1[1][ss1_list.index(res1)],
                    ca1[2][ss1_list.index(res1)]
                ]
                for k in range(j + 1, len(cresi)):
                    res2 = cresi[k]
                    coo2 = [
                        ca1[0][ss1_list.index(res2)],
                        ca1[1][ss1_list.index(res2)],
                        ca1[2][ss1_list.index(res2)]
                    ]
                    noe_cutoff = noe_matrix[res1, res2]
                    if noe_cutoff:
                        dist = get_dist(coo1, coo2)
                        if noe_cutoff > 10000:
                            real_noe = noe_cutoff - 10000
                            # backmapping side chain noes to amides
                            if real_noe - 4.0 <= dist <= real_noe + 4.0:
                                noes_found.append((res1, res2))
                                noes_total.append((res1, res2))
                            else:
                                noes_total.append((res1, res2))
                        elif dist <= noe_cutoff:
                            noes_found.append((res1, res2))
                            noes_total.append((res1, res2))
                        else:
                            noes_total.append((res1, res2))
        except:
            continue

    import itertools
    sse_pairs = list(itertools.combinations(range(len(sse_coors)), 2))
    # [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 3),\
    # (2, 4), (2, 5), (2, 6), (2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (4, 5), (4, 6), (4, 7), (5, 6), (5, 7), (6, 7)]

    for ij in sse_pairs:
        i = ij[0]
        j = ij[1]
        res_c, ca1 = getNHandresi(sse_coors[i])
        res_n, ca2 = getNHandresi(sse_coors[j])
        ss1_list = range(native_sse_order[i][4], native_sse_order[i][5] + 1)
        ss2_list = range(native_sse_order[j][4], native_sse_order[j][5] + 1)

        for res1 in ss1_list:
            try:
                ca_res1 = [
                    ca1[0][ss1_list.index(res1)], ca1[1][ss1_list.index(res1)],
                    ca1[2][ss1_list.index(res1)]
                ]
            except:
                continue
            for res2 in ss2_list:
                if noe_matrix[res1, res2]:
                    noe_cutoff = noe_matrix[res1, res2]
                elif noe_matrix[res2, res1]:
                    noe_cutoff = noe_matrix[res2, res1]
                else:
                    noe_cutoff = False
                if noe_cutoff:
                    # mo res1, res2, noe_matrix[res1, res2], noe_matrix[res2, res1], noe_cutoff
                    try:
                        ca_res2 = [
                            ca2[0][ss2_list.index(res2)],
                            ca2[1][ss2_list.index(res2)],
                            ca2[2][ss2_list.index(res2)]
                        ]
                    except:
                        continue
                    dist = get_dist(ca_res1, ca_res2)

                    if noe_cutoff > 10000:
                        real_noe = noe_cutoff - 10000  # back mapping side chain noes to amides

                        if real_noe - 4.0 <= dist <= real_noe + 4.0:
                            noes_found.append((res1, res2))
                            noes_total.append((res1, res2))
                        else:
                            noes_total.append((res1, res2))

                    elif dist <= noe_cutoff:
                        noes_found.append((res1, res2))
                        noes_total.append((res1, res2))
                    else:
                        noes_total.append((res1, res2))

    # if len(noes_found) == 0 or not sse_satisfied:
    if len(noes_found) == 0:
        return 0.00, 0
    # fmeasure = calcFmeasure(noes_found, noes_total)
    fmeasure = (float(len(noes_found)) / float(len(noes_total)))
    return fmeasure, len(noes_found)