mindsponge.metrics.between_residue_bond

mindsponge.metrics.between_residue_bond(pred_atom_positions, pred_atom_mask, residue_index, aatype, tolerance_factor_soft=12.0, tolerance_factor_hard=12.0)[source]

Flat-bottom loss to penalize structural violations between residues. This is a loss penalizing any violation of the geometry around the peptide bond between consecutive amino acids.

Parameters
  • pred_atom_positions (Tensor) – Atom positions in atom37/14 representation, shape \((N_{res}, 37, 3)\). or shape \((N_{res}, 14, 3)\) .

  • pred_atom_mask (Tensor) – Atom mask in atom37/14 representation. shape \((N_{res}, 37)\) or shape \((N_{res}, 14)\) .

  • residue_index (Tensor) – Residue index for given amino acid, this is assumed to be monotonically increasing. Range from 1 to \(N_{res}\). shape \((N_{res}, )\) .

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

  • tolerance_factor_soft (float) – soft tolerance factor measured in standard deviations of pdb distributions. Default: 12.0 .

  • tolerance_factor_hard (float) – hard tolerance factor measured in standard deviations of pdb distributions. Default: 12.0 .

Returns

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

  • Tensor, ca_c_n_loss_mean, loss for violations of bond angle around C spanned by CA, C, N. shape is \(( )\) .

  • Tensor, c_n_ca_loss_mean, loss for violations of bond angle around N spanned by C, N, CA. shape is \(( )\) .

  • Tensor, per_residue_loss_sum, sum of all losses of each residue. shape is \((N_{res}, )\) .

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

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 between_residue_bond
>>> np.random.seed(1)
>>> pred_atom_positions = Tensor(np.random.random(size=(50,37,3)), ms.float32)
>>> pred_atom_mask = Tensor(np.random.randint(2,size=(50,37)), ms.int32)
>>> residue_index = Tensor(np.array(range(50)), ms.int32)
>>> aatype = Tensor(np.random.randint(20, size=(50,)), ms.int32)
>>> tolerance_factor_soft = 12.0
>>> tolerance_factor_hard = 12.0
>>> result = between_residue_bond(pred_atom_positions, pred_atom_mask, residue_index, aatype,
>>>                              tolerance_factor_soft, tolerance_factor_hard)
>>> for x in result:
>>>    print(x)
0.52967054
0.6045412
0.39251995
[0.62809587 1.6770853  1.7221183  1.0325309  1.3417522  1.79882
 1.7718308  1.5092779  1.5653987  1.9564128  1.6804926  1.6051245
 1.5033073  1.5895741  2.1686926  2.126039   1.3837843  1.2554975
 1.8135165  2.1593785  1.9408598  1.7281027  1.8666006  1.9623451
 1.8177024  1.7543832  1.5969353  1.2150483  0.9833115  1.219868
 1.7008476  1.6968286  1.7648234  1.5584714  1.370602   1.8525059
 1.7938454  1.5313196  1.6940074  1.8512855  1.8222975  1.6600168
 1.9163743  1.7201058  1.6288358  1.6055745  1.521946   1.6553445
 1.6175683  0.894606 ]
 [1. 1. 0. 1. 1. 0. 0. 1. 1. 1. 1. 0. 0. 0. 0. 1. 1. 1. 1. 1. 0. 1. 1. 0.
  0. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1. 1. 1. 0.
  1. 1.]