from_mol#

biotite.interface.rdkit.from_mol(mol, conformer_id=None, add_hydrogen=None)[source]#

Convert a rdkit.Chem.rdchem.Mol into an AtomArray or AtomArrayStack.

Parameters:
molrdkit.Chem.rdchem.Mol

The molecule to be converted.

conformer_idint or {“2D”, “3D”}, optional

The ID of the conformer to be converted. If set to “2D” or “3D”, an AtomArrayStack with only the 2D or 3D conformer is returned, respectively. By default, an AtomArrayStack with all conformers (2D and 3D) is returned.

add_hydrogenbool, optional

If set to true, explicit hydrogen atoms are always added. If set to false, explicit hydrogen atoms are never added. By default, explicit hydrogen atoms are only added, if hydrogen atoms are not already present.

Returns:
atomsAtomArray or AtomArrayStack

The converted atoms. An AtomArray is returned if an integer conformer_id is given. Otherwise, an AtomArrayStack is returned. If the input mol does not have a conformer, an AtomArrayStack with a single model, where all coordinates are NaN, is returned.

Notes

The atoms in the return value are in the same order as the input mol, i.e. indices pointing to the rdkit.Chem.rdchem.Mol can be used to point to the same atoms in the AtomArray.

All atom-level properties of mol (obtainable with rdkit.Chem.rdchem.Mol.GetProp()) are added as annotation array with the same name. element and charge are not inferred from properties but from the dedicated attributes in the rdkit.Chem.rdchem.Mol object.

Examples

>>> from rdkit.Chem import MolFromSmiles
>>> from rdkit.Chem.rdDistGeom import EmbedMolecule
>>> from rdkit.Chem.rdForceFieldHelpers import UFFOptimizeMolecule
>>> from rdkit.Chem.rdmolops import AddHs
>>> mol = MolFromSmiles("C[C@@H](C(=O)O)N")
>>> mol = AddHs(mol)
>>> # Create a 3D conformer
>>> conformer_id = EmbedMolecule(mol)
>>> UFFOptimizeMolecule(mol)
0
>>> alanine_atom_array = from_mol(mol, conformer_id)
>>> # RDKit does not assign atom names -> for convenience, do this in Biotite
>>> alanine_atom_array.atom_name = create_atom_names(alanine_atom_array)
>>> print(alanine_atom_array)
            0      C1     C        -1.076    1.102   -0.094
            0      C2     C        -0.363   -0.246   -0.218
            0      C3     C         1.129   -0.073   -0.109
            0      O1     O         1.644    0.373    0.952
            0      O2     O         1.943   -0.405   -1.187
            0      N1     N        -0.861   -1.175    0.798
            0      H1     H        -0.724    1.795   -0.888
            0      H2     H        -2.171    0.960   -0.212
            0      H3     H        -0.881    1.561    0.899
            0      H4     H        -0.600   -0.664   -1.221
            0      H5     H         2.949   -0.295   -1.132
            0      H6     H        -0.595   -0.830    1.750
            0      H7     H        -0.395   -2.102    0.660