49 from rosetta
import Pose
50 from rosetta.numeric
import xyzVector
53 from extract_coords_pose
import extract_coordinates_from_pose_1x3
57 optAlign performs the Kabsch alignment algorithm upon the alpha-carbons of two selections.
59 By default, this program will optimally align the ALPHA CARBONS of the selections provided.
60 To turn off this feature remove the lines between the commented "REMOVE ALPHA CARBONS" below.
62 This is a hacky modification for usage in PyRosetta,
63 The geometry/math is the same but it uses poses instead of PyMOL
65 @param pose1: First pose
66 @param pose2: Second pose
67 @param pose1sel: List of residues to align in the first pose
68 @param pose2sel: List of residues to align in the second pose
73 pose1sel = range(1,pose1.total_residue()+1)
75 pose2sel = range(1,pose2.total_residue()+1)
83 v = pose1.residue(r).atom('CA').xyz()
84 stsel1.append([v[0],v[1],v[2]])
87 v = pose2.residue(r).atom('CA').xyz()
88 stsel2.append([v[0],v[1],v[2]])
96 for r in range(pose1.total_residue()):
97 r = pose1.residue(r+1)
98 for a in range(r.natoms()):
100 molsel1.append([v[0],v[1],v[2]])
102 for r in range(pose2.total_residue()):
103 r = pose2.residue(r+1)
104 for a in range(r.natoms()):
106 molsel2.append([v[0],v[1],v[2]])
110 assert len(stsel1) ==
len(stsel2)
116 COM1 = numpy.sum(stsel1,axis=0) /
float(L)
117 COM2 = numpy.sum(stsel2,axis=0) /
float(L)
122 E0 = numpy.sum( numpy.sum(stsel1 * stsel1,axis=0),axis=0) + numpy.sum( numpy.sum(stsel2 * stsel2,axis=0),axis=0)
127 V, S, Wt = numpy.linalg.svd( numpy.dot( numpy.transpose(stsel2), stsel1))
133 reflect =
float(str(
float(numpy.linalg.det(V) * numpy.linalg.det(Wt))))
139 RMSD = E0 - (2.0 *
sum(S))
140 RMSD = numpy.sqrt(
abs(RMSD / L))
146 stsel2 = numpy.dot((molsel2 - COM2), U)
147 stsel2 = stsel2.tolist()
149 stsel1 = molsel1 - COM1
150 stsel1 = stsel1.tolist()
157 for r
in range(pose1.total_residue()):
158 res = pose1.residue(r+1)
159 for a
in range(res.natoms()):
165 pose1.residue(r+1).set_xyz(a+1,dummy)
168 for r
in range(pose2.total_residue()):
169 res = pose2.residue(r+1)
170 for a
in range(res.natoms()):
176 pose2.residue(r+1).set_xyz(a+1,dummy)
178 print 'RMSD=%f' % RMSD
Fstring::size_type len(Fstring const &s)
Length.
Real sum(ddGs &scores_to_sum)
T abs(T const &x)
std::abs( x ) == | x |