cryolike.util
cryolike.util.atomic_model
- class cryolike.util.atomic_model.AtomicModel(atomic_coordinates: ndarray[tuple[int, ...], dtype[floating]] | None = None, atom_radii: ndarray | float = 0.1, box_size: float | None = None)
Bases:
objectClass representing a particle model based on known atomic/protein residue positions.
- atomic_coordinates
Locations of the atoms in the model.
- Type:
np.ndarray
- atom_radii
Size of each atom in the model.
- Type:
np.ndarray
- pdb_file
The path to the file from which this model was loaded, if any. (Otherwise empty string.)
- Type:
- classmethod read_from_pdb(pdb_file: str, box_size: float | None = None, atom_radii: ndarray | float | None = 0.1, atom_selection: str | None = None, centering: bool = True, use_protein_residue_model: bool = True)
Build an atomic model from a PDB file.
- Parameters:
pdb_file (str) – Path to the PDB file to load
box_size (float | None, optional) – Size of the viewing box. If None (the default), a default box size defined in the AtomicModel constructor will be used.
atom_radii (Union[np.ndarray, float], optional) – Radii of the atoms, either as a per-atom array of values or a single value for all atoms. Defaults to 0.1.
atom_selection (str | None, optional) – Which atoms to choose from the model. If using a protein residue model, will be set automatically. Otherwise, it should be a valid index of the PDB file’s Topology. Defaults to None.
centering (bool, optional) – Whether to center the coordinates to a zero mean. Defaults to True.
use_protein_residue_model (bool, optional) – If True, will use the ‘name CA’ atom selection and read atomic radii from known amino acid sizes. Defaults to True.
- Returns:
Instantiated atomic model from the PDB file.
- Return type:
cryolike.util.device_handling
- cryolike.util.device_handling.check_nufft_installed(dev: device) None
Check for the availability of NUFFT libraries.
- cryolike.util.device_handling.get_device(dev: str | device | None, verbose: bool = False) device
Resolve user’s requested device.
- Parameters:
dev (str | device | None) – Requested device. If a torch.device, it will be returned unchanged. If None, will default to CUDA:0 if CUDA is available, or else will use cpu. String values are any recognized by torch, i.e. cpu, cuda with or without ordinal, or other device types. We do not attempt to ensure the requested device is actually available on the system.
verbose (bool, optional) – If True, function will describe the request and response. Defaults to False.
- Returns:
A torch.device initialized as requested.
- Return type:
device
cryolike.util.enums
- class cryolike.util.enums.AtomShape(value)
Bases:
EnumType of topology for modelling atomic density
- class cryolike.util.enums.Precision(value)
Bases:
EnumPrecision definitions for requests.
- get_dtypes(default: Precision) tuple[torch.dtype, torch.dtype, torch.dtype]
Interprets this Precision to return the desired dtypes.
- Parameters:
default (Precision) – Precision level to use if DEFAULT is set.
- Returns:
Torch float-type, complex-type, and int-type
- Return type:
tuple[dtype, dtype, dtype]
for the requested precision.
- set_epsilon(requested: float, default: Precision | None = None) float
Return the desired epsilon value, or the machine precision of the chosen dtype, whichever is larger.
- Parameters:
- Returns:
- If the current precision allows the requested value of epsilon, that will
be returned unmodified. If the requested epsilon is too small for the current precision level (e.g. caller requests epsilon of 1e-10 for single-precision, where machine precision is only 1e-6) then the finest value of epsilon supported by machine precision of this dtype will be returned instead.
- Return type: