-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_one_tree.py
26 lines (18 loc) · 927 Bytes
/
run_one_tree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# ограничения на дерево + правила 1 без С-Н
import pandas as pd
from mechanisms_tree import Tree
from pseudoatoms_dict import pseudoatoms_dict
from pickle import dump
# test_reactions_df = pd.read_csv('test_mechanisms.csv', sep=';')
root_molecules_smiles = '[H+].[H]ON=C(C([H])([H])C([H])([H])[H])C([H])([H])C([H])([H])[H]'
products_smiles = '[H]N(C(=O)C([H])([H])C([H])([H])[H])C([H])([H])C([H])([H])[H]'
with open('rules/rules3.smarts') as file:
rules_smarts = file.read().split('\n')
tree = Tree(root_molecules_smiles, products_smiles, limit_depth=8, limit_nodes_count=1000)
tree.grow_tree(rules_smarts, pseudoatoms_dict)
paths_starts = tree.paths_starts()
with open(f'results/trees/tree.pkl', 'wb') as file:
dump(tree, file)
with open(f'results/trees/paths_starts_tree.txt', 'w') as file:
for j in paths_starts:
file.write(str(j) + '\n')