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 \((N_{res}, 14)\) .

  • residue_index (Tensor) – Residue index for given amino acid range from 0 to \(N_{res} - 1\). Shape \((N_{res}, )\) .

  • aatype (Tensor) – amino acid types. shape \((N_{res}, )\) . Range is \([0,20]\) .

  • residx_atom14_to_atom37 (Tensor) – mapping for (residx, atom14) –> atom37. shape \((N_{res}, 14)\) .

  • atom14_pred_positions (Tensor) – predicted positions of atoms in global prediction frame. shape \((N_{res}, 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 \((N_{res}, 14, 14)\) .

  • upper_bound (Tensor) – upper bond on allowed distances. shape \((N_{res}, 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 \((N_{res}, )\) .

  • connections_per_residue_violation_mask (Tensor), mask denoting all residues with violation present. shape is \((N_{res}, )\) .

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

  • clashes_per_atom_loss_sum (Tensor), sum of all clash losses per atom, shape \((N_{res}, 14)\) .

  • clashes_per_atom_clash_mask (Tensor), mask whether atom clashes with any other atom. shape \((N_{res}, 14)\) .

  • per_atom_loss_sum (Tensor), sum of all clash losses per atom, shape \((N_{res}, 14)\) .

  • per_atom_violations (Tensor), violation per atom, shape \((N_{res}, 14)\) .

  • total_per_residue_violations_mask (Tensor), violation masks for all residues, shape \((N_{res}, )\) .

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

Symbol:

\(N_{res}\), 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,)
()