rxnmapper 0.3.0__tar.gz → 0.3.1__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.
- {rxnmapper-0.3.0/rxnmapper.egg-info → rxnmapper-0.3.1}/PKG-INFO +19 -2
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/__init__.py +2 -1
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/attention.py +1 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/core.py +1 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/smiles_utils.py +6 -5
- {rxnmapper-0.3.0 → rxnmapper-0.3.1/rxnmapper.egg-info}/PKG-INFO +19 -2
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper.egg-info/requires.txt +1 -1
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/setup.cfg +1 -1
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/tests/test_mapper.py +13 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/LICENSE +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/MANIFEST.in +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/README.md +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/pyproject.toml +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/batched_mapper.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/config.json +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/pytorch_model.bin +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/special_tokens_map.json +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/tokenizer_config.json +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/training_args.bin +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/models/transformers/albert_heads_8_uspto_all_1310k/vocab.txt +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/py.typed +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper/tokenization_smiles.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper.egg-info/SOURCES.txt +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper.egg-info/dependency_links.txt +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper.egg-info/not-zip-safe +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/rxnmapper.egg-info/top_level.txt +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/setup.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/tests/__init__.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/tests/test_batched_mapper.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/tests/test_smiles_utils.py +0 -0
- {rxnmapper-0.3.0 → rxnmapper-0.3.1}/tests/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rxnmapper
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Reaction atom-mapping from transformers
|
|
5
5
|
Home-page: https://github.com/rxn4chemistry/rxnmapper
|
|
6
6
|
Author: IBM RXN team
|
|
@@ -20,9 +20,26 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
21
|
Requires-Python: >=3.6
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pandas>=1.0.3
|
|
25
|
+
Requires-Dist: rxn-chem-utils>=1.0.3
|
|
26
|
+
Requires-Dist: scipy>=1.4.1
|
|
27
|
+
Requires-Dist: torch<2.5,>=1.5.0
|
|
28
|
+
Requires-Dist: transformers>=4.0.0
|
|
23
29
|
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: black>=22.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: bump2version>=1.0.1; extra == "dev"
|
|
32
|
+
Requires-Dist: flake8>=3.7.9; extra == "dev"
|
|
33
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=0.910; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest>=5.4.1; extra == "dev"
|
|
36
|
+
Requires-Dist: sphinx-rtd-theme==0.4.3; extra == "dev"
|
|
37
|
+
Requires-Dist: sphinx==2.2.1; extra == "dev"
|
|
38
|
+
Requires-Dist: twine==3.1.1; extra == "dev"
|
|
39
|
+
Requires-Dist: types-setuptools>=62.6.0; extra == "dev"
|
|
24
40
|
Provides-Extra: rdkit
|
|
25
|
-
|
|
41
|
+
Requires-Dist: rdkit-pypi>=2021.3.2; python_version < "3.7" and extra == "rdkit"
|
|
42
|
+
Requires-Dist: rdkit>=2022.3.4; python_version >= "3.7" and extra == "rdkit"
|
|
26
43
|
|
|
27
44
|
# Extraction of organic chemistry grammar from unsupervised learning of chemical reactions
|
|
28
45
|
Enable robust atom mapping on valid reaction SMILES. The atom-mapping information was learned by an ALBERT model trained in an unsupervised fashion on a large dataset of chemical reactions.
|
|
@@ -7,6 +7,7 @@ This module contains all of the helper methods needed to convert the attention m
|
|
|
7
7
|
separating on reactants and products, including special tokens and not including special tokens, in the atom
|
|
8
8
|
domain / in the token domain, and accounting for adjacent atoms in molecules.
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
import logging
|
|
11
12
|
from typing import List, Optional
|
|
12
13
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Contains functions needed to process reaction SMILES and their tokens"""
|
|
2
|
+
|
|
2
3
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
4
|
|
|
4
5
|
import logging
|
|
@@ -72,7 +73,7 @@ def get_atom_types_smiles(smiles: str) -> List[int]:
|
|
|
72
73
|
# If `smiles` is a set of molecules, it may contain a "~".
|
|
73
74
|
smiles_mol = smiles_to_mol(smiles.replace("~", "."), sanitize=False)
|
|
74
75
|
|
|
75
|
-
atom_types = [atom.GetAtomicNum() for atom in smiles_mol.GetAtoms()]
|
|
76
|
+
atom_types = [atom.GetAtomicNum() for atom in smiles_mol.GetAtoms()] # type: ignore[call-arg]
|
|
76
77
|
|
|
77
78
|
return atom_types
|
|
78
79
|
|
|
@@ -315,7 +316,7 @@ def canonicalize_and_atom_map(smi: str, return_equivalent_atoms=False):
|
|
|
315
316
|
|
|
316
317
|
"""
|
|
317
318
|
mol = smiles_to_mol(smi, sanitize=False)
|
|
318
|
-
for atom in mol.GetAtoms():
|
|
319
|
+
for atom in mol.GetAtoms(): # type: ignore[call-arg]
|
|
319
320
|
if atom.HasProp("molAtomMapNumber"):
|
|
320
321
|
atom_map = atom.GetAtomMapNum()
|
|
321
322
|
atom.SetProp("atom_map", str(atom_map))
|
|
@@ -329,7 +330,7 @@ def canonicalize_and_atom_map(smi: str, return_equivalent_atoms=False):
|
|
|
329
330
|
]
|
|
330
331
|
)
|
|
331
332
|
|
|
332
|
-
atom_maps_canonical = [mol.GetAtoms()[idx].GetProp("atom_map") for idx in order]
|
|
333
|
+
atom_maps_canonical = [mol.GetAtoms()[idx].GetProp("atom_map") for idx in order] # type: ignore[call-arg]
|
|
333
334
|
|
|
334
335
|
if not return_equivalent_atoms:
|
|
335
336
|
return (can_smi, atom_maps_canonical)
|
|
@@ -366,7 +367,7 @@ def generate_atom_mapped_reaction_atoms(
|
|
|
366
367
|
i = -1
|
|
367
368
|
atom_mapped_precursors_list = []
|
|
368
369
|
for precursor_mol in precursors_mols:
|
|
369
|
-
for atom in precursor_mol.GetAtoms():
|
|
370
|
+
for atom in precursor_mol.GetAtoms(): # type: ignore[call-arg]
|
|
370
371
|
i += 1
|
|
371
372
|
if i in product_atom_maps:
|
|
372
373
|
# atom maps start at an index of 1
|
|
@@ -394,7 +395,7 @@ def generate_atom_mapped_reaction_atoms(
|
|
|
394
395
|
i = -1
|
|
395
396
|
atom_mapped_products_list = []
|
|
396
397
|
for products_mol in products_mols:
|
|
397
|
-
for atom in products_mol.GetAtoms():
|
|
398
|
+
for atom in products_mol.GetAtoms(): # type: ignore[call-arg]
|
|
398
399
|
i += 1
|
|
399
400
|
atom_map = product_mapping_dict.get(i, i + 1)
|
|
400
401
|
atom.SetProp("molAtomMapNumber", str(atom_map))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rxnmapper
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Reaction atom-mapping from transformers
|
|
5
5
|
Home-page: https://github.com/rxn4chemistry/rxnmapper
|
|
6
6
|
Author: IBM RXN team
|
|
@@ -20,9 +20,26 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
21
|
Requires-Python: >=3.6
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pandas>=1.0.3
|
|
25
|
+
Requires-Dist: rxn-chem-utils>=1.0.3
|
|
26
|
+
Requires-Dist: scipy>=1.4.1
|
|
27
|
+
Requires-Dist: torch<2.5,>=1.5.0
|
|
28
|
+
Requires-Dist: transformers>=4.0.0
|
|
23
29
|
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: black>=22.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: bump2version>=1.0.1; extra == "dev"
|
|
32
|
+
Requires-Dist: flake8>=3.7.9; extra == "dev"
|
|
33
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=0.910; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest>=5.4.1; extra == "dev"
|
|
36
|
+
Requires-Dist: sphinx-rtd-theme==0.4.3; extra == "dev"
|
|
37
|
+
Requires-Dist: sphinx==2.2.1; extra == "dev"
|
|
38
|
+
Requires-Dist: twine==3.1.1; extra == "dev"
|
|
39
|
+
Requires-Dist: types-setuptools>=62.6.0; extra == "dev"
|
|
24
40
|
Provides-Extra: rdkit
|
|
25
|
-
|
|
41
|
+
Requires-Dist: rdkit-pypi>=2021.3.2; python_version < "3.7" and extra == "rdkit"
|
|
42
|
+
Requires-Dist: rdkit>=2022.3.4; python_version >= "3.7" and extra == "rdkit"
|
|
26
43
|
|
|
27
44
|
# Extraction of organic chemistry grammar from unsupervised learning of chemical reactions
|
|
28
45
|
Enable robust atom mapping on valid reaction SMILES. The atom-mapping information was learned by an ALBERT model trained in an unsupervised fashion on a large dataset of chemical reactions.
|
|
@@ -108,3 +108,16 @@ def test_multiple_products(rxn_mapper: RXNMapper):
|
|
|
108
108
|
|
|
109
109
|
results = rxn_mapper.get_attention_guided_atom_maps(rxns)
|
|
110
110
|
assert_correct_maps(results, expected)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_reaction_with_dative_bond(rxn_mapper: RXNMapper):
|
|
114
|
+
rxns = ["COC(=O)CCBr.O=C[O-]->[K+]>>COC(=O)CCOC(=O)C"]
|
|
115
|
+
expected = [
|
|
116
|
+
{
|
|
117
|
+
"mapped_rxn": "[CH3:1][O:2][C:3](=[O:4])[CH2:5][CH2:6]Br.[O:9]=[CH:8][O-:7]->[K+]>>[CH3:1][O:2][C:3](=[O:4])[CH2:5][CH2:6][O:7][C:8](=[O:9])[CH3:10]",
|
|
118
|
+
"confidence": 0.9322116305783666,
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
results = rxn_mapper.get_attention_guided_atom_maps(rxns, canonicalize_rxns=False)
|
|
123
|
+
assert_correct_maps(results, expected)
|
|
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
|