proteinnetpy.maths

Module containing maths functionss for working with ProteinNet datasets

calc_chi1(mmcif, target_chain, seq)

Calculate Chi1 angle for each residue in an mmCIF dictionary.

Calculate side chain rotamer chiral angle for each residue in an mmCIF dictionary. This angle is the dihedral angle (see calc_dihedral) between the backbone and side chain (specific atoms used can be found in CHI1_ATOMS).

Parameters:
  • mmcif (dict) – mmCIF dictionary, as generated by Biopythons Bio.PDB.MMCIF2Dict.

  • target_chain (str) – Chain to calculate angles for.

  • seq (Iterable of str) – Expected target chain sequence.

Returns:

The calculated Chi1 angles for each position in the sequence.

Return type:

ndarray

References

This function is adapted from code by Umberto Perron.

calc_dihedral(p)

Calculate dihedral angles between 4 cartesian points.

Calculate dihedral angles between 4 cartesian points, meaning the angle between the plane defined by ABC and that defined by BCD from the four points passed (ABCD). The points should be on the first axis of the numpy array (i.e. in rows with coordinates as columns as displayed). The Phi, Psi and Omega backbone angles in proteins are dihedral angles between the planes defined by different combinations of backbone atoms (Phi: CA-C-N-CA, Psi: C-N-CA-C, Omega: N-CA-C-N).

Parameters:

p (ndarray) – Numpy array of points. Different points are on the first axis with coordinates along the second axis. The points are ordered ABCD.

Returns:

The calculated dihedral angle.

Return type:

Float

References

This code is adapted from user Praxeolitic’s StackOverflow answer.

softmax_sample(weights, min_value=-inf)

Sample from weights after appling the softmax function to them, subject to the weight being greater than min_value.

Sample from weights after appling the softmax function to them, subject to the weight being greater than min_value. Weights less than min_value are removed prior to the softmax opperation. The output index corresponding to the index of the original array, with any values less than min_value included.

Parameters:
  • weights (ndarray) – Weights to sample from.

  • min_value (float) – Minimum weight to consider

Returns:

Index selected by softmax weighted sampling.

Return type:

int

softmin_sample(weights, max_value=inf)

Sample from weights after appling the softmin function to them, subject to the weight being less than max_value.

Sample from weights after appling the softmin function to them, subject to the weight being less than max_value. Weights greater than max_value are removed prior to the softmin opperation. The output index corresponding to the index of the original array, with any values greater than max_value included.

Parameters:
  • weights (ndarray) – Weights to sample from.

  • max_value (float) – Maximum weight to consider

Returns:

Index selected by softmin weighted sampling.

Return type:

int