mindsponge.metrics.sidechain

mindsponge.metrics.sidechain(alt_naming_is_better, rigidgroups_gt_frames, rigidgroups_alt_gt_frames, rigidgroups_gt_exists, renamed_atom14_gt_positions, renamed_atom14_gt_exists, sidechain_atom_clamp_distance, sidechain_length_scale, pred_frames, pred_positions)[source]

sidechain FAPE Loss which take all local frames (side-chain, backbone) into consideration. Jumper et al. (2021) Suppl. Alg. 20 “StructureModule” line 17.

Parameters
  • alt_naming_is_better (Tensor) – Tensor of shape \((N_{res},)\), with value 1.0 where alternative swap is better.

  • rigidgroups_gt_frames (Tensor) – The ground truth locals frames of shape \((N_{res}, 8, 12)\), with \((N_{res},)\) the number of residues in protein. For each residue, there are 1 backbone frame and 7 side-chain frames, 8 frames in total. For the last dimension, the first 9 elements are the 9 components of rotation matrix; the last 3 elements are the 3 component of translation matrix.

  • rigidgroups_alt_gt_frames (Tensor) – The alternative ground truth locals frames due to symmetry of amino acids. This tensor has the same shape as rigidgroups_gt_frames

  • rigidgroups_gt_exists (Tensor) – The binary mask for gt frames of shape \((N_{res}, 8)\).

  • renamed_atom14_gt_positions (Tensor) – The mask for ground truth positions after renaming swaps are performed(swaps are needed for some amino acids due to symmetry compute_renamed_ground_truth), its shape is \((N_{res}, 14, 3)\).It takes the 14-types atoms encoding.

  • renamed_atom14_gt_exists (Tensor) – The mask for ground truth positions after renaming swap is performed after renaming swaps are performed, its shape is \((N_{res}, 14)\).

  • sidechain_atom_clamp_distance (float) – Distance cutoff on error beyond which gradients will be zero.

  • sidechain_length_scale (float) – The unit distance of sidechain FAPE loss, used to scale distances.

  • pred_frames (Tensor) – The predicted locals frames of shape \((12, N_{recycle}, N_{res}, 8)\). \((N_{recycle},)\) is the recycle number of FoldIteration in Structure module. Only the frames of last recycle is used in side-chain FAPE loss. 12 has the same meaning as the third dimension of rigidgroups_gt_frames.

  • pred_positions (Tensor) – The predicted positions of shape \((3, N_{recycle}, N_{res}, 14)\). Only the positions of last recycle is used in side-chain FAPE loss, encoded atom-14 encoding.

Returns

Tensor, fape. Clamped side-chian FAPE loss with shape \(()\).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> np.random.seed(0)
>>> from mindsponge.metrics import sidechain
>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor
>>> alt_naming_is_better = Tensor(np.zeros((256,))).astype(mstype.float32)
>>> rigidgroups_gt_frames = Tensor(np.random.rand(256, 8, 12)).astype(mstype.float32)
>>> rigidgroups_alt_gt_frames = Tensor(np.random.rand(256, 8, 12)).astype(mstype.float32)
>>> rigidgroups_gt_exists = Tensor(np.random.rand(256, 8)).astype(mstype.float32)
>>> renamed_atom14_gt_positions = Tensor(np.random.rand(256, 14, 3)).astype(mstype.float32)
>>> renamed_atom14_gt_exists = Tensor(np.random.rand(256, 14)).astype(mstype.float32)
>>> sidechain_atom_clamp_distance = 10.0
>>> sidechain_length_scale = 10.0
>>> pred_frames = Tensor(np.random.rand(12, 8, 256, 8)).astype(mstype.float32)
>>> pred_positions = Tensor(np.random.rand(3, 8, 256, 14)).astype(mstype.float32)
>>> sidechain_loss = sidechain(alt_naming_is_better, rigidgroups_gt_frames, rigidgroups_alt_gt_frames,
...                            rigidgroups_gt_exists, renamed_atom14_gt_positions,
...                            renamed_atom14_gt_exists, sidechain_atom_clamp_distance,sidechain_length_scale,
...                            pred_frames, pred_positions)
>>> print(sidechain_loss)
0.08569459