-
Hi, I try to do superimposition u2 into u1 using CA only. These structures have the same number of atoms. Is this a normal situation or a bug? How could I make a complete independent entity? Please download the files here: u1.pdb and u2.pdb import MDAnalysis as mda
from MDAnalysis.analysis import align
pdb1 = 'u1.pdb'
pdb2 = 'u2.pdb'
u1 = mda.Universe(pdb1)
u2 = mda.Universe(pdb2)
u1_ca = u1.select_atoms('name CA').copy()
u2_ca = u2.select_atoms('name CA').copy()
print(u1.select_atoms('name CA').positions[1:3,1:3], u1_ca.positions[1:3,1:3]) Before superimposition, (array([[-5.735, 28.569],
[-4.479, 26.143]], dtype=float32),
array([[-5.735, 28.569],
[-4.479, 26.143]], dtype=float32)) mobile0 = u1_ca.positions - u1_ca.atoms.center_of_mass()
ref0 = u2_ca.positions - u2_ca.atoms.center_of_mass()
R, rmsd_value = align.rotation_matrix(mobile0, ref0)
print("Rotation matrix = \n", R)
print("RMSD = ", rmsd_value)
u1_ca.atoms.translate(-u1_ca.atoms.center_of_mass())
u1_ca.atoms.rotate(R)
u1_ca.atoms.translate(u2_ca.atoms.center_of_mass())
print(u1.select_atoms('name CA').positions[1:3,1:3], u1_ca.positions[1:3,1:3]) After superimposition, (array([[ 9.291354, -24.866745],
[ 8.894788, -21.551838]], dtype=float32),
array([[ 9.291354, -24.866745],
[ 8.894788, -21.551838]], dtype=float32)) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The line u1_ca = u1.select_atoms('name CA').copy() makes a copy of an AtomGroup. However, an AtomGroup is (essentially) just an array of indices into the underlying coordinates (namely u1_ca = u1.select_atoms('name CA') Copying it does not give you a copy of the underlying coordinates. You can make copies of coordinates at the current frame and before the superposition with u1_pos = u1_ca.positions.copy() because |
Beta Was this translation helpful? Give feedback.
The line
makes a copy of an AtomGroup. However, an AtomGroup is (essentially) just an array of indices into the underlying coordinates (namely
u.trajectory.ts.positions
). It is effectively the same asCopying it does not give you a copy of the underlying coordinates. You can make copies of coordinates at the current frame and before the superposition with
because
positions
is a regular numpy array. Then compareu1_pos
withu1_ca.positions
.See also Why do the atom position change over trajectories?