Created
March 30, 2024 08:34
-
-
Save karpanGit/4140c753878c35a8120367f7fabd114e to your computer and use it in GitHub Desktop.
indigo, R-group decomposition with user specified query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the query may be passed by the user directly | |
# prepare query scaffold (e.g. '(R1)C1CC(R3)CCC1(R2)') | |
# scaffold = indigo.loadQueryMoleculeFromFile(r"D:/tmp/query_mol.mol") | |
scaffold = indigo.loadQueryMolecule('C1%91CCC%92CC%931.[*:1]%91.[*:2]%93.[*:3]%92 |$;;;;;;_R1;_R2;_R3$|') | |
# init decomposition | |
deco = indigo.createDecomposer(scaffold) | |
# load molecule | |
# if Br was H it would not match, even with implicit hydrogen atoms | |
# hence need to repeat with multiple queries with R groups removed | |
mol = indigo.loadMolecule('NC1CC(Br)CCC1(O)') # | |
# create deco item | |
item = deco.decomposeMolecule(mol) | |
# iterate over all the decompositions | |
for q_match in item.iterateDecompositions(): | |
print('match') | |
# get decomposed molecule (current match) | |
rg_mol = q_match.decomposedMoleculeWithRGroups() | |
# print structure | |
print(rg_mol.smiles()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment