xyz_to_rdmol¶
xyz_to_rdmol is a core function for reconstructing molecular graphs (bonds) from atomic coordinates.
Convert an XYZ block to a RDKit molecule.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
xyz_block
|
str
|
The XYZ block of a molecule. |
必需 |
total_charge
|
int
|
The total charge of the molecule. Defaults to 0. |
0
|
total_radical_electrons
|
int
|
The total radical electrons of the molecule. Defaults to 0. |
0
|
make_dative
|
bool
|
Whether to make dative bonds. Defaults to True. |
True
|
返回:
| 类型 | 描述 |
|---|---|
Mol | None
|
Chem.Mol: The RDKit molecule. |
源代码位于: src/molop/structure/__init__.py
Python
def xyz_to_rdmol(
xyz_block: str,
total_charge: int = 0,
total_radical_electrons: int = 0,
make_dative: bool = True,
) -> Chem.Mol | None:
"""
Convert an XYZ block to a RDKit molecule.
Parameters:
xyz_block (str): The XYZ block of a molecule.
total_charge (int, optional): The total charge of the molecule. Defaults to 0.
total_radical_electrons (int, optional): The total radical electrons of the molecule. Defaults to 0.
make_dative (bool, optional): Whether to make dative bonds. Defaults to True.
Returns:
Chem.Mol: The RDKit molecule.
"""
possible_omol = xyz2omol(xyz_block, total_charge, total_radical_electrons)
if possible_omol is None:
return None
rdmol_opt = omol_to_rdmol(possible_omol, total_charge, total_radical_electrons)
if rdmol_opt is None:
return None
if make_dative:
return make_dative_bonds(Chem.RWMol(rdmol_opt))
return rdmol_opt