Parameter-setting example

CryoLike requires setting various parameters for image conversion, template creation, and likelihood computation. This example demontrates how to set these parameters using a script, which will write the collection of parameters to the file system for reuse in other functions. The parameters are collected and held in an cryolike.metadata.image_descriptor.ImageDescriptor object.

The imaging parameters include the number of voxels and voxel size in the template model, the precision for computations, a description of the angles from which to view the template model and the number of inplane rotations to consider for each projection. For PDB models, we also accept the atomic radii and selection of atoms to include. These are optional; if not specified, amino-acid-specific defaults will be used, and all atoms in the model will be included.

Currently, the user is advised to make sure the number of voxels and voxel size agrees with the cryo-EM data to avoid inconsistent results.

import os
from numpy import pi

from cryolike import ImageDescriptor

verbose = True

if verbose:
    print("Setting parameters...")
n_voxels = 132
voxel_size = 1.346
precision = 'single' # 'single' or 'double'
viewing_distance = 8.0 / (4.0 * pi)
n_inplanes = 256
# atom_radii = 3.0
atom_selection = "name CA"
folder_output = './output/templates/'
os.makedirs(folder_output, exist_ok=True)

image_parameters_filename = os.path.join(folder_output, "parameters.npz")
image_parameters = ImageDescriptor.from_individual_values(
    n_pixels = n_voxels,
    pixel_size = voxel_size,
    resolution_factor = 1.0,
    precision = precision,
    viewing_distance = viewing_distance,
    n_inplanes = n_inplanes,
    use_protein_residue_model = True,
    atom_shape = 'hard-sphere' # or 'gaussian'
)
if verbose:
    image_parameters.print()
image_parameters.save(image_parameters_filename)