pyKVFinder.read_pdb
- pyKVFinder.read_pdb(fn: str | Path, vdw: Dict[str, Dict[str, float]] | None = None, model: int | None = None) ndarray [source]
Reads PDB file into numpy.ndarrays.
- Parameters:
fn (Union[str, pathlib.Path]) – A path to PDB file.
vdw (Dict[str, Dict[str, float]], optional) – A dictionary containing radii values, by default None. If None, use output of
read_vdw()
.model (int, optional) – The model number of a multi-model PDB file, by default None. If None, keep atoms from all models.
- Returns:
atomic – A numpy array with atomic data (residue number, chain, residue name, atom name, xyz coordinates and radius) for each atom.
- Return type:
numpy.ndarray
- Raises:
TypeError – fn must be a string or a pathlib.Path.
Note
The van der Waals radii file defines the radius values for each atom by residue and when not defined, it uses a generic value based on the atom type. The function by default loads the built-in van der Waals radii file: vdw.dat.
See also
read_vdw
,read_xyz
,get_vertices
,get_vertices_from_file
,detect
,constitutional
,hydropathy
Example
With the vdW radii dictionary loaded with
read_vdw
, we can read a target PDB file into Numpy array (atomic data):>>> import os >>> import pyKVFinder >>> from pyKVFinder import read_pdb >>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb') >>> atomic = read_pdb(pdb) >>> atomic array([['13', 'E', 'GLU', ..., '-15.642', '-14.858', '1.824'], ['13', 'E', 'GLU', ..., '-14.62', '-15.897', '1.908'], ['13', 'E', 'GLU', ..., '-13.357', '-15.508', '1.908'], ..., ['350', 'E', 'PHE', ..., '18.878', '-9.885', '1.908'], ['350', 'E', 'PHE', ..., '17.624', '-9.558', '1.908'], ['350', 'E', 'PHE', ..., '19.234', '-13.442', '1.69']], dtype='<U32')
Warning
The function takes the built-in dictionary when the
vdw
argument is not specified. If you wish to use a custom van der Waals radii file, you must read it withread_vdw
as shown earlier and pass it asread_pdb(pdb, vdw=vdw)
.