mofbuilder.io.CifWriter#
- class mofbuilder.io.CifWriter(comm=None, ostream=None, filepath=None, debug=False)[source]#
Bases:
objectWriter for crystallographic CIF files (Crystallographic Information File, .cif).
Handles CIF file creation in parallel MPI environments, with proper cell and atom formatting for MOF and other crystalline data.
- Parameters:
comm (Any | None)
ostream (veloxchem.outputstream.OutputStream | None)
filepath (str | None)
debug (bool)
- comm#
MPI communicator.
- Type:
Any
- rank#
MPI process rank.
- Type:
int
- nodes#
Number of MPI processes.
- Type:
int
- ostream#
Output stream for status messages or debugging.
- Type:
OutputStream
- filepath#
Default path to write CIF files.
- Type:
Optional[Path]
- _debug#
Enables debug-level status messages if True.
- Type:
bool
- cell_info#
Placeholder for unit cell parameters.
- Type:
Optional[Any]
- supercell_boundary#
Placeholder for supercell dimensions.
- Type:
Optional[Any]
- unit_cell#
Placeholder for unit cell dimensions.
- Type:
Optional[Any]
- file_dir#
Directory where the CIF will be written (set in write()).
- Type:
Optional[Path]
- write()[source]#
Writes a CIF file given cell, boundary, and atom data.
- Parameters:
filepath (str | None)
header (str)
lines (List[List[Any]])
supercell_boundary (List[float] | None)
cell_info (List[float] | None)
- Return type:
None
- write(filepath=None, header='', lines=[], supercell_boundary=None, cell_info=None)[source]#
Write data to a CIF file.
This method writes atomic, cell, and symmetry data to a new or existing CIF file in the standard format. Used in the context of crystal structures generated by mofbuilder.
- Parameters:
filepath (Optional[str]) – Output file path (.cif will be appended if missing).
header (str) – Optional string describing the creation method.
lines (List[List[Any]]) – Each sublist contains atom data in the form [atom_type, atom_label, atom_number, residue_name, residue_number, x, y, z, spin, charge, note].
supercell_boundary (Optional[List[float]]) – Max [x, y, z] of the supercell; used to normalize coordinates.
cell_info (Optional[List[float]]) – Cell parameters [a, b, c, alpha, beta, gamma].
- Raises:
AssertionError – If no output filepath is specified.
ValueError – If required parameters (lines, boundary, cell_info) are missing or malformed.
- Return type:
None
Example
>>> writer = CifWriter() >>> writer.write( ... filepath="my_structure.cif", ... header="MOFbuilder v1.0", ... lines=[["C", "C1", 1, "RES", 1, 1.0, 2.0, 3.0, 1.0, 0.0, ""]], ... supercell_boundary=[10.0,10.0,10.0], ... cell_info=[10.0,10.0,10.0,90.0,90.0,90.0] ... )