aamutils 0.0.2__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aamutils-0.0.2 → aamutils-0.0.4}/PKG-INFO +5 -5
- {aamutils-0.0.2 → aamutils-0.0.4}/README.md +4 -4
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/utils.py +59 -2
- {aamutils-0.0.2 → aamutils-0.0.4}/benchmark.py +12 -2
- {aamutils-0.0.2 → aamutils-0.0.4}/pyproject.toml +1 -1
- {aamutils-0.0.2 → aamutils-0.0.4}/.github/workflows/publish-package.yml +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/.github/workflows/test-and-lint.yml +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/.gitignore +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/LICENSE +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/Makefile +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/__init__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/__main__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/algorithm/__init__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/algorithm/aaming.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/algorithm/ilp.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/cmd/__init__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/aamutils/cmd/expanding.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/conf.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/data/test_dataset.json +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/doc/getting_started.rst +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/doc/reference.rst +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/index.rst +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/lint.sh +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/make.bat +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/requirements.txt +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/test/__init__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/test/algorithm/__init__.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/test/algorithm/test_aaming.py +0 -0
- {aamutils-0.0.2 → aamutils-0.0.4}/test/algorithm/test_ilp.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: aamutils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Collection of atom-atom-mapping utility functions.
|
|
5
5
|
Project-URL: homepage, https://github.com/klausweinbauer/AAMUtils
|
|
6
6
|
Project-URL: source, https://github.com/klausweinbauer/AAMUtils
|
|
@@ -78,18 +78,18 @@ reported results can be reproduced by running the following commands:
|
|
|
78
78
|
### (1) Extend partial reaction center (50%, 75% and 100% missing atoms)
|
|
79
79
|
|
|
80
80
|
```
|
|
81
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 0.5
|
|
81
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 0.5 --seed 42
|
|
82
82
|
```
|
|
83
83
|
```
|
|
84
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 0.75
|
|
84
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 0.75 --seed 42
|
|
85
85
|
```
|
|
86
86
|
```
|
|
87
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 1
|
|
87
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 1 --seed 42
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
### (2) Extend partial AAM with fully mapped RC
|
|
91
91
|
```
|
|
92
|
-
python3 benchmark.py --remove-mode keep_rc --remove-ratio 1
|
|
92
|
+
python3 benchmark.py --remove-mode keep_rc --remove-ratio 1 --seed 42
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
|
|
@@ -56,18 +56,18 @@ reported results can be reproduced by running the following commands:
|
|
|
56
56
|
### (1) Extend partial reaction center (50%, 75% and 100% missing atoms)
|
|
57
57
|
|
|
58
58
|
```
|
|
59
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 0.5
|
|
59
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 0.5 --seed 42
|
|
60
60
|
```
|
|
61
61
|
```
|
|
62
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 0.75
|
|
62
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 0.75 --seed 42
|
|
63
63
|
```
|
|
64
64
|
```
|
|
65
|
-
python3 benchmark.py --remove-mode rc --remove-ratio 1
|
|
65
|
+
python3 benchmark.py --remove-mode rc --remove-ratio 1 --seed 42
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
### (2) Extend partial AAM with fully mapped RC
|
|
69
69
|
```
|
|
70
|
-
python3 benchmark.py --remove-mode keep_rc --remove-ratio 1
|
|
70
|
+
python3 benchmark.py --remove-mode keep_rc --remove-ratio 1 --seed 42
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
|
|
@@ -3,6 +3,7 @@ import numpy as np
|
|
|
3
3
|
import networkx as nx
|
|
4
4
|
import rdkit.Chem as Chem
|
|
5
5
|
import rdkit.Chem.rdmolfiles as rdmolfiles
|
|
6
|
+
import rdkit.Chem.rdDepictor as rdDepictor
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def mol_to_graph(mol: Chem.rdchem.Mol) -> nx.Graph:
|
|
@@ -26,6 +27,16 @@ def mol_to_graph(mol: Chem.rdchem.Mol) -> nx.Graph:
|
|
|
26
27
|
return g
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
def smiles_to_graph(smiles: str) -> nx.Graph | tuple[nx.Graph, nx.Graph]:
|
|
31
|
+
if ">>" in smiles:
|
|
32
|
+
smiles_token = smiles.split(">>")
|
|
33
|
+
g = mol_to_graph(rdmolfiles.MolFromSmiles(smiles_token[0]))
|
|
34
|
+
h = mol_to_graph(rdmolfiles.MolFromSmiles(smiles_token[1]))
|
|
35
|
+
return g, h
|
|
36
|
+
else:
|
|
37
|
+
return mol_to_graph(rdmolfiles.MolFromSmiles(smiles))
|
|
38
|
+
|
|
39
|
+
|
|
29
40
|
def graph_to_mol(
|
|
30
41
|
G: nx.Graph, symbol_key="symbol", aam_key="aam", bond_type_key="bond"
|
|
31
42
|
) -> Chem.rdchem.Mol:
|
|
@@ -37,13 +48,16 @@ def graph_to_mol(
|
|
|
37
48
|
1.5: Chem.rdchem.BondType.AROMATIC,
|
|
38
49
|
}
|
|
39
50
|
rw_mol = Chem.rdchem.RWMol()
|
|
51
|
+
idx_map = {}
|
|
40
52
|
for n, d in G.nodes(data=True):
|
|
41
53
|
idx = rw_mol.AddAtom(Chem.rdchem.Atom(d[symbol_key]))
|
|
54
|
+
idx_map[n] = idx
|
|
42
55
|
if aam_key in d.keys() and d[aam_key] >= 0:
|
|
43
56
|
rw_mol.GetAtomWithIdx(idx).SetAtomMapNum(d[aam_key])
|
|
44
|
-
assert n == idx
|
|
45
57
|
for n1, n2, d in G.edges(data=True):
|
|
46
|
-
|
|
58
|
+
idx1 = idx_map[n1]
|
|
59
|
+
idx2 = idx_map[n2]
|
|
60
|
+
rw_mol.AddBond(idx1, idx2, bond_order_map[d[bond_type_key]])
|
|
47
61
|
return rw_mol.GetMol()
|
|
48
62
|
|
|
49
63
|
|
|
@@ -123,3 +137,46 @@ def print_graph(graph):
|
|
|
123
137
|
)
|
|
124
138
|
)
|
|
125
139
|
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def its2mol(its: nx.Graph, aam_key="aam", bond_key="bond") -> Chem.rdchem.Mol:
|
|
143
|
+
_its = its.copy()
|
|
144
|
+
for n in _its.nodes:
|
|
145
|
+
_its.nodes[n][aam_key] = n
|
|
146
|
+
for u, v in _its.edges():
|
|
147
|
+
_its[u][v][bond_key] = 1
|
|
148
|
+
return graph_to_mol(_its)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def plot_its(its, ax, bond_key="bond", aam_key="aam", symbol_key="symbol"):
|
|
152
|
+
bond_char = {None: "∅", 1: "—", 2: "=", 3: "≡"}
|
|
153
|
+
mol = its2mol(its, aam_key=aam_key, bond_key=bond_key)
|
|
154
|
+
|
|
155
|
+
positions = {}
|
|
156
|
+
conformer = rdDepictor.Compute2DCoords(mol)
|
|
157
|
+
for i, atom in enumerate(mol.GetAtoms()):
|
|
158
|
+
aam = atom.GetAtomMapNum()
|
|
159
|
+
apos = mol.GetConformer(conformer).GetAtomPosition(i)
|
|
160
|
+
positions[aam] = [apos.x, apos.y]
|
|
161
|
+
|
|
162
|
+
ax.axis("equal")
|
|
163
|
+
ax.axis("off")
|
|
164
|
+
|
|
165
|
+
nx.draw_networkx_edges(its, positions, edge_color="#000000", ax=ax)
|
|
166
|
+
nx.draw_networkx_nodes(its, positions, node_color="#FFFFFF", node_size=500, ax=ax)
|
|
167
|
+
|
|
168
|
+
labels = {n: "{}:{}".format(d[symbol_key], n) for n, d in its.nodes(data=True)}
|
|
169
|
+
edge_labels = {}
|
|
170
|
+
for u, v, d in its.edges(data=True):
|
|
171
|
+
bc1 = d[bond_key][0]
|
|
172
|
+
bc2 = d[bond_key][1]
|
|
173
|
+
if bc1 == bc2:
|
|
174
|
+
continue
|
|
175
|
+
if bc1 in bond_char.keys():
|
|
176
|
+
bc1 = bond_char[bc1]
|
|
177
|
+
if bc2 in bond_char.keys():
|
|
178
|
+
bc2 = bond_char[bc2]
|
|
179
|
+
edge_labels[(u, v)] = "({},{})".format(bc1, bc2)
|
|
180
|
+
|
|
181
|
+
nx.draw_networkx_labels(its, positions, labels=labels, ax=ax)
|
|
182
|
+
nx.draw_networkx_edge_labels(its, positions, edge_labels=edge_labels, ax=ax)
|
|
@@ -50,7 +50,9 @@ def load_data():
|
|
|
50
50
|
return data
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def run(n, remove_mode, remove_ratio):
|
|
53
|
+
def run(n, remove_mode, remove_ratio, seed=None):
|
|
54
|
+
if seed is not None:
|
|
55
|
+
random.seed(seed)
|
|
54
56
|
data = load_data()
|
|
55
57
|
testcase_cnt = 0
|
|
56
58
|
success_cnt = 0
|
|
@@ -136,6 +138,7 @@ if __name__ == "__main__":
|
|
|
136
138
|
default_rm_mode = "rc"
|
|
137
139
|
default_rm_ratio = 0.5
|
|
138
140
|
default_n = 1000
|
|
141
|
+
default_seed = None
|
|
139
142
|
|
|
140
143
|
parser = argparse.ArgumentParser(
|
|
141
144
|
prog="benchmarks.py",
|
|
@@ -171,6 +174,13 @@ if __name__ == "__main__":
|
|
|
171
174
|
+ " Default: {}"
|
|
172
175
|
).format(default_rm_ratio),
|
|
173
176
|
)
|
|
177
|
+
parser.add_argument(
|
|
178
|
+
"--seed",
|
|
179
|
+
default=default_seed,
|
|
180
|
+
help=(
|
|
181
|
+
"The seed used to initialize random number generation. " + "Default: {}"
|
|
182
|
+
).format(default_seed),
|
|
183
|
+
)
|
|
174
184
|
|
|
175
185
|
args = parser.parse_args()
|
|
176
|
-
run(args.n, args.remove_mode, args.remove_ratio)
|
|
186
|
+
run(args.n, args.remove_mode, args.remove_ratio, args.seed)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|