Read / write¶
Structure and complex I/O helpers, including the STK-to-ASE bridge and
GULP/AMS writers: cage_isomer_builder.utils.read_write.
stk_2_ase_atoms ¶
A function that converts and stk molecular object to an ase atom object.
Parameter:
- stk_atoms: stk molecular object
- pbc : periodic boundary conditions
default is False.
Return:
- ase_atom: ase.Atoms
ASE atom object
- bond_matrix : bond matrix
The bond matrix is essential for force field and maintaining
correct bonding especially when two bonded atoms are far apart
beyond conventional bond cutoff imposed by covalent radii
Source code in cage_isomer_builder/utils/read_write.py
write_to_xyz ¶
A function that writes an ase_atoms to xyz
Parameter: - filename: str name of file to save - ase_atoms : ASE.atoms structure to be written
Source code in cage_isomer_builder/utils/read_write.py
generate_isomer_structure_file ¶
generate_isomer_structure_file(cage, fg_anchors, isomer_descriptor, fg_anchor_indices, output_path, fg_anchor_h_positions=None)
A function to generate and write an XYZ structure file for a single isomer, placing "At" anchor atoms at the active FG slots defined by the isomer descriptor and restoring every other slot to its original, unfunctionalised H atom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cage
|
Atoms
|
The base cage structure containing all FG anchor slots as At atoms. A copy is made internally so the original is not modified. |
required |
fg_anchors
|
Atoms
|
Subset of the cage containing all At anchor atoms with their positions, as returned by functionalise_all_anchors. Used to restore active anchor positions in the isomer. |
required |
isomer_descriptor
|
list of int
|
Base-4 isomer descriptor of length n_linkers, where each element is the global FG anchor slot index active on that linker. e.g. [0, 5, 9, 14] activates slots 0, 5, 9, and 14. |
required |
fg_anchor_indices
|
list of int
|
Indices of all At anchor atoms in the full cage Atoms object, as returned by functionalise_all_anchors. Used to map from isomer_descriptor indices to cage atom indices. |
required |
output_path
|
str
|
Directory path where the XYZ file will be saved. e.g. 'Tet2Di4_isomers/ |
required |
fg_anchor_h_positions
|
(ndarray, shape(len(fg_anchor_indices), 3))
|
Each anchor's original (pre-extension) hydrogen position, aligned
with |
None
|
Source code in cage_isomer_builder/utils/read_write.py
write_host_guest_complex ¶
Write a HostGuestComplex to disk, picking the writer from path's
file extension.
.gin-> GULP molecular-mechanics input, viagulp_setup.mmanalysis.write_gin(UFF4MOF atom types assigned byanalyze_mmfromcomplex_.bond_matrix). Bond orders are taken fromcomplex_.bond_matrixexactly, never re-perceived from the merged host+guest geometry - see place_guest_in_host..run-> AMS geometry-optimisation run script, via utils.read_write.write_run, same bond matrix.- anything else -> plain
ase.io.write(path, atoms). No bond matrix is used (or needed) here, since none of ASE's own formats (xyz, cif, pdb, ...) carry bond order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
complex_
|
HostGuestComplex or Atoms
|
A HostGuestComplex is required for |
required |
path
|
str or Path
|
Output file path; its suffix selects the writer. |
required |
lattice
|
str
|
Forwarded to |
"conv"
|
mechanical
|
bool
|
Forwarded to |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |