Tools

This module contains a series of core tools used for the feature calculations in DeepRank. These tools are at the moment:

  • sasa: a simple solvent surface area calculator
  • sparse: a 3D sparse matrix engine

Here are the details of the submodule given in tools.

Solvent Accessible Surface Area

class deeprank.tools.sasa.SASA(pdbfile)[source]

Simple class that computes Surface Accessible Solvent Area.

The method follows some of the approaches presented in:

Solvent accessible surface area approximations for rapid and accurate protein structure prediction https://link.springer.com/article/10.1007%2Fs00894-009-0454-9

Example

>>> sasa = SASA('1AK4_1w.pdb')
>>> NV = sasa.neighbor_vector()
>>> print(NV)
Parameters:pdbfile (str) – PDB file of the conformation
get_center(chain1='A', chain2='B', center='cb')[source]

Get the center of the resiudes.

Parameters:
  • chain1 (str, optional) – Name of the first chain
  • chain2 (str, optional) – Name of the second chain
  • center (str, optional) – Specify the center. ‘cb’: the center locates on carbon beta of each residue ‘center’: average position of all atoms of the residue
Raises:

ValueError – If the center is not recpgnized

get_residue_center(chain1='A', chain2='B')[source]

Compute the average position of all the residues.

Parameters:
  • chain1 (str, optional) – Name of the first chain
  • chain2 (str, optional) – Name of the second chain
get_residue_carbon_beta(chain1='A', chain2='B')[source]

Extract the position of the carbon beta of each residue.

Parameters:
  • chain1 (str, optional) – Name of the first chain
  • chain2 (str, optional) – Name of the second chain
neighbor_vector(lbound=3.3, ubound=11.1, chain1='A', chain2='B', center='cb')[source]

Compute teh SASA folowing the neighbour vector approach.

The method is based on Eq on page 1097 of https://link.springer.com/article/10.1007%2Fs00894-009-0454-9

Parameters:
  • lbound (float, optional) – lower boubd
  • ubound (float, optional) – upper bound
  • chain1 (str, optional) – name of the first chain
  • chain2 (str, optional) – name of the second chain
  • center (str, optional) – specify the center (see get_residue_center)
Returns:

neighbouring vectors

Return type:

dict

neighbor_count(lbound=4.0, ubound=11.4, chain1='A', chain2='B', center='cb')[source]

Compute the neighbourhood count of each residue.

The method is based on Eq on page 1097 of https://link.springer.com/article/10.1007%2Fs00894-009-0454-9

Parameters:
  • lbound (float, optional) – lower boubd
  • ubound (float, optional) – upper bound
  • chain1 (str, optional) – name of the first chain
  • chain2 (str, optional) – name of the second chain
  • center (str, optional) – specify the center
  • get_residue_center) ((see) –
Returns:

Neighborhood count

Return type:

dict

static neighbor_weight(dist, lbound, ubound)[source]

Neighboor weight.

Parameters:
  • dist (np.array) – distance from neighboors
  • lbound (float) – lower bound
  • ubound (float) – upper bound
Returns:

distance

Return type:

float

Sparse 3D Matrix

deeprank.tools.sparse._printif(string, cond)[source]
class deeprank.tools.sparse.FLANgrid(sparse=None, index=None, value=None, shape=None)[source]

Flat Array sparse matrix.

Parameters:
  • sparse (bool, optional) – Sparse or Not
  • index (list(int), optional) – single index of each non-zero element
  • value (list(float), optional) – values of non-zero elements
  • shape (3x3 array, optional) – Shape of the matrix
from_dense(data, beta=None, debug=False)[source]

Create a sparse matrix from a dense one.

Parameters:
  • data (np.array) – Dense matrix
  • beta (float, optional) – threshold to determine if a sparse rep is valuable
  • debug (bool, optional) – print debug information
to_dense(shape=None)[source]

Create a dense matrix.

Parameters:shape (3x3 array, optional) – Shape of the matrix
Returns:Dense 3D matrix
Return type:np.array
Raises:ValueError – shape not defined
_get_single_index(index)[source]

Get the single index for a single element.

# get the index can be used with a map # self.index = np.array( list( map(self._get_single_index,index) ) ).astype(index_type) # however that is remarkably slow compared to the array version

Parameters:index (array) – COO index
Returns:index
Return type:int
_get_single_index_array(index)[source]

Get the single index for multiple elements.

# get the index can be used with a map # self.index = np.array( list( map(self._get_single_index,index) ) ).astype(index_type) # however that is remarkably slow compared to the array version

Parameters:index (array) – COO index
Returns:index
Return type:list(int)