PyRosetta Model

A PyRosetta-based oracle model for protein structure prediction and energy scoring. This model uses the Rosetta molecular modeling suite to predict protein properties based on structure and energy calculations.

class alf_tools.models.pyrosetta.PyRosetta(pdb_path, initial_relax_repeats=20, repeats_per_prediction=1, average_fn_over_repeats='mean', alphabet='ARNDCQEGHILKMFPSTWYV', seed=0)[source]

Bases: BaseModel

Physics-based protein fitness scorer using PyRosetta energy functions.

featurise(inputs)[source]

Featurisation is not implemented for this model.

Raises:

NotImplementedError – Featurisation is not implemented for this model.

Return type:

Any

get_training_summary_metrics()[source]

Training summary metrics are not implemented for this model.

Raises:

NotImplementedError – Training metrics are not implemented for this model.

Return type:

Dict[str, Union[float, int, number]]

mutate_and_relax(sequence)[source]

Mutates the wild-type structure to the given sequence and relaxes the structure.

Parameters:

sequence (str) – Sequence to mutate the wild-type structure to. Must have the same length as the wild-type sequence (only point substitutions are supported; insertions/deletions are not).

Return type:

float

Returns:

Score of the relaxed structure.

Raises:

ValueError – If sequence length differs from the wild-type sequence.

predict(candidate_points)[source]

Predict fitness scores for the given candidate points.

Procedure for scoring a candidate:
  • Mutate the wild-type structure to the given sequence

  • Relax the structure

  • Score the structure

  • Return the score

Parameters:

candidate_points (List[Candidate]) – List of candidate points to predict.

Return type:

Predictions

Returns:

Predictions containing fitness scores.

Raises:

ValueError – If average_fn_over_repeats is not “mean” or “median”.

relax_local(pose, rosetta_residue_num, distance_threshold=8.0)[source]
Locally minimises a structure around a given residue by moving both the backbone

and side-chains.

Parameters:
  • pose (Pose) – Input Pose object

  • rosetta_residue_num (List[int]) – List of indices of residue in Pose around which miniisation should be performed. NB: This is likely to be different that the residue number in the PDB.

  • distance_threshold (float) – The radius within which a residue must be to the residue of interest for it to be indcluded in the minimisation. Value in Angstroms.

Return type:

Pose

Returns:

Locally minimised Pose object.

relax_structure(pose, n_repeats=5)[source]
Relaxes a Pose object using the FastRelax protocol. This involves rounds of

side-chain packing and whole-atom-minimisations. For more detail on the protocol, refer to the Rosetta documentation. Saves the minimised structure as a PDB file.

Parameters:
  • pose (Pose) – pose object to relax

  • n_repeats (int) – Number of pack-minimise rounds to perform. Larger values will significantly slow down the protocol.

Return type:

Tuple[Pose, float]

Returns:

Tuple of (minimised Pose, time taken to perform the relaxation).

sample(*args, **kwargs)[source]

Sampling is not implemented for this model.

Raises:

NotImplementedError – Sampling is not implemented for this model.

Return type:

List[Candidate]

train(train_data, val_data)[source]

Training is not implemented for this model.

Raises:

NotImplementedError – Training is not implemented for this model.

Return type:

None