In [2]:
Copied!
import datamol as dm
import datamol as dm
In [3]:
Copied!
# Define a reaction from rxn block finle
rxn = dm.reactions.rxn_from_block_file("data/ReactionBlock.rxn", sanitize=True)
rxn
# Define a reaction from rxn block finle
rxn = dm.reactions.rxn_from_block_file("data/ReactionBlock.rxn", sanitize=True)
rxn
Out[3]:
In [4]:
Copied!
dm.reactions.is_reaction_ok(rxn, enable_logs=True)
dm.reactions.is_reaction_ok(rxn, enable_logs=True)
2022-10-14 12:30:01.734 | INFO | datamol.reactions._reactions:is_reaction_ok:147 - Number of warnings:0 2022-10-14 12:30:01.735 | INFO | datamol.reactions._reactions:is_reaction_ok:148 - Number of preprocessing errors: 0 2022-10-14 12:30:01.735 | INFO | datamol.reactions._reactions:is_reaction_ok:149 - Number of reactants in reaction: 2 2022-10-14 12:30:01.736 | INFO | datamol.reactions._reactions:is_reaction_ok:150 - Number of products in reaction: 1 2022-10-14 12:30:01.736 | INFO | datamol.reactions._reactions:is_reaction_ok:151 - Preprocess labels added:((), ())
Out[4]:
True
In [5]:
Copied!
# Apply reaction and snitize the products
prod_mols = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("CC(=O)O"), dm.to_mol("NC")),
as_smiles=False,
sanitize=True,
single_output=False,
)
dm.to_image(prod_mols, use_svg=False)
# Apply reaction and snitize the products
prod_mols = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("CC(=O)O"), dm.to_mol("NC")),
as_smiles=False,
sanitize=True,
single_output=False,
)
dm.to_image(prod_mols, use_svg=False)
Out[5]:
In [6]:
Copied!
# Return a single product in SMILES and keep the open attachment points
prod_smi_att = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("[2*]CC(=O)O"), dm.to_mol("NC[1*]")),
as_smiles=False,
sanitize=True,
single_output=True,
rm_attach=False,
)
prod_smi_att
# Return a single product in SMILES and keep the open attachment points
prod_smi_att = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("[2*]CC(=O)O"), dm.to_mol("NC[1*]")),
as_smiles=False,
sanitize=True,
single_output=True,
rm_attach=False,
)
prod_smi_att
Out[6]:
In [7]:
Copied!
# Return a single product in SMILES without any open attachment points
prod_smi = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("[2*]CC(=O)O"), dm.to_mol("NC[1*]")),
as_smiles=False,
sanitize=True,
single_output=True,
rm_attach=True,
)
prod_smi
# Return a single product in SMILES without any open attachment points
prod_smi = dm.reactions.apply_reaction(
rxn=rxn,
reactants=(dm.to_mol("[2*]CC(=O)O"), dm.to_mol("NC[1*]")),
as_smiles=False,
sanitize=True,
single_output=True,
rm_attach=True,
)
prod_smi
Out[7]:
In [8]:
Copied!
scaffold = dm.to_mol("O=C(NCc1ccnc([2*])c1)[1*]")
frag1 = dm.to_mol("[1*]OC1CCC1")
frag2 = dm.to_mol("[2*]N1CCCC1")
dm.to_image([scaffold, frag1, frag2], use_svg=False)
scaffold = dm.to_mol("O=C(NCc1ccnc([2*])c1)[1*]")
frag1 = dm.to_mol("[1*]OC1CCC1")
frag2 = dm.to_mol("[2*]N1CCCC1")
dm.to_image([scaffold, frag1, frag2], use_svg=False)
Out[8]:
In [9]:
Copied!
# Define reaction with SMARTS and apply reaction on the specified attachment points
rxn1 = dm.reactions.rxn_from_smarts("[1*][*:1].[1*][*:2]>>[*:1][*:2]")
res1 = dm.reactions.apply_reaction(rxn1, (dm.to_mol(frag1), dm.to_mol(scaffold)), rm_attach=True)
dm.to_image(res1, use_svg=False)
# Define reaction with SMARTS and apply reaction on the specified attachment points
rxn1 = dm.reactions.rxn_from_smarts("[1*][*:1].[1*][*:2]>>[*:1][*:2]")
res1 = dm.reactions.apply_reaction(rxn1, (dm.to_mol(frag1), dm.to_mol(scaffold)), rm_attach=True)
dm.to_image(res1, use_svg=False)
Out[9]:
In [10]:
Copied!
# One reaction to attach multiple specified attchment points
rxn2 = dm.reactions.rxn_from_smarts("[1*][*:1].[2*][*:4].([1*][*:2].[2*][*:3])>>([*:1][*:2].[*:3][*:4])")
res2 = dm.reactions.apply_reaction(rxn2, (frag1, frag2, scaffold))
dm.to_image(res2, use_svg=False)
# One reaction to attach multiple specified attchment points
rxn2 = dm.reactions.rxn_from_smarts("[1*][*:1].[2*][*:4].([1*][*:2].[2*][*:3])>>([*:1][*:2].[*:3][*:4])")
res2 = dm.reactions.apply_reaction(rxn2, (frag1, frag2, scaffold))
dm.to_image(res2, use_svg=False)
Out[10]: