Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransformationSymmetry not applied correctly #1032

Closed
benmwebb opened this issue Aug 26, 2020 · 1 comment
Closed

TransformationSymmetry not applied correctly #1032

benmwebb opened this issue Aug 26, 2020 · 1 comment
Assignees
Labels

Comments

@benmwebb
Copy link
Member

Jan reports on imp-users that the following script (using example_protein.pdb from modules/core/examples) results in wonky coordinates for one rigid body related by TransformationSymmetry:

import IMP
import IMP.core
import IMP.atom
import IMP.container
import IMP.rmf
import RMF
import sys

IMP.setup_from_argv(sys.argv, "rigid bodies")

m = IMP.Model()
rbs = []
hs = []
for i in range(4):
    mp1 = IMP.atom.read_pdb(IMP.core.get_example_path('example_protein.pdb'), m)
    chains = IMP.atom.get_by_type(mp1, IMP.atom.CHAIN_TYPE)
    hs.append(IMP.atom.Hierarchy(chains[0]))
    rbs.append(IMP.atom.create_rigid_body(chains[0]))

for i, rb in enumerate(rbs[1:]):
    # the other 3 particles are all symmetric copies of the first
    IMP.core.Reference.setup_particle(rb, rbs[0])
    # the symmetry operation is rotation around the z axis
    tr = IMP.algebra.Transformation3D(
        IMP.algebra.get_rotation_about_axis(IMP.algebra.get_basis_vector_3d(2),
                                            2 * 3.14 / len(rbs) * (i + 1)),
        IMP.algebra.Vector3D(0, 0, 0))
    sm = IMP.core.TransformationSymmetry(tr)
    c = IMP.core.SingletonConstraint(sm, None, m, rb)
    m.add_score_state(c)

#crazy code block:
for rb in rbs:
    rb.update_members()
m.update()
for rb in rbs:
    rb.set_reference_frame(rb.get_reference_frame()) #this updates the members immediately too
m.update()
#end of the crazy code block

modelrmf = RMF.create_rmf_file('model.rmf')
IMP.rmf.add_hierarchies(modelrmf, hs)
IMP.rmf.save_frame(modelrmf)
@benmwebb benmwebb self-assigned this Aug 26, 2020
@benmwebb
Copy link
Member Author

The problem here is that TransformationSymmetry operates on the reference frame of the rigid body, and there is no guarantee that these are the same. The solution here is to use create_compatible_rigid_body() for all but the first rigid body. The resulting script looks like:

import IMP
import IMP.core
import IMP.atom
import IMP.container
import IMP.rmf
import RMF
import sys

IMP.setup_from_argv(sys.argv, "rigid bodies")

m = IMP.Model()
rbs = []
hs = []
for i in range(4):
    mp1 = IMP.atom.read_pdb(IMP.core.get_example_path('example_protein.pdb'), m)
    chains = IMP.atom.get_by_type(mp1, IMP.atom.CHAIN_TYPE)
    c = IMP.atom.Hierarchy(chains[0])
    if hs:
        rbs.append(IMP.atom.create_compatible_rigid_body(c, hs[0]))
    else:
        rbs.append(IMP.atom.create_rigid_body(c))
    hs.append(c)

for i, rb in enumerate(rbs[1:]):
    # the other 3 particles are all symmetric copies of the first
    IMP.core.Reference.setup_particle(rb, rbs[0])
    # the symmetry operation is rotation around the z axis
    tr = IMP.algebra.Transformation3D(
        IMP.algebra.get_rotation_about_axis(IMP.algebra.get_basis_vector_3d(2),
                                            2 * 3.14 / len(rbs) * (i + 1)),
        IMP.algebra.Vector3D(0, 0, 0))
    sm = IMP.core.TransformationSymmetry(tr)
    c = IMP.core.SingletonConstraint(sm, None, m, rb)
    m.add_score_state(c)

m.update()
modelrmf = RMF.create_rmf_file('model.rmf')
IMP.rmf.add_hierarchies(modelrmf, hs)
IMP.rmf.save_frame(modelrmf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant