Created
May 9, 2024 16:36
-
-
Save matteoferla/3f1c9739072770ed20900352634dc92e to your computer and use it in GitHub Desktop.
RDKit fix reference frame of molecule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am sure I have pasted this snippet somewhere, but I always forget where —so may be a duplicate. | |
wrong_ref: Chem.Mol = ... # the reference mol in former frame/location/crystal | |
right_ref: Chem.Mol = ... # the reference mol in desired frame | |
wrong: Chem.Mol = ... # the target | |
affine_matrix = AllChem.GetAlignmentTransform(wrong_ref, right_ref)[1] | |
AllChem.TransformConformer(wrong.GetConformer(), affine_matrix) # this is in place |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment