PyRosetta (13) Constraint Generator

PyRosetta (13): Constraint Generator

Introduction

Constraint functions

Harmonic: HARMONIC

A harmonic constraint uses a simple parabola (a squared function) to apply a penalty.

$ E=(\frac{x−x_0}{\sigma})^2 $

where $ \sigma $is a force constant, $ x $ is the measured value, and $ x_0 $ is the ideal value.

![](PyRosetta (13) Constraint Generator Movers/1756802935061-72f8eb91-7309-4f80-81b3-c20f109b7a73.png)

Bounded (Flat harmonic: FLAT_HARMONIC)

A bounded constraint defines a flat-bottomed energy well. It has two key parameters: a minimum bound $ lb = x_0 - t $ and a maximum bound $ ub = x_0 + t $.

Similar to HARMONIC, but is 0 (“flat”) around $ \pm $tolerance (t).

$ E= (\frac{x−x_0}{\sigma})^2 - (\frac{t}{\sigma})^2, \ x\ge x_0 + t \ \text{or} \ x\le x_0 -t $

$ E = 0, \ x_0 - t \le x \le x_0 + t $

![](PyRosetta (13) Constraint Generator Movers/1756802945356-1aba79e7-063a-4e4a-87de-818d86d4d6e0-1757296044272-5.png)

If the measured value $ x $ is within the bounds ($ lb\le x\le ub\ $), the energy penalty is 0.

If the measured value is outside the bounds $ x<lb $ or $ x>ub $, a penalty is applied that increases with the deviation, often harmonically.

Behavior: Instead of a “spring”, it creates a “box” or “well”. Any conformation within the specified range is considered equally good and incurs no penalty. Only when the conformation leaves this range is it penalized.

Best for situations where we want to allow some flexibility while preventing major structural excursions.

Ambiguous Constraints

For certain amino acids, the position of an atom can be ambiguous due to the symmetry of the sidechain or because the sidechain can adopt different rotamers.

How ambiguous constraints work:

  • In the sidechains of these three amino acids, certain atoms can swap positions. For example, in asparagine, the oxygen (OD1) and nitrogen (ND2) can swap places.
  • During a minimization step, the constraint would tether the atom to whichever of its ambiguous reference positions is currently closer. This allows the sidechain to flip between rotamers without incurring a large energy penalty from the constraint.

CoordinateConstraintGenerator

Instantiation of CoordinateConstraintGenerator

1
coord_constraint_gen = pyrosetta.rosetta.protocols.constraint_generator.CoordinateConstraintGenerator()

Example of CoordinateConstraintGenerator

1
coord_constraint_gen = pyrosetta.rosetta.protocols.constraint_generator.CoordinateConstraintGenerator()

Setup Constrants

WARNING: It is recomended to add a virtual root before adding constraints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
true_selector = pyrosetta.rosetta.core.select.residue_selector.TrueResidueSelector() # Select all residues

# Construct the CoordinateConstraintGenerator
coord_constraint_gen = pyrosetta.rosetta.protocols.constraint_generator.CoordinateConstraintGenerator()
coord_constraint_gen.set_id("contrain_all_backbone_atoms!")
coord_constraint_gen.set_ambiguous_hnq(False)
coord_constraint_gen.set_bounded(False)
coord_constraint_gen.set_sidechain(False)
coord_constraint_gen.set_sd(1.0)
coord_constraint_gen.set_ca_only(False)
coord_constraint_gen.set_residue_selector(true_selector)

# Apply the CoordinateConstraintGenerator using the AddConstraints mover
add_constraints = pyrosetta.rosetta.protocols.constraint_generator.AddConstraints()
add_constraints.add_generator(coord_constraint_gen)
add_constraints.apply(pose)

Remove Constraints

Remove constraints before direct (manual) pose manipulation.

1
2
3
4

remove_constraints = pyrosetta.rosetta.protocols.constraint_generator.RemoveConstraints()
remove_constraints.add_generator(coord_constraint_gen)
remove_constraints.apply(pose)

Configuration Options of CoordinateConstraintGenerator

Set ID for CoordinateConstraintGenerator

1
2
coord_constraint_gen.set_id("contrain_all_backbone_atoms!") 
# Set the identifier of this generator

set_ambiguous_hnq

set_ambiguous_hnq is a hardcoded shortcut to enable/disable tracking of both possible symmetrical positions for ambiguous-hydrgen-related atoms in Histone, Asparagine and Glutamine.

If set to false, the constraint generator will apply a standard, non-ambiguous constraint to the specified atom positions.

1
2
coord_constraint_gen.set_ambiguous_hnq(False) 
# Histone, Asparagine, and Glutamine

NOTICE: ambiguous atoms also exists in Asparatate (D), Glutamate (E), Phenyalanine (F), tyrosine (Y). D and E are handled by Rosetta Atom Types (OOC). And the built-in packer explores both symmetrical orientations of the ring. To specify customized constraints, use**AmbiguousConstraint**in a constraint file.

