Assembly

assembly related functions

source

AssemblyPool

 AssemblyPool (items:list[Molecule])

Initialize self. See help(type(self)) for accurate signature.

pool = AssemblyPool([Molecule('C'), Molecule('CCCCC')])
assert len(pool)==2
def filter_func(molecule):
    return len(molecule.smile)>1

pool2 = pool.filter(filter_func)
assert len(pool2)==1

pool = AssemblyPool([Molecule('C'), Molecule('C'), Molecule('C')])
pool = pool.deduplicate(lambda x: x.smile)
assert len(pool)==1

source

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.


source

Node

 Node (name:str, template:Optional[Template]=None)

Initialize self. See help(type(self)) for accurate signature.


source

FragmentNode

 FragmentNode (name:str, children:list[FragmentNode],
               template:Optional[Template]=None)

Initialize self. See help(type(self)) for accurate signature.


source

FragmentLeafNode

 FragmentLeafNode (name:str, mapping_idxs:list[int],
                   template:Optional[Template]=None)

Initialize self. See help(type(self)) for accurate signature.

f1 = ['[*:1]C', '[*:1]N', '[*:2]O']
f2 = ['[*:1]CC', '[*:1]CCC']

m1 = [Molecule(i) for i in f1]
m2 = [Molecule(i) for i in f2]

p1 = AssemblyPool(m1)
p2 = AssemblyPool(m2)

assembly_dict = {
    'R1' : p1,
    'R2' : p2
}

assembly_inputs = AssemblyInputs(assembly_dict, 10000, 1e8)

r1 = FragmentLeafNode('R1', [1])
r2 = FragmentLeafNode('R2', [1])
full = FragmentNode('F', [r1, r2])

out = full.assemble(assembly_inputs)

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
  }
 ]
}

source

SynthonPool

 SynthonPool (items:list[Synthon])

Initialize self. See help(type(self)) for accurate signature.


source

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)

source

add_rxn

 add_rxn (pair:Tuple[chem_templates.building_blocks.Synthon,chem_templates
          .building_blocks.Synthon],
          rxn_universe:chem_templates.building_blocks.ReactionUniverse)

source

make_pairs_chunked

 make_pairs_chunked (pool1:__main__.SynthonPool,
                     pool2:__main__.SynthonPool, chunksize:int)

source

make_pairs

 make_pairs (pool1:__main__.SynthonPool, pool2:__main__.SynthonPool)

source

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.


source

SynthonLeafNode

 SynthonLeafNode (name:str, n_func:set[int],
                  template:Optional[Template]=None)

Initialize self. See help(type(self)) for accurate signature.

p1 = SynthonPool([Synthon('O=C(O)CCN[CH:10]=O'), Synthon('O=C(O)CCCN[CH:10]=O')])
p2 = SynthonPool([Synthon('CCOC(=O)c1c([NH2:20])sc2c1CCNC2'), Synthon('C1CN(C2CC[NH:20]C2)CCN1')])
rxn_universe = ReactionUniverse('all_rxns', REACTION_GROUPS)

bb1 = SynthonLeafNode('bb1', set([1]))
bb2 = SynthonLeafNode('bb2', set([1]))
prod = SynthonNode('product', bb1, bb2, rxn_universe, set([0]))

input_dict = {
    'bb1' : p1,
    'bb2' : p2
}

inputs = AssemblyInputs(input_dict, 10000, 10000)

outputs = prod.assemble(inputs, verbose=True)
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}}

source

build_synthesis_scheme

 build_synthesis_scheme (synthon:chem_templates.building_blocks.Synthon)
bb1 = SynthonLeafNode('bb1', set([1]))
bb2 = SynthonLeafNode('bb2', set([2]))
prod1 = SynthonNode('product1', bb1, bb2, rxn_universe, set([1]))
bb3 = SynthonLeafNode('bb3', set([1]))
prod2 = SynthonNode('product2', prod1, bb3, rxn_universe, set([0]))

mol1 = Molecule('Nc1cc(O)c(Br)cc1Br', {'ID' : 'EN300-104251'})
mol2 = Molecule('CCOC(=O)c1c(C)[nH]c(C(=O)C(C)Cl)c1C', {'ID' : 'EN300-08472'})
mol3 = Molecule('O=C(O)C1(Cc2ccc(Br)cc2F)CCCNC1', {'ID' : 'EN300-6745292'})

p1 = SynthonPool(molecule_to_synthon(mol1))
p2 = SynthonPool(molecule_to_synthon(mol2))
p3 = SynthonPool(molecule_to_synthon(mol3))

input_dict = {
    'bb1' : p1,
    'bb2' : p2,
    'bb3' : p3
}

inputs = AssemblyInputs(input_dict, 10000, 10000)

outputs = prod2.assemble(inputs, verbose=False)

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"
    ]
  }
}

source

build_fragment_assembly_scheme

 build_fragment_assembly_scheme (molecule:chem_templates.chem.Molecule)
f1 = ['[*:1]C', '[*:1]N', '[*:2]O']
f2 = ['[*:1]CC', '[*:1]CCC']

m1 = [Molecule(i, data={'test1':'test1'}) for i in f1]
m2 = [Molecule(i, data={'test2':'test2'}) for i in f2]

p1 = AssemblyPool(m1)
p2 = AssemblyPool(m2)

assembly_dict = {
    'R1' : p1,
    'R2' : p2
}

assembly_inputs = AssemblyInputs(assembly_dict, 10000, 1e8)

r1 = FragmentLeafNode('R1', [1])
r2 = FragmentLeafNode('R2', [1])
full = FragmentNode('F', [r1, r2])

outputs = full.assemble(assembly_inputs)

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]"
  }
}

source

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
  }
 ]
}

assembly_schema = build_assembly_from_dict(schema1)

schema2 = {'name': 'product',
 '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}}

assembly_schema = build_assembly_from_dict(schema2)