pyKVFinder.get_vertices_from_file
- pyKVFinder.get_vertices_from_file(fn: str | Path, atomic: ndarray | List[List[str | float | int]], step: float | int = 0.6, probe_in: float | int = 1.4, probe_out: float | int = 4.0, nthreads: int | None = None) Tuple[ndarray, ndarray, ndarray] [source]
Gets 3D grid vertices from box configuration file or parKVFinder parameters file, selects atoms inside custom 3D grid, define sine and cosine of 3D grid angles and define xyz grid units.
- Parameters:
fn (Union[str, pathlib.Path]) – A path to box configuration file (TOML-formatted).
atomic (Union[numpy.ndarray, List[List[Union[str, float, int]]]]) – A numpy array with atomic data (residue number, chain, residue name, atom name, xyz coordinates and radius) for each atom.
step (Union[float, int], optional) – Grid spacing (A), by default 0.6.
probe_in (Union[float, int], optional) – Probe In size (A), by default 1.4.
probe_out (Union[float, int], optional) – Probe Out size (A), by default 4.0.
nthreads (int, optional) – Number of threads, by default None. If None, the number of threads is os.cpu_count() - 1.
- Returns:
vertices (numpy.ndarray) – A numpy.ndarray with xyz vertices coordinates (origin, X-axis, Y-axis, Z-axis) of the custom box.
atomic (Union[numpy.ndarray, List[List[Union[str, float, int]]]]) – A numpy array with atomic data (residue number, chain, residue name, atom name, xyz coordinates and radius) for each atom inside the custom box.
- Raises:
TypeError – fn must be a string or a pathlib.Path.
TypeError – atomic must be a list or a numpy.ndarray.
ValueError – atomic has incorrect shape. It must be (n, 8).
TypeError – step must be a positive real number.
ValueError – step must be a positive real number.
TypeError – probe_in must be a non-negative real number.
ValueError – probe_in must be a non-negative real number.
TypeError – probe_out must be a non-negative real number.
ValueError – probe_out must be a non-negative real number.
ValueError – probe_out must be greater than probe_in.
TypeError – nthreads must be a positive integer.
ValueError – You must define (p1, p2, p3, p4) or (residues, padding) keys in fn.
ValueError – Box not properly defined in fn.
Note
The box configuration scale file defines the vertices of the 3D grid used by pyKVFinder to detect and characterize cavities. There are three methods for defining a custom 3D grid in pyKVFinder. The first directly defines four vertices of the 3D grid (origin, X-axis, Y-axis and Z-axis), the second defines a list of residues and a padding, and the the third uses parKVFinder parameters file created by its PyMOL plugin. For more details, see Box configuration file template.
See also
read_pdb
,read_xyz
,detect
,constitutional
,hydropathy
,export
Example
First, define a box configuration file (see
Box configuration file template
).>>> import os >>> fn = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', 'custom-box.toml') >>> with open(fn, 'r') as f: ... print(f.read()) [box] p1 = [3.11, 7.34, 1.59] p2 = [11.51, 7.34, 1.59] p3 = [3.11, 10.74, 1.59] p4 = [3.11, 7.34, 6.19]
With the atomic information and coordinates read with
pyKVFinder.read_pdb
and a box configuration file, we can get the coordinates of grid vertices and select atoms inside custom 3D grid.>>> from pyKVFinder import get_vertices_from_file >>> vertices, atomic = pyKVFinder.get_vertices_from_file(fn, atomic)
Warning
Custom box coordinates adds Probe Out size in each direction to create the coordinates of grid vertices.