mofbuilder.io.PdbReader#
- class mofbuilder.io.PdbReader(comm=None, ostream=None, filepath=None)[source]#
Bases:
objectClass for reading and processing atomic coordinates from PDB files.
- Parameters:
comm (Any | None)
ostream (veloxchem.outputstream.OutputStream | None)
filepath (str | None)
- comm#
MPI communicator.
- Type:
MPI.Comm
- rank#
MPI rank of current process.
- Type:
int
- nodes#
Total number of MPI processes.
- Type:
int
- ostream#
Output stream for logging.
- Type:
OutputStream
- filepath#
Path to the PDB file.
- Type:
str | Path | None
- com_target_type#
Atom type used for center-of-mass calculation.
- Type:
str
- data#
Parsed atom data as array; see row format below.
- Type:
np.ndarray | None
- X_data#
Rows corresponding to atom type “X”.
- Type:
np.ndarray | None
- node_atoms#
Atom types and labels for processed nodes.
- Type:
np.ndarray | None
- node_ccoords#
Coordinates for all node atoms, recentered.
- Type:
np.ndarray | None
- node_x_ccoords#
Coordinates for atoms of type “X”, recentered.
- Type:
np.ndarray | None
- _debug#
Toggle debug-level logging.
- Type:
bool
- read_pdb()[source]#
Reads the PDB file and extracts atom data.
- Parameters:
filepath (str | None)
recenter (bool)
com_type (str | None)
- Return type:
None
- expand_arr2data()[source]#
Converts an array of atom records into the library’s standard format.
- Parameters:
arr (ndarray | None)
- Return type:
Tuple[ndarray | None, ndarray | None]
- process_node_pdb()[source]#
Specialized recentering and extraction for node atoms.
- Return type:
None
- read_pdb(filepath=None, recenter=True, com_type=None)[source]#
Read a PDB file, extract atoms, and optionally recenter coordinates.
Populates self.data with shape (N, 11): [atom_type, atom_label, atom_number, residue_name, residue_number, value_x, value_y, value_z, occupancy, b_factor, note].
- Parameters:
filepath (str, optional) – Path to the PDB file. Overrides instance filepath if given.
recenter (bool, optional) – If True (default), recenter coordinates to center-of-mass.
com_type (str, optional) – Atom type for COM; if None, uses all atoms.
- Raises:
AssertionError – If file does not exist.
- Return type:
None
Note
Only ATOM/HETATM records are parsed; format assumes canonical PDB column mapping.
- expand_arr2data(arr)[source]#
Convert array of minimal records to standard data format.
- Parameters:
arr (np.ndarray | list) – Array/list of [atom_type, atom_label, x, y, z].
- Returns:
All parsed data (as for self.data), and extracted rows where note is ‘X’.
- Return type:
Tuple[np.ndarray | None, np.ndarray | None]
Example
data, x_data = pdb_reader.expand_arr2data([[“Fe”, “Fe”, 0.0, 0.0, 0.0]])
- process_node_pdb()[source]#
Read the PDB and prepare node-centered atom sets.
Parses self.data, recenters coordinates for self.com_target_type (default ‘X’), and stores node atoms, coordinates, and “X” atoms.
Note
Intended for node PDB files (metal nodes) in the MOF framework.
- Populates:
self.node_atoms: [atom_type, atom_label] for all atoms
self.node_ccoords: centered coordinates for all atoms
self.node_x_ccoords: centered coordinates for “X” atoms
- Return type:
None