Closed GoogleCodeExporter closed 9 years ago
Hi kheyfboris,
A selection is still part of its Universe and any changes will change the
underlying coordinates. You cannot simply duplicate a selection and make it
independent of the Universe (i.e. in Python speak there's no "deep copy").
Think of selections as "pointers" to atoms. Whenever you change the selection
you're changing the underlying Atom object.
I think your code should correctly write out shifted copies but your All atom
group will simply contain len(MoveByVectors)-1 copies of the selection, and
they will all have the coordinates shifted by np.sum(MoveByVectors,axis=1).
I think this problem is better discussed on the user mailing list so I am
closing it. If you think that this is bug or if you want to formulate a feature
request then you're of course welcome reopen the Issue (just add a comment to
this effect, describing the details).
If you're interested in using MDAnalysis for system building (e.g. create
multiple copies of a solvent molecule and translate) then you check with Andy
Somogyi who has been working on extending MDAnalysis substantially in this
direction.
Oliver
Original comment by orbeckst
on 17 Oct 2012 at 9:18
Oh, Ok then. I managed to do what I needed any way: I wrote several pdbs to a
newly created dir, renumbered them with editconf, and merged them with pymol:
for Number, Vector in enumerate(MoveByVectors):
# loading:
universe = Universe(args.myStr)
Temp = universe.selectAtoms("all")
# translation:
Temp.translate(Vector)
# rotation:
RotationPoint = Temp.atoms.centerOfGeometry()
perpVector = r_[Vector[1], -Vector[0], Vector[2]] # perpendicular to Vector in the x-y plane -- to rotate the thing about
Rotation = rotation_matrix(-AngleRad, perpVector, RotationPoint)
Temp.atoms.rotate(Rotation[:3,:3])
# saving:
fileName = myBody + "_" + "{0:03d}".format(Number + 1) + myExt
Temp.write(fileName)
# renumber:
subprocess.check_call("editconf{wW} -f {File} -o {File} -resnr {Num}".format(File = fileName, wW = args.wW, Num = Number + 1), shell=True, cwd=os.getcwd())
Original comment by kheyfbo...@gmail.com
on 18 Oct 2012 at 1:07
Attachments:
Original issue reported on code.google.com by
kheyfbo...@gmail.com
on 17 Oct 2012 at 5:35