Last active
February 11, 2023 14:16
-
-
Save alisterburt/83496cae0cb852fcd149902b53a8eefc to your computer and use it in GitHub Desktop.
RELION 3.0 particle pose from STAR file
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
| import starfile | |
| from scipy.spatial.transform import Rotation as R | |
| particle_star_file = 'hiv/01_10.00Apx_particles.star' | |
| df = starfile.read(particle_star_file) | |
| # get necessary info from dataframe | |
| xyz = df[['rlnCoordinateX', 'rlnCoordinateY', 'rlnCoordinateZ']].to_numpy() # (n, 3) | |
| shifts = df[['rlnOriginX', 'rlnOriginY', 'rlnOriginZ']].to_numpy() # (n, 3) | |
| euler_angles = df[['rlnAngleRot', 'rlnAngleTilt', 'rlnAnglePsi']].to_numpy() # (n, 3) | |
| # Get absolute position and orientation | |
| particle_positions = xyz - shifts | |
| rotation_matrices = R.from_euler( | |
| seq='ZYZ', angles=euler_angles, degrees=True | |
| ).inv().as_matrix() # (n, 3, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment