sampling_utils¶
Auxiliary functions for setting up the conformational sampling process.
Functions¶
|
Setup logging handlers and files for PyRosetta sampling and Ray. |
|
Update the parameters dictionary before sampling. |
|
Create initial Pose for sampling and apply any required constraints. |
|
Sample dihedral angles from a database into target regions of a given structure. |
Module Contents¶
- ensemblify.generation.ensemble_utils.sampling_utils.setup_sampling_logging(sampling_log)¶
Setup logging handlers and files for PyRosetta sampling and Ray.
- Parameters:
sampling_log (
str) – Path to sampling .log file.- Returns:
- logger (logging.Logger):
The Logger object associated with the sampling .log file
- ray_log (str):
Filepath to .log file with Ray log messages.
- pyrosetta_log (str):
Filepath to .log file with PyRosetta log messages.
- Return type:
tuple[logging.Logger,str,str]
- ensemblify.generation.ensemble_utils.sampling_utils.setup_sampling_parameters(parameters_file)¶
Update the parameters dictionary before sampling.
In the ‘targets’ parameter, change a target from e.g. [1,54] to (range(1,55)). If using an AlphaFold model as a starting structure, keep in the sampling ranges only regions of at least a certain contiguous size where each residue’s pLDDT is below a threshold. Targets, secondary structure biases and contacts are also updated to tuples instead of lists.
- Parameters:
parameters_file (
str) – Path to parameters file following the Ensemblify template.- Returns:
The updated params dictionary.
- Return type:
dict
- ensemblify.generation.ensemble_utils.sampling_utils.setup_sampling_initial_pose(params, sampling_log)¶
Create initial Pose for sampling and apply any required constraints.
Constraints applied to the pose are stored in a constraints.cst file stored in the same directory as the sampling_log file.
- Parameters:
params (
dict) – Parameters following the Ensemblify template.sampling_log (
str) – Path to the sampling .log file.
- Returns:
Object to be used as the starting structure for the sampling process.
- Return type:
pyrosetta.rosetta.core.pose.Pose
- ensemblify.generation.ensemble_utils.sampling_utils.sample_pdb(ppose, databases, targets, output_path, job_name, decoy_num='', log_file=None, ss_bias=None, variance=0.1, sampler_params={'MC': {'temperature': 200, 'max_loops': 200}}, scorefxn_id='score0', scorefxn_weight=1.0, minimizer_id='dfpmin_armijo_nonmonotone', minimizer_tolerance=0.001, minimizer_maxiters=5000, minimizer_finalcycles=5, cst_weight=1, cstviolation_threshold=0.015, cstviolation_maxres=20)¶
Sample dihedral angles from a database into target regions of a given structure.
- Parameters:
ppose (
pyrosetta.distributed.packed_pose.core.PackedPose) – Reference to the initial structure.databases (
dict[str,dict[str,pd.DataFrame]]) – Reference to the databases dictionary.targets (
dict[str,tuple[tuple[str,tuple[int,...],str,str]]]) – Dictionary detailing the target regions for sampling in each chain.output_path (
str) – Path to directory where sampled structures will be written to.job_name (
str) – Prefix identifier for generated structures.decoy_num (
str, optional) – Identifier to differentiate between different decoys of the same batch in a multiprocessing context. Defaults to ‘’.log_file (
str, optional) – Path to the PyRosetta .log file. Defaults to ‘pyrosetta.log’ in current working directory.ss_bias (
tuple[tuple[tuple[str,tuple[int,int],str],...],int], optional) – Secondary Structure Bias with the desired percentage of total structures to respect this bias. Defaults to None.variance (
float, optional) – New dihedral angle values inserted into sampling regions are sampled from a Gaussian distribution centered on the value found in database and percentage variance equal to this value. Defaults to 0.10 (10%).sampler_params (
dict[str,dict[str,int]], optional) – Parameters for the used sampler, assumes MonteCarloSampler is used. Defaults to {‘MC’:{‘temperature’:200,’max_loops’:200}}.scorefxn_id (
str, optional) – PyRosetta ScoreFunction identifier. Must pertain to a .wst weights file present in /…/pyrosetta/database/scoring/weights/ . Defaults to ‘score0’.scorefxn_weight (
float, optional) – Weight for the repulsive Van der Waals term in the ScoreFunction. Will only have an effect if the ScoreFunction has a repulsive Van der Waals term. Defaults to 1.0.minimizer_id (
str, optional) – PyRosetta minimization algorithm identifier used in MinMover. Defaults to ‘dfpmin_armijo_nonmonotone’.minimizer_tolerance (
float, optional) – Tolerance value for the PyRosetta MinMover object. Defaults to 0.001.minimizer_maxiters (
int, optional) – Maximum iterations value for the PyRosetta MinMover object. Defaults to 5000.minimizer_finalcycles (
int, optional) – Number of times to apply the MinMover to our final structure. Defaults to 5.cst_weight (
int, optional) – Weight of the AtomPairConstraint term in the ScoreFunction. Defaults to 1.cstviolation_threshold (
float, optional) – Any residue with AtomPairConstraint score term value above this threshold is considered in violation of the applied constraints. Defaults to 0.015.cstviolation_maxres (
int, optional) – Number of residues allowed to be above the constraint violation threshold. Defaults to 20.
- Returns:
Path to the sampled .pdb structure. Only written and returned if the sampled structure is valid (does not violate the applied constraints). Otherwise, return None.
- Return type:
str | None