Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindsponge.metrics.sidechain

View Source On Gitee
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 (Nres,), with value 1.0 where alternative swap is better.

  • rigidgroups_gt_frames (Tensor) – The ground truth locals frames of shape (Nres,8,12), with Nres 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 (Nres,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 (Nres,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 (Nres,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,Nrecycle,Nres,8). Nrecycle 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,Nrecycle,Nres,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