// return FailedOperation(input_data=input_data.dict(), **ret_data)
if not jmol.connectivity: // Check for empty list
ret_data["error"] = ComputeError(
error_type="input_error", error_message="run_rdkit molecule must have a connectivity graph")
return FailedOperation(input_data=input_data.dict(), **ret_data)
// Build out the base molecule
base_mol = Chem.Mol()
rw_mol = Chem.RWMol(base_mol)
for sym in jmol.symbols:
rw_mol.AddAtom(Chem.Atom(sym.title()))
// Add in connectivity
bond_types = {1: Chem.BondType.SINGLE, 2: Chem.BondType.DOUBLE, 3: Chem.BondType.TRIPLE}
for atom1, atom2, bo in jmol.connectivity:
rw_mol.AddBond(atom1, atom2, bond_types[bo])
mol = rw_mol.GetMol()
// Write out the conformer
natom = len(jmol.symbols)
conf = Chem.Conformer(natom)
bohr2ang = ureg.conversion_factor("bohr", "angstrom")
for line in range(natom):
conf.SetAtomPosition(line, (bohr2ang * jmol.geometry[line, 0],
bohr2ang * jmol.geometry[line, 1],
bohr2ang * jmol.geometry[line, 2])) // yapf: disable
mol.AddConformer(conf)
Chem.rdmolops.SanitizeMol(mol)
if input_data.model.method.lower() == "uff":
ff = AllChem.UFFGetMoleculeForceField(mol)
all_params = AllChem.UFFHasAllMoleculeParams(mol)
else:
ret_data["error"] = ComputeError(
error_type="input_error", error_message="run_rdkit can only accepts UFF methods")
return FailedOperation(input_data=input_data.dict(), **ret_data)
if all_params is False:
ret_data["error"] = ComputeError(
error_type="input_error", error_message="run_rdkit did not match all parameters to molecule")