Switch between bounded or harmonic constraints

whether to use harmonic (false) or bounded (true) constraints

1
2
3
coord_constraint_gen.set_bounded(true)
# If set bounded true:
coord_constraint_gen.set_bounded_width(0.5)

Constraint all / constraint backbone

Constrain all heavy atoms (false), or only backbone heavy atoms (true)

1
coord_constraint_gen.set_sidechain(False)

Standard deviation RMSD constraints

The strength/deviation of the constraints to use.

1
2
3
4
5
'''
Sets a standard deviation of contrained atoms to (an arbitrary) 1.0 Angstroms RMSD.
Set higher or lower for different results.
'''
coord_constraint_gen.set_sd(1.0)

CA only

Only CA atoms are constrained.

1
coord_constraint_gen.set_ca_only(False)

Apply to a Selector object

1
coord_constraint_gen.set_residue_selector(my_selector)

AddCompositionConstraintMover from XML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
add_composition_constraint = pyrosetta.rosetta.protocols.aa_composition.AddCompositionConstraintMover()
add_composition_constraint.create_constraint_from_file_contents("""
PENALTY_DEFINITION
OR_PROPERTIES AROMATIC ALIPHATIC
NOT_TYPE LEU
FRACT_DELTA_START -0.05
FRACT_DELTA_END 0.05
PENALTIES 1 0 1 # The above two lines mean that if we're 5% below or 5% above the desired content, we get a 1-point penalty.
FRACTION 0.4 # Forty percent aromatic or aliphatic, but not leucine
BEFORE_FUNCTION CONSTANT
AFTER_FUNCTION CONSTANT
END_PENALTY_DEFINITION

PENALTY_DEFINITION
TYPE LEU
DELTA_START -1
DELTA_END 1
PENALTIES 1 0 1
FRACTION 0.05 # Five percent leucine
BEFORE_FUNCTION CONSTANT
AFTER_FUNCTION CONSTANT
END_PENALTY_DEFINITION
""")
add_composition_constraint.add_residue_selector(chain_A)
add_composition_constraint.apply(pose)

AddHelixSequenceConstraintsMover

Apply the AddHelixSequenceConstraints mover, which utilizes the aa_composition scoreterm. By default, this mover adds five types of sequence constraints to the designable residues in each alpha helix in the pose. Any of these behaviours may be disabled or modified by invoking advanced options, but no advanced options need be set in most cases. The five types of sequence constraints are:

  1. A strong sequence constraint requiring at least two negatively-charged residues in the first (N-terminal) three residues of each alpha-helix.
  2. A strong sequence constraint requiring at least two positively-charged residues in the last (C-terminal) three residues of each alpha-helix.
  3. A weak but strongly ramping sequence constraint penalizing helix-disfavoring residue types (by default, Asn, Asp, Ser, Gly, Thr, and Val) throughout each helix. (A single such residue is sometimes tolerated, but the penalty for having more than one residue in this category increases quadratically with the count of helix-disfavouring residues.)
  4. A weak sequence constraint coaxing the helix to have 10% alanine. Because this constraint is weak, deviations from this value are tolerated, but this should prevent an excessive abundance of alanine residues.
  5. A weak sequence constraint coaxing the helix to have at least 25% hydrophobic content. This constraint is also weak, so slightly less hydrophobic helices will be tolerated to some degree. Note that alanine is not considered to be “hydrophobic” within Rosetta.
1
2
3
add_helix_sequence_constraints = pyrosetta.rosetta.protocols.aa_composition.AddHelixSequenceConstraintsMover()
add_helix_sequence_constraints.set_residue_selector(chain_A)
add_helix_sequence_constraints.apply(my_pose)

AddNetChargeConstraintMover

Apply the AddNetChargeConstraintMover mover, which utilizes the netcharge scoreterm.

We require that the net charge in selected region must be exactly 0.

1
2
3
4
5
6
7
8
9
10
add_net_charge_constraint = pyrosetta.rosetta.protocols.aa_composition.AddNetChargeConstraintMover()
add_net_charge_constraint.create_constraint_from_file_contents("""
DESIRED_CHARGE 0 #Desired net charge is zero.
PENALTIES_CHARGE_RANGE -1 1 #Penalties are listed in the observed net charge range of -1 to +1.
PENALTIES 1 0 1 #The penalties are 1 for an observed charge of -1, 0 for an observed charge of 0, and 1 for an observed charge of +1.
BEFORE_FUNCTION QUADRATIC #Ramp quadratically for observed net charges of -2 or less.
AFTER_FUNCTION QUADRATIC #Ramp quadratically for observed net charges of +2 or greater.
""")
add_net_charge_constraint.add_residue_selector(chain_A)
add_net_charge_constraint.apply(my_pose)

Reference

https://zhuanlan.zhihu.com/p/58897635

CoordinateConstraintGenerator

  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2024-2025 Michael Lau
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信