示例#1
0
def rmsdQCP3(previous_smotif, csmotif, direction):
    """

    :param previous_smotif:
    :param csmotif:
    :param direction:
    :return:
    """

    for entry in previous_smotif:
        if 'qcp_rmsd' == entry[0]:
            temp_holder = entry[1]
            presse = temp_holder[:]

    #print csmotif
    if direction == 'left':
        frag_b = getcoo(csmotif[2])
        native_fragb_2ndsse = copy.copy(csmotif[1])
        frag_a = copy.deepcopy(presse[0])

    else:
        try:
            frag_a = copy.deepcopy(presse[-1])
            frag_b = getcoo(csmotif[1])
            native_fragb_2ndsse = copy.copy(csmotif[2])
        except:
            print previous_smotif

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])

    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    # print rmsd

    rotmat = []
    for i in range(0, 9):
        rotmat.append(qcprot.GetDvector(i, rot))

    # translate the other SSE of the current smotif

    sse_2nd_coos = getcoo(native_fragb_2ndsse)
    cm_sse2nd = translateCM(sse_2nd_coos, b_cen)
    rot_sse_2nd = applyRot(cm_sse2nd, rotmat)
    trans_sse2nd = applyTranslation(rot_sse_2nd, a_cen)

    # append the translated coordinates
    temp_holder = copy.deepcopy(presse)

    if direction == 'left':
        temp_holder.insert(0, trans_sse2nd)
    else:
        temp_holder.append(trans_sse2nd)


    qcprot.FreeDMatrix(xyz1)
    qcprot.FreeDMatrix(xyz2)
    qcprot.FreeDArray(rot)

    return rmsd, temp_holder
示例#2
0
def rmsdQCP(psmotif, csmotif, direction):
    """
    use rmsdQCP
    :param psmotif:
    :param csmotif:
    :param direction:
    :return:
    """

    psmotif = copy.copy(psmotif[1])

    if direction == 'left':
        native_fraga = getcoo(psmotif[1])
        frag_a = getcoo(psmotif[1])
        frag_b = getcoo(csmotif[2])
        native_fragb_2ndsse = copy.copy(csmotif[1])
        native_fraga_2ndsse = getcoo(psmotif[2])
    else:

        native_fraga = getcoo(psmotif[2])
        frag_a = getcoo(psmotif[2])
        frag_b = getcoo(csmotif[1])
        native_fragb_2ndsse = copy.copy(csmotif[2])
        native_fraga_2ndsse = getcoo(psmotif[1])

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])

    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    rotmat = []
    for i in range(0, 9):
        rotmat.append(qcprot.GetDvector(i, rot))

    rotated_fragb = applyRot(frag_b, rotmat)

    # trans_fragb = applyTranslation(rotated_fragb, a_cen)

    # translate the other SSE of the current smotif
    sse_2nd_coos = getcoo(native_fragb_2ndsse)
    # sse_2nd_coos, sec_cm = centerCoo(sse_2nd_coos)
    cm_sse2nd = translateCM(sse_2nd_coos,b_cen)
    rot_sse_2nd = applyRot(cm_sse2nd, rotmat)
    trans_sse2nd = applyTranslation(rot_sse_2nd, a_cen)

    #return 3 arrays of coordinates
    if direction == 'left':
        #transformed_coor = [native_fraga, native_fraga_2ndsse, trans_sse2nd]

        transformed_coor = [trans_sse2nd, native_fraga, native_fraga_2ndsse]
        #
    else:

        transformed_coor = [native_fraga_2ndsse, native_fraga, trans_sse2nd]

    qcprot.FreeDMatrix(xyz1)
    qcprot.FreeDMatrix(xyz2)
    qcprot.FreeDArray(rot)

    return rmsd, transformed_coor
