Skip to content

Commit

Permalink
Merge pull request #3 from sokrypton/main
Browse files Browse the repository at this point in the history
v2.3.1
  • Loading branch information
martin-steinegger authored Feb 3, 2023
2 parents 68c2feb + 36c5925 commit 15eb3e0
Show file tree
Hide file tree
Showing 45 changed files with 2,418 additions and 1,009 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include alphafold/common/stereo_chemical_props.txt
466 changes: 286 additions & 180 deletions README.md

Large diffs are not rendered by default.

390 changes: 390 additions & 0 deletions afdb/README.md

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions alphafold/common/confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def predicted_tm_score(
logits: np.ndarray,
breaks: np.ndarray,
residue_weights: Optional[np.ndarray] = None,
asym_id: Optional[np.ndarray] = None,
interface: bool = False) -> np.ndarray:
asym_id: Optional[np.ndarray] = None) -> np.ndarray:
"""Computes predicted TM alignment or predicted interface TM alignment score.
Args:
Expand All @@ -123,8 +122,7 @@ def predicted_tm_score(
residue_weights: [num_res] the per residue weights to use for the
expectation.
asym_id: [num_res] the asymmetric unit ID - the chain ID. Only needed for
ipTM calculation, i.e. when interface=True.
interface: If True, interface predicted TM score is computed.
ipTM calculation.
Returns:
ptm_score: The predicted TM alignment or the predicted iTM score.
Expand All @@ -136,10 +134,10 @@ def predicted_tm_score(
residue_weights = np.ones(logits.shape[0])

bin_centers = _calculate_bin_centers(breaks)
num_res = residue_weights.shape[0]

num_res = int(np.sum(residue_weights))
# Clip num_res to avoid negative/undefined d0.
clipped_num_res = max(num_res, 19)
clipped_num_res = max(np.sum(residue_weights), 19)

# Compute d_0(num_res) as defined by TM-score, eqn. (5) in Yang & Skolnick
# "Scoring function for automated assessment of protein structure template
Expand All @@ -154,15 +152,14 @@ def predicted_tm_score(
# E_distances tm(distance).
predicted_tm_term = np.sum(probs * tm_per_bin, axis=-1)

pair_mask = np.ones(shape=(num_res, num_res), dtype=bool)
if interface:
pair_mask *= asym_id[:, None] != asym_id[None, :]
if asym_id is None:
pair_mask = np.ones((num_res,num_res), dtype=bool)
else:
pair_mask = asym_id[:, None] != asym_id[None, :]

predicted_tm_term *= pair_mask

pair_residue_weights = pair_mask * (
residue_weights[None, :] * residue_weights[:, None])
normed_residue_mask = pair_residue_weights / (1e-8 + np.sum(
pair_residue_weights, axis=-1, keepdims=True))
pair_residue_weights = pair_mask * (residue_weights[None, :] * residue_weights[:, None])
normed_residue_mask = pair_residue_weights / (1e-8 + np.sum(pair_residue_weights, axis=-1, keepdims=True))
per_alignment = np.sum(predicted_tm_term * normed_residue_mask, axis=-1)
return np.asarray(per_alignment[(per_alignment * residue_weights).argmax()])
return np.asarray(per_alignment[(per_alignment * residue_weights).argmax()])
10 changes: 5 additions & 5 deletions alphafold/common/residue_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

# Internal import (35fd).


stereo_chemical_props_path = 'alphafold/common/stereo_chemical_props.txt'
from . import __file__
stereo_chemical_props_path = os.path.join(os.path.dirname(__file__), f'stereo_chemical_props.txt')

# Distance from one CA to next CA [trans configuration: omega = 180].
ca_ca = 3.80209737096
Expand Down Expand Up @@ -122,7 +122,7 @@
# 4,5,6,7: 'chi1,2,3,4-group'
# The atom positions are relative to the axis-end-atom of the corresponding
# rotation axis. The x-axis is in direction of the rotation axis, and the y-axis
# is defined such that the dihedral-angle-definiting atom (the last entry in
# is defined such that the dihedral-angle-defining atom (the last entry in
# chi_angles_atoms above) is in the xy-plane (with a positive y-coordinate).
# format: [atomname, group_idx, rel_position]
rigid_group_atom_positions = {
Expand Down Expand Up @@ -771,10 +771,10 @@ def _make_rigid_transformation_4x4(ex, ey, translation):
# and an array with (restype, atomtype, coord) for the atom positions
# and compute affine transformation matrices (4,4) from one rigid group to the
# previous group
restype_atom37_to_rigid_group = np.zeros([21, 37], dtype=np.int)
restype_atom37_to_rigid_group = np.zeros([21, 37], dtype=int)
restype_atom37_mask = np.zeros([21, 37], dtype=np.float32)
restype_atom37_rigid_group_positions = np.zeros([21, 37, 3], dtype=np.float32)
restype_atom14_to_rigid_group = np.zeros([21, 14], dtype=np.int)
restype_atom14_to_rigid_group = np.zeros([21, 14], dtype=int)
restype_atom14_mask = np.zeros([21, 14], dtype=np.float32)
restype_atom14_rigid_group_positions = np.zeros([21, 14, 3], dtype=np.float32)
restype_rigid_group_default_frame = np.zeros([21, 8, 4, 4], dtype=np.float32)
Expand Down
Loading

0 comments on commit 15eb3e0

Please sign in to comment.