Beispiel #1
0
def calculatePairWisePhiPsiRmsd( mol1, mol2, ranges='auto' ):
    """
    Calculate a pairwise angular Phi,Psi rmsd between the models of mol1 and mol2
    return result NTlistOfLists, pairwise1, pairwise2, pairwise12 tuple
    """

    fitResidues1 = mol1.setResiduesFromRanges(ranges)
    models1 = PhiPsiLists( mol1, fitResidues1 )

    fitResidues2 = mol2.setResiduesFromRanges(ranges)
    models2 = PhiPsiLists( mol2, fitResidues2 )

    #print '>', ranges, models1, models2

    l1 = len(models1)
    l2 = len(models2)
    if l1 == 0 or len(models1[0]) == 0 or l2 == 0 or len(models2[0]) == 0:
        nTdebug(">calculatePairWisePhiPsiRmsd> returning None, %s %s %s", l1, l2, ranges)
        return None, None, None, None

    models = models1 + models2

    result = NTlistOfLists(len(models), len(models), 0.0)

    #nTmessage( '==> Calculating dihedral pairwise rmsds' )

    for i in range(len(models)):
        for j in range(i+1, len(models)):
            #print '>>', i,j
            r = models[i].calculateRMSD( models[j] )
            if r == None:
                nTdebug('calculatePairWisePhiPsiRmsd: error for %s and %s', models[i], models[j])
                return None, None, None, None
            else:
                result[i][j] = r
                result[j][i] = r
        #end for
    #end for

    pairwise1 = NTlist()
    for i in range(l1):
        for j in range(i+1, l1):
            pairwise1.append(result[i][j])
#            print '1>', i,j

    pairwise2 = NTlist()
    for i in range(l1, l1+l2):
        for j in range(i+1, l1+l2):
            pairwise2.append(result[i][j])
#            print '2>', i,j

    pairwise12 = NTlist()
    for i in range(l1):
        for j in range(l1, l1+l2):
            pairwise12.append(result[i][j])

#            print '12>', i,j
#    print len(pairwise1), len(pairwise2), len(pairwise12)
    return ( result, pairwise1.average2(fmt='%6.2f +- %5.2f'),pairwise2.average2(fmt='%6.2f +- %5.2f'),
        pairwise12.average2(fmt='%6.2f +- %5.2f') )
Beispiel #2
0
def calculatePairWiseRmsd( mol1, mol2, ranges=None ):
    """Calculate pairwise rmsd between mol1 and mol2
       Optionally use ranges for the fitting
    """

    #Use ranges routines to define fitAtoms ed
    fitResidues1 = mol1.setResiduesFromRanges(ranges)
    mol1.selectFitAtoms( fitResidues1, backboneOnly=True, includeProtons = False )
    fitResidues2 = mol2.setResiduesFromRanges(ranges)
    mol2.selectFitAtoms( fitResidues2, backboneOnly=True, includeProtons = False )
#    mol2.superpose( ranges )

    l1 = len(mol1.ensemble)
    l2 = len(mol2.ensemble)

    if (   l1 == 0 or len(mol1.ensemble[0].fitCoordinates) == 0
        or l2 == 0 or len(mol2.ensemble[0].fitCoordinates) == 0
        or len(mol1.ensemble[0].fitCoordinates) != len(mol2.ensemble[0].fitCoordinates)
    ):
        nTdebug( ">calculatePairWiseRmsd> returning None, %s %s %s" , l1, l2, ranges)
        return None, None, None, None


    models = mol1.ensemble + mol2.ensemble

    result = NTlistOfLists(len(models), len(models), 0.0)

    nTmessage('==> Calculating pairwise rmsds %s %s', mol1, mol2)

    for i in range(len(models)):
        for j in range(i+1, len(models)):
            result[i][j] = models[i].superpose( models[j] )
            result[j][i] = result[i][j]
        #end for
    #end for

    pairwise1 = NTlist()
    for i in range(l1):
        for j in range(i+1, l1):
            pairwise1.append(result[i][j])
#            print '1>', i,j

    pairwise2 = NTlist()
    for i in range(l1, l1+l2):
        for j in range(i+1, l1+l2):
            pairwise2.append(result[i][j])
#            print '2>', i,j

    pairwise12 = NTlist()
    for i in range(l1):
        for j in range(l1, l1+l2):
            pairwise12.append(result[i][j])

#            print '12>', i,j
#    print len(pairwise1), len(pairwise2), len(pairwise12)
    return ( result, pairwise1.average2(fmt='%6.2f +- %5.2f'),pairwise2.average2(fmt='%6.2f +- %5.2f'),
        pairwise12.average2(fmt='%6.2f +- %5.2f'))