示例#3
0
def refineRMSD(smotif_coors, pair, csmotif, rmsd_cutoff):

    tsmotif_coors = copy.deepcopy(smotif_coors)

    frag_a1 = tsmotif_coors[pair[0]]
    frag_a2 = tsmotif_coors[pair[1]]
    frag_a = combine_arrays(frag_a1, frag_a2)

    frag_b1 = getcoo(csmotif[1])
    frag_b2 = getcoo(csmotif[2])
    frag_b = combine_arrays(frag_b1, frag_b2)

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])

    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    if rmsd > rmsd_cutoff:
        # exit without further computation
        # free memory
        qcprot.FreeDMatrix(xyz1)
        qcprot.FreeDMatrix(xyz2)
        qcprot.FreeDArray(rot)
        return [], rmsd
    else:

        rotmat = [None] * 9
        for i in range(0, 9):
            rotmat[i] = qcprot.GetDvector(i, rot)

        cm_frag_b1 = translateCM(frag_b1, b_cen)
        cm_frag_b2 = translateCM(frag_b2, b_cen)

        rot_frag_b1 = applyRot(cm_frag_b1, rotmat)
        rot_frag_b2 = applyRot(cm_frag_b2, rotmat)

        trans_frag_b1 = applyTranslation(rot_frag_b1, a_cen)
        trans_frag_b2 = applyTranslation(rot_frag_b2, a_cen)

        tsmotif_coors.pop(pair[0])
        tsmotif_coors.insert(pair[0], trans_frag_b1)

        tsmotif_coors.pop(pair[1])
        tsmotif_coors.insert(pair[1], trans_frag_b2)

        qcprot.FreeDMatrix(xyz1)
        qcprot.FreeDMatrix(xyz2)
        qcprot.FreeDArray(rot)

        return tsmotif_coors, rmsd
示例#4
0
def rmsdQCP4(pair, presse, alt_smotif_log, csmotif, direction, cutoff):
    """
    TODO Delete this function
    :param pair:
    :param presse:
    :param alt_smotif_log:
    :param csmotif:
    :param direction:
    :param cutoff:
    :return:
    """

    from utility.alt_smotif_util import delete_last_sse

    if direction == 'left':
        frag_b = getcoo(csmotif[2])
        native_fragb_2ndsse = (csmotif[1])[:]
        frag_a = copy.deepcopy(presse[pair[1]])
        presse = delete_last_sse(presse, alt_smotif_log)
    else:
        frag_a = copy.deepcopy(presse[pair[0]])
        frag_b = getcoo(csmotif[1])
        native_fragb_2ndsse = (csmotif[2])[:]
        presse = delete_last_sse(presse, alt_smotif_log)

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])
    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    if rmsd > cutoff:
        # exit without further computation
        # free memory
        qcprot.FreeDMatrix(xyz1)
        qcprot.FreeDMatrix(xyz2)
        qcprot.FreeDArray(rot)
        return rmsd, []

    rotmat = [None] * 9
    for i in range(0, 9):
        rotmat[i] = qcprot.GetDvector(i, rot)

    # translate the other SSE of the current smotif

    sse_2nd_coos = getcoo(native_fragb_2ndsse)
    cm_sse2nd = translateCM(sse_2nd_coos, b_cen)
    rot_sse_2nd = applyRot(cm_sse2nd, rotmat)
    trans_sse2nd = applyTranslation(rot_sse_2nd, a_cen)

    # append the translated coordinates
    temp_holder = presse[:]

    if direction == 'left':
        temp_holder.insert(0, trans_sse2nd)
    else:
        temp_holder.append(trans_sse2nd)

    # free memory
    qcprot.FreeDMatrix(xyz1)
    qcprot.FreeDMatrix(xyz2)
    qcprot.FreeDArray(rot)

    return rmsd, temp_holder
示例#5
0
def rmsdQCP3(previous_smotif, csmotif, direction, cutoff, previous_sse_index):
    """
    :param previous_smotif:
    :param csmotif:
    :param direction:
    :param cutoff:
    :param previous_sse_index:
    :return:
    """
    psmotif = (previous_smotif[2][1])[:]
    psmotif_index = previous_sse_index[-1]

    if direction == 'left':
        frag_b = getcoo(csmotif[2])
        native_fragb_2ndsse = (csmotif[1])[:]
        frag_a = copy.deepcopy(psmotif[psmotif_index])
    else:
        frag_a = copy.deepcopy(psmotif[psmotif_index])
        frag_b = getcoo(csmotif[1])
        native_fragb_2ndsse = (csmotif[2])[:]

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])

    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    if rmsd > cutoff:
        # exit without further computation
        # free memory
        qcprot.FreeDMatrix(xyz1)
        qcprot.FreeDMatrix(xyz2)
        qcprot.FreeDArray(rot)
        return rmsd, []

    rotmat = [None] * 9
    for i in range(0, 9):
        rotmat[i] = qcprot.GetDvector(i, rot)

    # translate the other SSE of the current smotif

    sse_2nd_coos = getcoo(native_fragb_2ndsse)
    cm_sse2nd = translateCM(sse_2nd_coos, b_cen)
    rot_sse_2nd = applyRot(cm_sse2nd, rotmat)
    trans_sse2nd = applyTranslation(rot_sse_2nd, a_cen)

    # append the translated coordinates
    temp_holder = (psmotif)[:]

    if direction == 'left':
        temp_holder.insert(0, trans_sse2nd)
    else:
        temp_holder.append(trans_sse2nd)

    # free memory
    qcprot.FreeDMatrix(xyz1)
    qcprot.FreeDMatrix(xyz2)
    qcprot.FreeDArray(rot)

    return rmsd, temp_holder
