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.get_structural_violations

View Source On Gitee
mindsponge.metrics.get_structural_violations(atom14_atom_exists, residue_index, aatype, residx_atom14_to_atom37, atom14_pred_positions, violation_tolerance_factor=VIOLATION_TOLERANCE_ACTOR, clash_overlap_tolerance=CLASH_OVERLAP_TOLERANCE, lower_bound=LOWER_BOUND, upper_bound=UPPER_BOUND, atomtype_radius=ATOMTYPE_RADIUS, c_one_hot=C_ONE_HOT, n_one_hot=N_ONE_HOT, dists_mask_i=DISTS_MASK_I, cys_sg_idx=CYS_SG_IDX)[source]

Computes several checks for structural violations.

Parameters
  • atom14_atom_exists (Tensor) – mask denoting whether atom at positions exists for given amino acid type. shape (Nres,14) .

  • residue_index (Tensor) – Residue index for given amino acid range from 0 to Nres1. Shape (Nres,) .

  • aatype (Tensor) – amino acid types. shape (Nres,) . Range is [0,20] .

  • residx_atom14_to_atom37 (Tensor) – mapping for (residx, atom14) –> atom37. shape (Nres,14) .

  • atom14_pred_positions (Tensor) – predicted positions of atoms in global prediction frame. shape (Nres,14,3) .

  • violation_tolerance_factor (float) – violation between amino acid tolerance factor. Default: 12.0 .

  • clash_overlap_tolerance (float) – clash overlap tolerance factor. Default: 1.5 .

  • lower_bound (Tensor) – lower bond on allowed distances. shape (Nres,14,14) .

  • upper_bound (Tensor) – upper bond on allowed distances. shape (Nres,14,14) .

  • atomtype_radius (Tensor) – Van der Waals radius for each amino acid. shape: (37,) .

  • c_one_hot (Tensor) – one hot encoding for C atoms (using atom14 representation). shape: (14,) .

  • n_one_hot (Tensor) – one hot encoding for N atoms (using atom14 representation). shape: (14,) .

  • dists_mask_i (Tensor) – initial distants mask, shape: (14,14) .

  • cys_sg_idx (Tensor) – CYS amino acid index. Default: 5 . see more at mindsponge.common.residue_constants. shape: ()

Returns

  • bonds_c_n_loss_mean (Tensor), loss for peptide bond length violations. shape is ().

  • angles_ca_c_n_loss_mean (Tensor), loss for violations of bond angle around C spanned by CA, C, N. Shape is ().

  • angles_c_n_ca_loss_mean (Tensor), loss for violations of bond angle around N spanned by C, N, CA. Shape is ().

  • connections_per_residue_loss_sum (Tensor), sum of all losses of each residue. shape is (Nres,) .

  • connections_per_residue_violation_mask (Tensor), mask denoting all residues with violation present. shape is (Nres,) .

  • clashes_mean_loss (Tensor), average clash loss. shape: () .

  • clashes_per_atom_loss_sum (Tensor), sum of all clash losses per atom, shape (Nres,14) .

  • clashes_per_atom_clash_mask (Tensor), mask whether atom clashes with any other atom. shape (Nres,14) .

  • per_atom_loss_sum (Tensor), sum of all clash losses per atom, shape (Nres,14) .

  • per_atom_violations (Tensor), violation per atom, shape (Nres,14) .

  • total_per_residue_violations_mask (Tensor), violation masks for all residues, shape (Nres,) .

  • structure_violation_loss (Tensor), total violations for all amino acids. shape is () .

Symbol:

Nres, number of amino acids.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> from mindspore import Tensor
>>> import numpy as np
>>> from mindsponge.metrics import get_structural_violations
>>> atom14_atom_exists = Tensor(np.random.random(size=(50, 14)), ms.float32)
>>> residue_index = Tensor(np.array(range(50)), ms.int32)
>>> aatype = Tensor(np.random.randint(20, size=(50,)), ms.int32)
>>> residx_atom14_to_atom37 = Tensor(np.random.randint(2, size=(50, 14)), ms.int32)
>>> atom14_pred_positions = Tensor(np.random.random(size=(50, 14, 3)), ms.float32)
>>> violation_tolerance_factor = 12.0
>>> clash_overlap_tolerance = 1.5
>>> lower_bound = Tensor(np.random.random(size=(50, 14, 14)), ms.float32)
>>> upper_bound = Tensor(np.random.random(size=(50, 14, 14)), ms.float32)
>>> atomtype_radius =Tensor([1.55, 1.7, 1.7, 1.7, 1.52, 1.7, 1.7, 1.7, 1.52, 1.52, 1.8,
...                          1.7, 1.7, 1.7, 1.55, 1.55, 1.52, 1.52, 1.8, 1.7, 1.7, 1.7,
...                          1.7, 1.55, 1.55, 1.55, 1.52, 1.52, 1.7, 1.55, 1.55, 1.52, 1.7,
...                          1.7, 1.7, 1.55, 1.52], ms.float32)
>>> c_one_hot = Tensor(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ms.int32)
>>> n_one_hot = Tensor(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ms.int32)
>>> dists_mask_i = Tensor(np.eye(14, 14), ms.int32)
>>> cys_sg_idx = Tensor(5, ms.int32)
>>> result = get_structural_violations(atom14_atom_exists, residue_index, aatype, residx_atom14_to_atom37,
...                                    atom14_pred_positions, violation_tolerance_factor,
...                                    clash_overlap_tolerance, lower_bound, upper_bound, atomtype_radius,
...                                    c_one_hot, n_one_hot, dists_mask_i,cys_sg_idx)
>>> for r in result:
>>>     print(r.shape)
()
()
()
(50,)
(50,)
()
(50, 14)
(50, 14)
(50, 14)
(50, 14)
(50,)
()