cryodrgn icon indicating copy to clipboard operation
cryodrgn copied to clipboard

Issue with parse_pose_star

Open mbelouso opened this issue 1 year ago • 1 comments

This appears to be an intermittent issue. I was helping a collegue get cryodrgn running and when I ran the command:

cryodrgn parse_pose_star run_data.star -o poses.pkl

It produced the following error:

(INFO) (parse_pose_star.py) (22-Nov-24 15:59:57) 221564 particles Traceback (most recent call last): File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3802, in get_loc return self._engine.get_loc(casted_key) File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: '2'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/mbelouso/anaconda3/envs/cryodrgn/bin/cryodrgn", line 8, in sys.exit(main_commands()) File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/command_line.py", line 81, in main_commands _get_commands( File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/command_line.py", line 76, in _get_commands args.func(args) File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/commands/parse_pose_star.py", line 55, in main apix, resolution = starfile.apix, starfile.resolution File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/starfile.py", line 277, in apix return self.get_optics_values(fieldname="_rlnImagePixelSize", dtype=np.float32) File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/starfile.py", line 208, in get_optics_values [ File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/cryodrgn/starfile.py", line 209, in self.data_optics.loc[g, fieldname] File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/pandas/core/indexing.py", line 1066, in getitem return self.obj._get_value(*key, takeable=self._takeable) File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/pandas/core/frame.py", line 3924, in _get_value row = self.index.get_loc(index) File "/home/mbelouso/anaconda3/envs/cryodrgn/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3804, in get_loc raise KeyError(key) from err KeyError: '2'

The STAR file culprit can be found here, but to my eyes I can't figure out what the issue is with the input:

https://drive.google.com/drive/folders/1N9iW9_FmWL8yJItNnfdxv_974vAAIPm1?usp=sharing

I have confirmed that in general this works on other STAR files on the same compute platform.

thanks so much guys!

cheers

matt B

mbelouso avatar Nov 22 '24 05:11 mbelouso

Hi Matt,

I believe this error comes from mismatches in the _rlnOpticsGroup numbers. The issue is resolved by setting rlnOpticsGroup to 1 for all particles.

The easiest way to do this without a text editor might be to use relion_image_handler i.e. relion_star_handler --i run_data.star --o run_data_mod.star --operate rlnOpticsGroup --set_to 1 --i_tablename particles --ignore_optics Since rlnOpticsGroup is in both the particle and optics data blocks, you get an error if you don't ignore the optics table, so you'll need to add the optics table back after running this command.

ryanfeathers avatar Jan 03 '25 19:01 ryanfeathers