Skip to content

Copy function did not return an independent entity? #4956

Answered by orbeckst
locitran asked this question in Q&A
Discussion options

You must be logged in to vote

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 u.trajectory.ts.positions). It is effectively the same as

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 positions is a regular numpy array. Then compare u1_pos with u1_ca.positions.

See also Why do the atom position change over trajectories?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RMeli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4921 on March 11, 2025 01:18.