示例#6
0
def rmsdQCP(psmotif, csmotif, direction, cutoff, previous_sse_index):
    """
    use rmsdQCP
    :param psmotif:
    :param csmotif:
    :param direction:
    :param cutoff:
    :param previous_sse_index:
    :return:
    """

    psmotif = (psmotif[1])[:]
    psmotif_index = previous_sse_index[-1]

    if psmotif_index == 0:
        indexa = 1
        indexb = 2
    elif psmotif_index == 1:
        indexa = 2
        indexb = 1
    else:
        print "Error"

    # Extra careful about this if-else loop, the trick is finding the the correct arrays
    if direction == 'left':
        native_fraga = getcoo(psmotif[indexa])
        frag_a = getcoo(psmotif[indexa])
        frag_b = getcoo(csmotif[2])
        native_fragb_2ndsse = (csmotif[1])[:]
        native_fraga_2ndsse = getcoo(psmotif[indexb])
    else:
        native_fraga = getcoo(psmotif[indexa])
        frag_a = getcoo(psmotif[indexa])
        frag_b = getcoo(csmotif[1])
        native_fragb_2ndsse = (csmotif[2])[:]
        native_fraga_2ndsse = getcoo(psmotif[indexb])

    frag_a, a_cen = centerCoo(frag_a)
    frag_b, b_cen = centerCoo(frag_b)

    frag_aca = getCAcoo(frag_a)
    frag_bca = getCAcoo(frag_b)

    fraglen = len(frag_aca[0])

    xyz1 = qcprot.MakeDMatrix(3, fraglen)
    xyz2 = qcprot.MakeDMatrix(3, fraglen)

    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz1, frag_aca[0][i])
        qcprot.SetDArray(1, i, xyz1, frag_aca[1][i])
        qcprot.SetDArray(2, i, xyz1, frag_aca[2][i])
    for i in range(0, fraglen):
        qcprot.SetDArray(0, i, xyz2, frag_bca[0][i])
        qcprot.SetDArray(1, i, xyz2, frag_bca[1][i])
        qcprot.SetDArray(2, i, xyz2, frag_bca[2][i])

    rot = qcprot.MakeDvector(9)

    # *********
    rmsd = qcprot.CalcRMSDRotationalMatrix(xyz1, xyz2, fraglen, rot)
    # *********

    if rmsd > cutoff:
        # exit without further computation
        # free memory
        qcprot.FreeDMatrix(xyz1)
        qcprot.FreeDMatrix(xyz2)
        qcprot.FreeDArray(rot)
        return rmsd, []

    rotmat = [None] * 9
    for i in range(0, 9):
        rotmat[i] = qcprot.GetDvector(i, rot)

    # translate the other SSE of the current smotif
    sse_2nd_coos = getcoo(native_fragb_2ndsse)

    cm_sse2nd = translateCM(sse_2nd_coos, b_cen)
    rot_sse_2nd = applyRot(cm_sse2nd, rotmat)
    trans_sse2nd = applyTranslation(rot_sse_2nd, a_cen)

    # return 3 arrays of coordinates
    # The order problem ?

    if direction == 'left':
        if psmotif_index == 0:
            transformed_coor = [
                trans_sse2nd, native_fraga, native_fraga_2ndsse
            ]
        else:
            transformed_coor = [
                trans_sse2nd, native_fraga_2ndsse, native_fraga
            ]
    else:
        if psmotif_index == 1:  # double check this
            transformed_coor = [
                native_fraga_2ndsse, native_fraga, trans_sse2nd
            ]
        else:
            transformed_coor = [
                native_fraga, native_fraga_2ndsse, trans_sse2nd
            ]

    # free memory
    qcprot.FreeDMatrix(xyz1)
    qcprot.FreeDMatrix(xyz2)
    qcprot.FreeDArray(rot)

    return rmsd, transformed_coor