Last active
March 22, 2022 16:29
-
-
Save alisterburt/2ea6ad5b83299abfe03423f0e57fbb52 to your computer and use it in GitHub Desktop.
simple RELION 3.0 to RELION 3.1 data.star conversion
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 pandas as pd | |
| import starfile | |
| STAR_FILE = '/path/to/rln30_file.star' | |
| # starfile returns a pandas dataframe for a 'one-block' file | |
| # if you have multiple blocks then | |
| # you get a dictionary of {'block_name': pd.DataFrame) | |
| df = starfile.read(STAR_FILE) | |
| optics_df = pd.DataFrame( | |
| { | |
| 'rlnOpticsGroup': [1], | |
| 'rlnOpticsGroupName': ['my_optics_group'], | |
| 'rlnImagePixelSize': [1.35], | |
| 'rlnImageSize': [228], | |
| 'rlnImageDimensionality': [3], | |
| 'rlnVoltage': [300], | |
| 'rlnSphericalAberration': [2.7], | |
| } | |
| ) | |
| # add optics group column to rln30 data | |
| df['rlnOpticsGroup'] = 1 | |
| # set up and write out output | |
| output_data = { | |
| 'optics': optics_df, | |
| 'particles': df | |
| } | |
| starfile.write(output_data, '/path/to/file/out.star') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment