shnitsel.bridges¶
This submodule contains functions used to interface with other packages and programs, especially RDKit.
Functions¶
|
Convert an xr.DataArray of molecular geometry to an XYZ string |
|
Convert an entire trajectory's worth of geometries to an XYZ string |
|
Convert a single frame's geometry to an RDKit Mol object |
|
Convert a numbered SMILES-string to a analogically-numbered Mol object |
|
Try many ways to get a representative Mol object for an ensemble: |
|
Convert a geometry to a SMILES-string, retaining atom order |
Module Contents¶
- to_xyz(da, comment='#', units='angstrom')¶
Convert an xr.DataArray of molecular geometry to an XYZ string
- Parameters:
da (shnitsel.core.typedefs.AtXYZ) – A molecular geometry – should have dimensions ‘atom’ and ‘direction’
comment – The comment line for the XYZ, by default ‘#’
units – The units to which to convert before creating the XYZ string
- Return type:
The XYZ data as a string
Notes
The units of the outputs will be the same as the array; consider converting to angstrom first, as most tools will expect this.
- traj_to_xyz(traj_atXYZ, units='angstrom')¶
Convert an entire trajectory’s worth of geometries to an XYZ string
- Parameters:
traj_atXYZ (shnitsel.core.typedefs.AtXYZ) – Molecular geometries – should have dimensions ‘atom’ and ‘direction’; should also be groupable by ‘time’ (i.e. either have a ‘time’ dimension or a ‘time’ coordinate)
units – The units to which to convert before creating the XYZ string
- Return type:
The XYZ data as a string, with time indicated in the comment line of each frame
Notes
The units of the outputs will be the same as the array; consider converting to angstrom first, as most tools will expect this.
- to_mol(atXYZ_frame, charge=None, covFactor=1.2, to2D=True, molAtomMapNumber=None, atomNote=None, atomLabel=None)¶
Convert a single frame’s geometry to an RDKit Mol object
- Parameters:
atXYZ_frame (shnitsel.core.typedefs.AtXYZ) – The
xr.DataArrayobject to be converted; must have ‘atom’ and ‘direction’ dims, must not have ‘frame’ dim.charge (int | None) – Charge of the molecule, used by RDKit to determine bond orders; if
None(the default), this function will trycharge=0and leave the bond orders undetermined if that causes an error; otherwise failure to determine bond order will raise an error.covFactor (float) – Scales the distance at which atoms are considered bonded, by default 1.2
to2D (bool) – Discard 3D information and generate 2D conformer (useful for displaying), by default True
molAtomMapNumber (list | Literal[True] | None) – Set the
molAtomMapNumberproperties to values provided in a list, or (ifTrueis passed) set the properties to the respective atom indicesatomNote (list | Literal[True] | None) – Behaves like the
molAtomMapNumberparameter above, but for theatomNotepropertiesatomLabel (list | Literal[True] | None) – Behaves like the
molAtomMapNumberparameter above, but for theatomLabelproperties
- Return type:
An RDKit Mol object
- Raises:
ValueError – If
chargeis notNoneand bond order determination fails
- numbered_smiles_to_mol(smiles)¶
Convert a numbered SMILES-string to a analogically-numbered Mol object
- Parameters:
smiles (str) – A SMILES string in which each atom is associated with a mapping index, e.g. ‘[H:3][C:1]#[C:0][H:2]’
- Returns:
An
rdkit.Chem.Mol()object with atom indices numbered accordingto the indices from the SMILES-string
- Return type:
rdkit.Chem.Mol
- default_mol(obj)¶
Try many ways to get a representative Mol object for an ensemble:
Use the
molattr (of either obj or obj[‘atXYZ’]) directly
2. Feed the
smiles_mapattr (of eitherobjorobj['atXYZ']) toshnitsel.bridges.default_mol()3. Take the geometry from the first frame of the molecule and the charge specified in thechargeattr (charge=0 assumed if not specified) and feed these toshnitsel.bridges.to_mol()- Parameters:
obj – An ‘atXYZ’ xr.DataArray with molecular geometries or an xr.Dataset containing the above as one of its variables
- Return type:
An rdkit.Chem.Mol object
- Raises:
ValueError – If the final approach fails
- smiles_map(atXYZ_frame, charge=0, covFactor=1.5)¶
Convert a geometry to a SMILES-string, retaining atom order
- Parameters:
atXYZ_frame – An xr.DataArray of molecular geometry
charge – The charge of the molcule, by default 0
optional – The charge of the molcule, by default 0
covFactor – Scales the distance at which atoms are considered bonded, by default 1.5
optional – Scales the distance at which atoms are considered bonded, by default 1.5
- Returns:
A SMILES-string in which the mapping number indicates the order in which the
atoms appeared in the input matrix, e.g. ‘[H (3][C:1]#[C:0][H:2]’)
- Return type: