deepfold.relax package

Submodules

deepfold.relax.amber_minimize module

Restrained Amber Minimization of a structure.

deepfold.relax.amber_minimize.clean_protein(prot: Protein, checks: bool = True)

Adds missing atoms to Protein instance.

Parameters:
  • prot – A protein.Protein instance.

  • checks – A bool specifying whether to add additional checks to the cleaning process.

Returns:

A string of the cleaned protein.

Return type:

pdb_string

deepfold.relax.amber_minimize.find_violations(prot_np: Protein)

Analyzes a protein and returns structural violation information.

Parameters:

prot_np – A protein.

Returns:

A dict of structure components with structural violations. violation_metrics: A dict of violation metrics.

Return type:

violations

deepfold.relax.amber_minimize.get_violation_metrics(prot: Protein)

Computes violation and alignment metrics.

deepfold.relax.amber_minimize.make_atom14_positions(prot)

Constructs denser atom positions (14 dimensions instead of 37).

deepfold.relax.amber_minimize.run_pipeline(prot: Protein, stiffness: float, use_gpu: bool, max_outer_iterations: int = 1, place_hydrogens_every_iteration: bool = True, max_iterations: int = 0, tolerance: float = 2.39, restraint_set: str = 'non_hydrogen', max_attempts: int = 100, checks: bool = True, exclude_residues: Sequence[int] | None = None)

Run iterative amber relax.

Successive relax iterations are performed until all violations have been resolved. Each iteration involves a restrained Amber minimization, with restraint exclusions determined by violation-participating residues.

Parameters:
  • prot – A protein to be relaxed.

  • stiffness – kcal/mol A**2, the restraint stiffness.

  • use_gpu – Whether to run on GPU

  • max_outer_iterations – The maximum number of iterative minimization.

  • place_hydrogens_every_iteration – Whether hydrogens are re-initialized prior to every minimization.

  • max_iterations – An int specifying the maximum number of L-BFGS steps per relax iteration. A value of 0 specifies no limit.

  • tolerance – kcal/mol, the energy tolerance of L-BFGS. The default value is the OpenMM default.

  • restraint_set – The set of atoms to restrain.

  • max_attempts – The maximum number of minimization attempts per iteration.

  • checks – Whether to perform cleaning checks.

  • exclude_residues – An optional list of zero-indexed residues to exclude from restraints.

Returns:

A dictionary of output values.

Return type:

out

deepfold.relax.amber_minimize.will_restrain(atom: Atom, rset: str) bool

Returns True if the atom will be restrained by the given restraint set.

deepfold.relax.cleanup module

Cleans up a PDB file using pdbfixer in preparation for OpenMM simulations.

fix_pdb uses a third-party tool. We also support fixing some additional edge cases like removing chains of length one (see clean_structure).

deepfold.relax.cleanup.clean_structure(pdb_structure, alterations_info)

Applies additional fixes to an OpenMM structure, to handle edge cases.

Parameters:
  • pdb_structure – An OpenMM structure to modify and fix.

  • alterations_info – A dict that will store details of changes made.

deepfold.relax.cleanup.fix_pdb(pdbfile, alterations_info)

Apply pdbfixer to the contents of a PDB file; return a PDB string result.

  1. Replaces nonstandard residues.

  2. Removes heterogens (non protein residues) including water.

  3. Adds missing residues and missing atoms within existing residues.

  4. Adds hydrogens assuming pH=7.0.

  5. KeepIds is currently true, so the fixer must keep the existing chain and residue identifiers. This will fail for some files in wider PDB that have invalid IDs.

Parameters:
  • pdbfile – Input PDB file handle.

  • alterations_info – A dict that will store details of changes made.

Returns:

A PDB string representing the fixed structure.

deepfold.relax.relax module

Amber relaxation.

class deepfold.relax.relax.AmberRelaxation(*, max_iterations: int, tolerance: float, stiffness: float, exclude_residues: Sequence[int], max_outer_iterations: int, use_gpu: bool)

Bases: object

Amber relaxation.

process(*, prot: Protein) Tuple[str, Dict[str, Any], ndarray]

Runs Amber relax on a prediction, adds hydrogens, returns PDB string.

deepfold.relax.utils module

Utils for minimization.

deepfold.relax.utils.assert_equal_nonterminal_atom_types(atom_mask: ndarray, ref_atom_mask: ndarray)

Checks that pre- and post-minimized proteins have same atom set.

deepfold.relax.utils.overwrite_b_factors(pdb_str: str, bfactors: ndarray) str

Overwrites the B-factors in pdb_str with contents of bfactors array.

Parameters:
  • pdb_str – An input PDB string.

  • bfactors – A numpy array with shape [1, n_residues, 37]. We assume that the B-factors are per residue; i.e. that the nonzero entries are identical in [0, i, :].

Returns:

A new PDB string with the B-factors replaced.

deepfold.relax.utils.overwrite_pdb_coordinates(pdb_str: str, pos) str

Module contents