pyrosetta_help.alphafold package
Submodules
pyrosetta_help.alphafold.constraints module
- pyrosetta_help.alphafold.constraints.add_interchain_pae_constraints(pose, errors, cutoff=15)[source]
Add constraints between residues that are interacting according to the PAE error matrix but are in different ‘chains’ (sensu PyRosetta FoldTree).
- Parameters:
pose –
errors –
cutoff –
- Returns:
- pyrosetta_help.alphafold.constraints.add_pae_constraints(pose: Pose, errors: ndarray, cutoff: float = 12, tolerance: float | None = None, weight: float = 1, adjecency_threshold=5) None [source]
Add constrains to the pose based on the errors matrix. NB. this matrix is a reshaped version of what AF2 returns.
A harmonic function is added to CA atoms that are in residues with the error under a specified cutoff. The mu is the current distance and the standard deviation of the harmonic is the error times
weight
.To find out how many were added:
>>> len(pose.constraint_set().get_all_constraints())
- Parameters:
pose –
errors –
cutoff –
tolerance – if None Harmonic, if value, tollerance of FlatHarmonic
weight – this is added to the SD part so squared inverse.
adjecency_threshold – min residue separation of sequence neighbours
- Returns:
- pyrosetta_help.alphafold.constraints.add_stretch_constraint(pose: Pose, weight: float = 5, slope_in: float = -0.05, residue_index_A: int = 1, residue_index_B: int = -1, distance: float | None = None, sigmoid: bool = True) AtomPairConstraint [source]
Add a constraint to “stretch out” the model, because
slope_in
is negative. The weight needs to be negative for sigmoid=False or it will attractive- Parameters:
pose – Pose to add constraint to
weight – how strength of constraint (max of 0.5 for
SigmoidFunc
)slope_in – negative number to stretch
residue_index_A – first residue?
residue_index_B – last residue is “-1”
distance – if omitted, the midpoint of Sigmoid will be the current distance
sigmoid – use sigmoid or identity/linear (bad idea)
- Returns:
- pyrosetta_help.alphafold.constraints.make_pae_constraint(pose, residue1_pose_idx: int, residue2_pose_idx: int, error: float, tolerance: float | None = None, weight: float = 1)[source]
Add a constraint between two residues based on the PAE error from AlphaFold2 (the colourful heatmap in EBI-AF2).
- Parameters:
pose –
residue1_pose_idx –
residue2_pose_idx –
error –
tolerance –
weight –
- Returns:
pyrosetta_help.alphafold.multimodel module
- class pyrosetta_help.alphafold.multimodel.AF2NotebookAnalyser(folder: str, load_poses: bool = True)[source]
Bases:
object
This class features heavily in the notebook
colab-pyrosetta-dimer.ipynb
It allows the analysis of the results of the AF2 protocol for a dimer. Namely,.sidechain_relax
analyser = ph.AF2NotebookAnalyser(folder=folder_name, load_poses=True) analyser.sidechain_relax(cycles) analyser.constrain(tolerance=2) analyser.relax(cycles) analyser.calculate_interface() score: pd.DataFrame = analyser.scores
The
.scores
attribute is a pandas DataFrame generated by.make_AF2_dataframe
One can also make a phosphorylated model
pdb_ptms = analyser.parse_phosphosite(raw, maximum=analyser.original_poses[1].chain_end(1)) analyser.make_phosphorylated(pdb_ptms, chain, cycles)
To access specific poses the following attributes are available:
print(analyser.pose_groupnames) # ['relaxed', 'original', 'phospho'] analyser.original_poses[i] analyser.relaxed_poses[i] analyser.phospho_poses[i]
- calculate_interface(interface='A_B')[source]
Calculates the interface strength between the two chains.
It does a median of the pLDDT scores of the interface residues.
- Parameters:
interface – A Rosetta format string for the description of the interface, e.g. ‘A_B’
- Returns:
- constrain(groupname: str = 'relaxed', **add_pae_constraints_arguments)[source]
Calls the
add_pae_constraints
andadd_interchain_pae_constraints
functions on each pose in the group. :param groupname: :param add_pae_constraints_arguments: :return:
- dump_pdbs(groupname: str = 'relaxed', folder: None | str = None, prefix: str | None = '')[source]
Save in the format
f'{prefix}rank_{index}_pyrosetta_{groupname}.pdb'
.
- find_interface_residues()[source]
Calls
get_interactions
for each pose and saves the result in thescores
dataframe.
- get_interactions(pose: Pose, chain_id: int, threshold: float = 3.0) ResidueVector [source]
Get the sequence of pose residue indices that are within the threshold distance of the chain_id.
- get_median_interface_bfactors() Dict[int, float] [source]
“bfactors” aren’t actually bfactors, but pLDDT values. Based on what are the residues identified with
find_interface_residues
in calculates the median pLDDT of these.
- get_poses() Dict[int, Pose] [source]
This used to be a
pyrosetta.rosetta.utility.vector1_core_pose_Pose
but it turns out that the getitem ofvector1_core_pose_Pose
returns a clone of the pose, not the pose itself.- Returns:
- classmethod load(folder: str, load_poses=False, params=())[source]
Loads the poses (from PDB files), scores and errors from the folder. :return:
- make_AF2_dataframe() DataFrame [source]
Given a folder form ColabsFold return a dictionary with key rank index and value a dictionary of details
This is convoluted, but it may have been altered by a human.
- make_phosphorylated(pdb_ptms: dict, chain: str = 'A', cycles: int = 3)[source]
Make a phosphorylated pose from the dictionary of Phoshositeplus annotations (see
parse_phosphosite
)
- classmethod parse_phosphosite(raw: str, minimum: int = 1, maximum: int = -1)[source]
A rubbish method to convert copy-pasted Phosphosite web table.
- Parameters:
raw –
minimum –
maximum –
- Returns:
- property poses
pyrosetta_help.alphafold.plot module
pyrosetta_help.alphafold.retrieval module
- pyrosetta_help.alphafold.retrieval.get_alphafold2_error(uniprot: str, reshaped=True) ndarray | list [source]
Returns the distances errors either as numpy matrix (
reshaped=True
) or as the weird format from AF2-EBI —seehelp(pyrosetta_help.alphafold.retrieval.reshape_errors)
for more.Remember that the matrix is zero indexed and that these values are in Ångström and are not pLDDT, which are stored as b-factors.
- pyrosetta_help.alphafold.retrieval.pose_from_alphafold2(uniprot: str) Pose [source]
Returns a pose from the alphafold2 server.
- Parameters:
uniprot – uniprot id (“accession”), not gene name or uniprot name.
- Returns:
- pyrosetta_help.alphafold.retrieval.reshape_errors(errors: List[Dict[str, list]]) array [source]
The JSON from AF2 has a single element list. the sole element is a dictionary with keys ‘residue1’, ‘residue2’ and ‘distance’. This method returns a matrix of distances reshaped based on the stated residue indices. This is rather unlikely to differ from a regular reshape… but idiotically I am not taking changes assuming it is always sorted.
pyrosetta_help.alphafold.superimpose module
- pyrosetta_help.alphafold.superimpose.superimpose_by_pLDDT(pose: Pose, original: Pose, cutoff=70, pose_range=None) map_core_id_AtomID_core_id_AtomID [source]
Superimpose two poses, based on residues with pLDDT above a given threshold.
- Parameters:
pose –
original –
cutoff –
%
pose_range – optional argument to subset (start:int, end:int)
- Returns: