stk
stk copied to clipboard
Add mutation function which substitutes terminal atomic groups.
It would be nice to add a mutation function which allows the user to specify a query molecule, and a replacement molecule and replace the substructure matched by the query molecule the replacement molecule.
Something like the following code but implemented as a mutation function in stk.
helicene = rdkit.MolFromMolFile('h_oh.mol', removeHs=False, sanitize=False)
query = rdkit.MolFromSmarts('[C][H]')
replacement = rdkit.MolFromSmiles('[N]')
rdkit.EmbedMolecule(replacement, rdkit.ETKDGv2())
new_mols = rdkit.ReplaceSubstructs(helicene, query, replacement)
for i, new_mol in enumerate(new_mols):
rdkit.SanitizeMol(new_mol)
rdkit.UFFOptimizeMolecule(new_mol)
rdkit.MolToMolFile(new_mol, f'new_mol_{i}.mol')
I will be looking into