Skip to content

Commit

Permalink
add file creating and overwrite option for starfile writer
Browse files Browse the repository at this point in the history
  • Loading branch information
DSilva27 committed Sep 17, 2024
1 parent 9fd557a commit 4e487ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cryojax/data/_relion/_starfile_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def write_starfile_with_particle_parameters(
relion_particle_stack: RelionParticleStack,
filename: str | pathlib.Path,
mrc_batch_size: Optional[int] = None,
overwrite: bool = False,
) -> None:
"""Generate a STAR file from a RelionParticleStack object.
Expand All @@ -45,8 +46,19 @@ def write_starfile_with_particle_parameters(
- `mrc_batch_size`:
The number of images to write to each MRC file. If `None`, the number of
images in the `RelionParticleStack` is used.
- `overwrite`:
Whether to overwrite the STAR file if it already exists.
"""

path_to_starfile = os.path.dirname(filename)
if not os.path.exists(path_to_starfile):
os.makedirs(path_to_starfile)

if not overwrite and os.path.exists(filename):
raise FileExistsError(
f"Overwrite was set to False, but STAR file {filename} already exists."
)

n_images = relion_particle_stack.pose.offset_x_in_angstroms.shape[0]

if mrc_batch_size is None:
Expand Down

0 comments on commit 4e487ca

Please sign in to comment.