constraintsΒΆ

Auxiliary functions for applying energy restraints (PyRosetta Constraints) to Pose objects.

FunctionsΒΆ

make_atom_pair_constraint(pose, res_num_1, res_num_2)

Create an AtomPairConstraint between the alpha carbons of two residues in a Pose.

add_intrachain_constraints(pose, constraint_targets, ...)

Add constraints between desired residues of the same domain to a constraint set.

add_contacts_constraints(pose, contacts, constraint_set)

Add constraints between residue regions whose relative position must remain conserved.

apply_constraints(pose, cst_targets[, contacts, ...])

Apply energy constraints to desired regions of a Pose object.

apply_pae_constraints(pose, pae_filepath, plddt_targets)

Apply energy constraints to a AlphaFold Pose based on its PAE matrix.

Module ContentsΒΆ

ensemblify.modelling.constraints.make_atom_pair_constraint(pose, res_num_1, res_num_2, stdev=10.0, tolerance=None)ΒΆ

Create an AtomPairConstraint between the alpha carbons of two residues in a Pose.

Parameters:
  • pose (pyrosetta.rosetta.core.pose.Pose) – Target Pose object for constraints. Used to extract residue ID and coordinates.

  • res_num_1 (int) – The first residue number.

  • res_num_2 (int) – The second residue number.

  • stdev (float, optional) – Standard deviation value to use in constraints. Defaults to 10.0.

  • tolerance (float, optional) – Tolerance value to use in constraints. Defaults to None.

Returns:

The created AtomPairConstraint object.

Return type:

pyrosetta.rosetta.core.scoring.constraints.AtomPairConstraint

ensemblify.modelling.constraints.add_intrachain_constraints(pose, constraint_targets, constraint_set, stdev=10.0, tolerance=None)ΒΆ

Add constraints between desired residues of the same domain to a constraint set.

Parameters:
  • pose (pyrosetta.rosetta.core.pose.Pose) – Target Pose object for constraints. Only used to extract residue ID and coordinates.

  • constraint_targets (tuple[tuple[int,int],...]) – Residues between which AtomPairConstraints will be added.

  • constraint_set (pyrosetta.rosetta.core.scoring.constraints.ConstraintSet) – Set of constraints to later be applied to Pose.

  • stdev (float, optional) – Standard deviation value to use in constraints. Defaults to 10.0.

  • tolerance (float, optional) – Tolerance value to use in constraints. Defaults to None.

Returns:

Updated ConstraintSet object, with added intrachain constraints.

Return type:

pyrosetta.rosetta.core.scoring.constraints.ConstraintSet

ensemblify.modelling.constraints.add_contacts_constraints(pose, contacts, constraint_set, stdev=10.0, tolerance=None)ΒΆ

Add constraints between residue regions whose relative position must remain conserved.

This would include, for example, dimerization sites or long range intrachain folding. The word β€˜contacts’ is used here for convenience, these could be any two regions whose relative position should be conserved, even if they are far apart in the Pose.

Parameters:
  • pose (pyrosetta.rosetta.core.pose.Pose) – Target Pose object for constraints.

  • contacts (tuple[tuple[tuple[str,tuple[int,int]],tuple[str,tuple[int,int]]],...]) – Residue ranges of regions whose relative position should be conserved. If None, no constraints will be added.

  • constraint_set (pyrosetta.rosetta.core.scoring.constraints.ConstraintSet) – Set of constraints to later be applied to Pose.

  • stdev (float, optional) – Standard deviation value to use in constraints. Defaults to 10.0.

  • tolerance (float, optional) – Tolerance value to use in constraints (if applicable). Defaults to None.

Returns:

Updated ConstraintSet, with added relative position constraints.

Return type:

pyrosetta.rosetta.core.scoring.constraints.ConstraintSet

ensemblify.modelling.constraints.apply_constraints(pose, cst_targets, contacts=None, stdev=10.0, tolerance=0.001)ΒΆ

Apply energy constraints to desired regions of a Pose object.

This function is incompatible with the apply_pae_constraints function, and they should not be used on the same Pose. The word β€˜contacts’ is used here for convenience, these could be any two regions whose relative position should be conserved, even if they are far apart in the Pose.

Parameters:
  • pose (pyrosetta.rosetta.core.pose.Pose) – Target Pose object for constraints. It is modified in place.

  • cst_targets (tuple[tuple[int,int],...]) – Residue ranges defining regions that make up folded protein domains. AtomPairConstraints will be applied between constituting residues.

  • contacts (tuple[tuple[tuple[str,tuple[int,int]],tuple[str,tuple[int,int]]],...]) – Pairs of residue ranges defining regions whose relative position should be conserved. AtomPairConstraints will be applied between residues belonging to different regions. Defaults to None.

  • stdev (float, optional) – Standard deviation value to use in constraints. Defaults to 10.0.

  • tolerance (float, optional) – Tolerance value to use in constraints. Defaults to 0.001.

ensemblify.modelling.constraints.apply_pae_constraints(pose, pae_filepath, plddt_targets, cutoff=10.0, flatten_cutoff=10.0, flatten_value=10.0, weight=1.0, tolerance=None, adjacency_threshold=8, plddt_scaling_factor=1.0)ΒΆ

Apply energy constraints to a AlphaFold Pose based on its PAE matrix.

The strength of the constraints scales with the value of the predicted aligned error for that residue pair. After scaling with PAE value, applied constraints are made weaker when one of the participating residues has low pLDDT. This function is incompatible with the apply_constraints function, and they should not be used on the same Pose.

Adapted from:

https://github.com/matteoferla/pyrosetta-help/blob/main/pyrosetta_help/alphafold/constraints.py

Parameters:
  • pose (pyrosetta.rosetta.core.pose.Pose) – The Pose constraints will be applied to.

  • pae_filepath (str) – Path to the PAE matrix .json file.

  • plddt_targets (dict) – Mapping of each chain to the residue numbers that will be sampled (pdb numbering), already filtered for residues with pLDDT below a threshold.

  • cutoff (float) – Only consider PAE values below this number (low error).

  • flatten_cutoff (float) – Any PAE values below this value will be changed to match flatten_value.

  • flatten_value (float) – Any PAE values below flatten_cutoff will be changed to match this value.

  • weight (float) – Along with the error value, determines the strength of the applied AtomPairConstraints.

  • tolerance (float, optional) – Defines the tolerance of the FlatHarmonicFunction of AtomPairConstraints created from the PAE matrix. Defaults to None.

  • adjacency_threshold (int) – How far away two residues need to be to consider their PAE value. Neighbours are skipped as PAE is best used for determining between domain or between chain confidence.

  • plddt_scaling_factor (float) – Any constraints setup between residues where either of them has a low pLDDT will be scaled by multiplying its weight by this factor. The higher this value the weaker those constraints will be.

Returns:

List of Pose residue numbers that participate in created constraints.

Return type:

list