= AssemblyPool([Molecule('C'), Molecule('CCCCC')])
pool assert len(pool)==2
def filter_func(molecule):
return len(molecule.smile)>1
= pool.filter(filter_func)
pool2 assert len(pool2)==1
= AssemblyPool([Molecule('C'), Molecule('C'), Molecule('C')])
pool = pool.deduplicate(lambda x: x.smile)
pool assert len(pool)==1
Assembly
assembly related functions
AssemblyPool
AssemblyPool (items:list[Molecule])
Initialize self. See help(type(self)) for accurate signature.
AssemblyInputs
AssemblyInputs (pool_dict:dict[str,AssemblyPool], assembly_chunksize:int, max_assemblies_per_node:int, worker_pool:Optional[Pool]=None, log:bool=True)
Initialize self. See help(type(self)) for accurate signature.
Node
Node (name:str, template:Optional[Template]=None)
Initialize self. See help(type(self)) for accurate signature.
FragmentNode
FragmentNode (name:str, children:list[FragmentNode], template:Optional[Template]=None)
Initialize self. See help(type(self)) for accurate signature.
FragmentLeafNode
FragmentLeafNode (name:str, mapping_idxs:list[int], template:Optional[Template]=None)
Initialize self. See help(type(self)) for accurate signature.
= ['[*:1]C', '[*:1]N', '[*:2]O']
f1 = ['[*:1]CC', '[*:1]CCC']
f2
= [Molecule(i) for i in f1]
m1 = [Molecule(i) for i in f2]
m2
= AssemblyPool(m1)
p1 = AssemblyPool(m2)
p2
= {
assembly_dict 'R1' : p1,
'R2' : p2
}
= AssemblyInputs(assembly_dict, 10000, 1e8)
assembly_inputs
= FragmentLeafNode('R1', [1])
r1 = FragmentLeafNode('R2', [1])
r2 = FragmentNode('F', [r1, r2])
full
= full.assemble(assembly_inputs)
out
assert len(out)==4
print(json.dumps(full.dump(), indent=1))
{
"name": "F",
"node_type": "fragment_node",
"template": null,
"children": [
{
"name": "R1",
"node_type": "fragment_leaf_node",
"mapping_idxs": [
1
],
"template": null
},
{
"name": "R2",
"node_type": "fragment_leaf_node",
"mapping_idxs": [
1
],
"template": null
}
]
}
SynthonPool
SynthonPool (items:list[Synthon])
Initialize self. See help(type(self)) for accurate signature.
make_assemblies
make_assemblies (pool1:__main__.SynthonPool, pool2:__main__.SynthonPool, rxn_universe:chem_templates.building_blocks.ReactionUniv erse, chunksize:int, worker_pool:Optional[<boundmethodBa seContext.Poolof<multiprocessing.context.DefaultContexto bjectat0x7fce59bc5130>>]=None)
add_rxn
add_rxn (pair:Tuple[chem_templates.building_blocks.Synthon,chem_templates .building_blocks.Synthon], rxn_universe:chem_templates.building_blocks.ReactionUniverse)
make_pairs_chunked
make_pairs_chunked (pool1:__main__.SynthonPool, pool2:__main__.SynthonPool, chunksize:int)
make_pairs
make_pairs (pool1:__main__.SynthonPool, pool2:__main__.SynthonPool)
SynthonNode
SynthonNode (name:str, incoming_node:SynthonNode, next_node:SynthonNode, rxn_universe:ReactionUniverse, n_func:set[int], template:Optional[Template]=None)
Initialize self. See help(type(self)) for accurate signature.
SynthonLeafNode
SynthonLeafNode (name:str, n_func:set[int], template:Optional[Template]=None)
Initialize self. See help(type(self)) for accurate signature.
= SynthonPool([Synthon('O=C(O)CCN[CH:10]=O'), Synthon('O=C(O)CCCN[CH:10]=O')])
p1 = SynthonPool([Synthon('CCOC(=O)c1c([NH2:20])sc2c1CCNC2'), Synthon('C1CN(C2CC[NH:20]C2)CCN1')])
p2 = ReactionUniverse('all_rxns', REACTION_GROUPS)
rxn_universe
= SynthonLeafNode('bb1', set([1]))
bb1 = SynthonLeafNode('bb2', set([1]))
bb2 = SynthonNode('product', bb1, bb2, rxn_universe, set([0]))
prod
= {
input_dict 'bb1' : p1,
'bb2' : p2
}
= AssemblyInputs(input_dict, 10000, 10000)
inputs
= prod.assemble(inputs, verbose=True)
outputs assert len(outputs) == 4
prod.dump()
bb1
bb2
product
{'name': 'product',
'node_type': 'synthon_node',
'n_func': {0},
'template': None,
'rxn_universe': <chem_templates.building_blocks.ReactionUniverse>,
'incoming_node': {'name': 'bb1',
'node_type': 'synthon_leaf_node',
'n_func': {1},
'template': None},
'next_node': {'name': 'bb2',
'node_type': 'synthon_leaf_node',
'n_func': {1},
'template': None}}
build_synthesis_scheme
build_synthesis_scheme (synthon:chem_templates.building_blocks.Synthon)
= SynthonLeafNode('bb1', set([1]))
bb1 = SynthonLeafNode('bb2', set([2]))
bb2 = SynthonNode('product1', bb1, bb2, rxn_universe, set([1]))
prod1 = SynthonLeafNode('bb3', set([1]))
bb3 = SynthonNode('product2', prod1, bb3, rxn_universe, set([0]))
prod2
= Molecule('Nc1cc(O)c(Br)cc1Br', {'ID' : 'EN300-104251'})
mol1 = Molecule('CCOC(=O)c1c(C)[nH]c(C(=O)C(C)Cl)c1C', {'ID' : 'EN300-08472'})
mol2 = Molecule('O=C(O)C1(Cc2ccc(Br)cc2F)CCCNC1', {'ID' : 'EN300-6745292'})
mol3
= SynthonPool(molecule_to_synthon(mol1))
p1 = SynthonPool(molecule_to_synthon(mol2))
p2 = SynthonPool(molecule_to_synthon(mol3))
p3
= {
input_dict 'bb1' : p1,
'bb2' : p2,
'bb3' : p3
}
= AssemblyInputs(input_dict, 10000, 10000)
inputs
= prod2.assemble(inputs, verbose=False)
outputs
print(json.dumps(build_synthesis_scheme(outputs[0]), indent=2))
{
"result": "CCOC(=O)c1c(C)c(C(=O)C(C)Oc2cc(N)c(Br)cc2Br)n(C(=O)C2(Cc3ccc(Br)cc3F)CCCNC2)c1C",
"is_input": false,
"assembly_data": {
"parents": [
{
"result": "CCOC(=O)c1c(C)c(C(=O)C(C)Oc2cc(N)c(Br)cc2Br)[nH:20]c1C",
"is_input": false,
"assembly_data": {
"parents": [
{
"input": "Nc1cc(O)c(Br)cc1Br",
"is_input": true,
"data": {
"ID": "EN300-104251"
}
},
{
"input": "CCOC(=O)c1c(C)[nH]c(C(=O)C(C)Cl)c1C",
"is_input": true,
"data": {
"ID": "EN300-08472"
}
}
],
"reaction_tags": [
"O-SN alkylation"
]
}
},
{
"input": "O=C(O)C1(Cc2ccc(Br)cc2F)CCCNC1",
"is_input": true,
"data": {
"ID": "EN300-6745292"
}
}
],
"reaction_tags": [
"nH-Cu-mediated C-N coupling"
]
}
}
build_fragment_assembly_scheme
build_fragment_assembly_scheme (molecule:chem_templates.chem.Molecule)
= ['[*:1]C', '[*:1]N', '[*:2]O']
f1 = ['[*:1]CC', '[*:1]CCC']
f2
= [Molecule(i, data={'test1':'test1'}) for i in f1]
m1 = [Molecule(i, data={'test2':'test2'}) for i in f2]
m2
= AssemblyPool(m1)
p1 = AssemblyPool(m2)
p2
= {
assembly_dict 'R1' : p1,
'R2' : p2
}
= AssemblyInputs(assembly_dict, 10000, 1e8)
assembly_inputs
= FragmentLeafNode('R1', [1])
r1 = FragmentLeafNode('R2', [1])
r2 = FragmentNode('F', [r1, r2])
full
= full.assemble(assembly_inputs)
outputs
print(json.dumps(build_fragment_assembly_scheme(outputs[0]), indent=2))
{
"result": "CCC",
"is_input": false,
"assembly_data": {
"parents": [
{
"input": "C[*:1]",
"is_input": true,
"data": {
"test1": "test1"
}
},
{
"input": "CC[*:1]",
"is_input": true,
"data": {
"test2": "test2"
}
}
],
"input_smiles": "C[*:1].CC[*:1]"
}
}
build_assembly_from_dict
build_assembly_from_dict (assembly_schema:dict)
= {
schema1 "name": "F",
"node_type": "fragment_node",
"template": None,
"children": [
{"name": "R1",
"node_type": "fragment_leaf_node",
"mapping_idxs": [1],
"template": None
},
{"name": "R2",
"node_type": "fragment_leaf_node",
"mapping_idxs": [1],
"template": None
}
]
}
= build_assembly_from_dict(schema1)
assembly_schema
= {'name': 'product',
schema2 'node_type': 'synthon_node',
'n_func': {0},
'template': None,
'rxn_universe': ReactionUniverse('all_rxns', REACTION_GROUPS),
'incoming_node': {'name': 'bb1',
'node_type': 'synthon_leaf_node',
'n_func': {1},
'template': None},
'next_node': {'name': 'bb2',
'node_type': 'synthon_leaf_node',
'n_func': {1},
'template': None}}
= build_assembly_from_dict(schema2) assembly_schema