pyKVFinder.openings

pyKVFinder.openings(cavities: ndarray, depths: ndarray | None = None, step: float | int = 0.6, openings_cutoff: int = 1, selection: List[int] | List[str] | None = None, nthreads: int | None = None, verbose: bool = False) Tuple[int, ndarray, Dict[str, Dict[str, float]]][source]

[WIP] Identify openings of the detected cavities and calculate their areas.

Parameters:
  • cavities (numpy.ndarray) –

    Cavity points in the 3D grid (cavities[nx][ny][nz]). Cavities array has integer labels in each position, that are:

    • -1: bulk points;

    • 0: biomolecule points;

    • 1: empty space points;

    • >=2: cavity points.

  • depths (Optional[numpy.ndarray], optional) – A numpy.ndarray with depth of cavity points (depth[nx][ny][nz]), by default None. If None, depths is calculated from cavities.

  • step (Union[float, int], optional) – Grid spacing (A), by default 0.6.

  • openings_cutoff (int, optional) – The minimum number of voxels an opening must have, by default 1.

  • selection (Union[List[int], List[str]], optional) – A list of integer labels or a list of cavity names to be selected, by default None.

  • nthreads (int, optional) – Number of threads, by default None. If None, the number of threads is os.cpu_count() - 1.

  • verbose (bool, optional) – Print extra information to standard output, by default False.

Returns:

  • nopenings (int) – Total number of openings.

  • openings (numpy.ndarray) – Openings points in the 3D grid (openings[nx][ny][nz]). Openings array has integer labels in each position, that are:

    • -1: bulk points;

    • 0: cavity or biomolecule points;

    • 1: empty space points;

    • >=2: Opening points.

    The empty space points are regions that do not meet the chosen openings cutoff to be considered an opening.

  • aopenings (Dict[str, Dict[str,float]]) – A dictionary with area of each detected opening.

Raises:
  • TypeErrorcavities must be a numpy.ndarray.

  • ValueErrorcavities has the incorrect shape. It must be (nx, ny, nz).

  • TypeErrordepths must be a numpy.ndarray.

  • ValueErrordepths has the incorrect shape. It must be (nx, ny, nz).

  • TypeErrorstep must be a positive real number.

  • ValueErrorstep must be a positive real number.

  • TypeErroropenings_cutoff must be an integer.

  • ValueErroropenings_cutoff must be a positive integer.

  • TypeErrorselection must be a list of strings (cavity names) or integers (cavity labels).

  • ValueError – Invalid selection: selection.

  • TypeErrornthreads must be a positive integer.

  • ValueErrornthreads must be a positive integer.

  • TypeErrorverbose must be a boolean

Example

With the cavity points identified with detect, we can characterize their openings, that includes number and area of openings and defining opening points:

>>> from pyKVFinder import openings
>>> nopenings, openings, aopenings = openings(cavities)
>>> nopenings
16
>>> openings
array([[[-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        ...,
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1]],
      ...,
      [[-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        ...,
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1],
        [-1, -1, -1, ..., -1, -1, -1]]])
>>> aopenings
{'KAA': {'OAA': 47.41, 'OAG': 3.6}, 'KAB': {'OAB': 25.84}, 'KAC': {'OAC': 53.62}, 'KAD': {'OAD': 12.59}, 'KAE': {'OAE': 26.3}, 'KAF': {'OAF': 18.46}, 'KAG': {'OAH': 12.83}, 'KAH': {'OAK': 59.96}, 'KAJ': {'OAI': 16.11}, 'KAL': {'OAJ': 17.3}, 'KAM': {'OAL': 35.27}, 'KAO': {'OAM': 8.49}, 'KAP': {'OAN': 13.71}, 'KAQ': {'OAO': 13.16}, 'KAR': {'OAP': 15.36}}

With the cavity and opening points identified, we can:

  • Export cavity points with opening points mapped on them:

>>> from pyKVFinder import export
>>> export("cavities_with_openings.pdb", cavities, None, vertices, B=openings)
  • Export opening points with same nomenclature from aopenings:

>>> from pyKVFinder import export_openings
>>> export_openings("openings.pdb", openings, vertices)