rxnmapper


Namerxnmapper JSON
Version 0.2.9 PyPI version JSON
download
home_pagehttps://github.com/rxn4chemistry/rxnmapper
SummaryReaction atom-mapping from transfomers
upload_time2023-05-15 14:25:28
maintainer
docs_urlNone
authorIBM RXN team
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Extraction of organic chemistry grammar from unsupervised learning of chemical reactions
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.

- [Extraction of organic chemistry grammar from unsupervised learning of chemical reactions](https://advances.sciencemag.org/content/7/15/eabe4166): peer-reviewed Science Advances publication (open access).
- [Demo](http://rxnmapper.ai/demo.html): give RXNMapper a try! 
- [Unsupervised attention-guided atom-mapping preprint](http://dx.doi.org/10.26434/chemrxiv.12298559): presented at the ML Interpretability for Scientific Discovery ICML workshop, 2020.

## Installation

### From pip
```console
conda create -n rxnmapper python=3.6 -y
conda activate rxnmapper
pip install rxnmapper
```

### From github
You can install the package and setup the environment directly from github using:

```console
git clone https://github.com/rxn4chemistry/rxnmapper.git 
cd rxnmapper
conda create -n rxnmapper python=3.6 -y
conda activate rxnmapper
pip install -e .
```

### RDkit

In both installation settings above, the `RDKit` dependency is not installed automatically, unless you include the extra when installing: `pip install "rxmapper[rdkit]"`.
It can also be installed via Conda or Pypi:

```bash
# Install RDKit from Conda
conda install -c conda-forge rdkit

# Install RDKit from Pypi
pip install rdkit
# for Python<3.7
# pip install rdkit-pypi
```

## Usage

### Basic usage

```python
from rxnmapper import RXNMapper
rxn_mapper = RXNMapper()
rxns = ['CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F', 'C1COCCO1.CC(C)(C)OC(=O)CONC(=O)NCc1cccc2ccccc12.Cl>>O=C(O)CONC(=O)NCc1cccc2ccccc12']
results = rxn_mapper.get_attention_guided_atom_maps(rxns)
```

The results contain the mapped reactions and confidence scores:

```python
[{'mapped_rxn': 'CN(C)C=O.F[c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11].O=C([O-])[O-].[CH3:1][CH:2]([CH3:3])[SH:4].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]',
  'confidence': 0.9565619900376546},
 {'mapped_rxn': 'C1COCCO1.CC(C)(C)[O:3][C:2](=[O:1])[CH2:4][O:5][NH:6][C:7](=[O:8])[NH:9][CH2:10][c:11]1[cH:12][cH:13][cH:14][c:15]2[cH:16][cH:17][cH:18][cH:19][c:20]12.Cl>>[O:1]=[C:2]([OH:3])[CH2:4][O:5][NH:6][C:7](=[O:8])[NH:9][CH2:10][c:11]1[cH:12][cH:13][cH:14][c:15]2[cH:16][cH:17][cH:18][cH:19][c:20]12',
  'confidence': 0.9704424331552834}]
```

To account for batching and error handling automatically, you can use `BatchedMapper` instead:
```python
from rxnmapper import BatchedMapper
rxn_mapper = BatchedMapper(batch_size=32)
rxns = ['CC[O-]~[Na+].BrCC>>CCOCC', 'invalid>>reaction']

# The following calls work with input of arbitrary size. Also, they do not raise 
# any exceptions but will return ">>" or an empty dictionary for the second reaction.
results = list(rxn_mapper.map_reactions(rxns))  # results as strings directly
results = list(rxn_mapper.map_reactions_with_info(rxns))  # results as dictionaries (as above)
```

### Testing

You can run the examples above with the test suite as well:

1. In your Conda environment: `pip install -e .[dev]`
2. `pytest tests` from the root 

## Examples

To learn more see the [examples](./examples).

## Data 

Data can be found at: https://ibm.box.com/v/RXNMapperData

## Citation

```
@article{schwaller2021extraction,
  title={Extraction of organic chemistry grammar from unsupervised learning of chemical reactions},
  author={Schwaller, Philippe and Hoover, Benjamin and Reymond, Jean-Louis and Strobelt, Hendrik and Laino, Teodoro},
  journal={Science Advances},
  volume={7},
  number={15},
  pages={eabe4166},
  year={2021},
  publisher={American Association for the Advancement of Science}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rxn4chemistry/rxnmapper",
    "name": "rxnmapper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "IBM RXN team",
    "author_email": "rxn4chemistry@zurich.ibm.com",
    "download_url": "https://files.pythonhosted.org/packages/f3/74/3dfe36e793250c7604656e359d6e4bb9fd03c32505371ec34efcc68b794d/rxnmapper-0.2.9.tar.gz",
    "platform": null,
    "description": "# Extraction of organic chemistry grammar from unsupervised learning of chemical reactions\nEnable 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.\n\n- [Extraction of organic chemistry grammar from unsupervised learning of chemical reactions](https://advances.sciencemag.org/content/7/15/eabe4166): peer-reviewed Science Advances publication (open access).\n- [Demo](http://rxnmapper.ai/demo.html): give RXNMapper a try! \n- [Unsupervised attention-guided atom-mapping preprint](http://dx.doi.org/10.26434/chemrxiv.12298559): presented at the ML Interpretability for Scientific Discovery ICML workshop, 2020.\n\n## Installation\n\n### From pip\n```console\nconda create -n rxnmapper python=3.6 -y\nconda activate rxnmapper\npip install rxnmapper\n```\n\n### From github\nYou can install the package and setup the environment directly from github using:\n\n```console\ngit clone https://github.com/rxn4chemistry/rxnmapper.git \ncd rxnmapper\nconda create -n rxnmapper python=3.6 -y\nconda activate rxnmapper\npip install -e .\n```\n\n### RDkit\n\nIn both installation settings above, the `RDKit` dependency is not installed automatically, unless you include the extra when installing: `pip install \"rxmapper[rdkit]\"`.\nIt can also be installed via Conda or Pypi:\n\n```bash\n# Install RDKit from Conda\nconda install -c conda-forge rdkit\n\n# Install RDKit from Pypi\npip install rdkit\n# for Python<3.7\n# pip install rdkit-pypi\n```\n\n## Usage\n\n### Basic usage\n\n```python\nfrom rxnmapper import RXNMapper\nrxn_mapper = RXNMapper()\nrxns = ['CC(C)S.CN(C)C=O.Fc1cccnc1F.O=C([O-])[O-].[K+].[K+]>>CC(C)Sc1ncccc1F', 'C1COCCO1.CC(C)(C)OC(=O)CONC(=O)NCc1cccc2ccccc12.Cl>>O=C(O)CONC(=O)NCc1cccc2ccccc12']\nresults = rxn_mapper.get_attention_guided_atom_maps(rxns)\n```\n\nThe results contain the mapped reactions and confidence scores:\n\n```python\n[{'mapped_rxn': 'CN(C)C=O.F[c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11].O=C([O-])[O-].[CH3:1][CH:2]([CH3:3])[SH:4].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]',\n  'confidence': 0.9565619900376546},\n {'mapped_rxn': 'C1COCCO1.CC(C)(C)[O:3][C:2](=[O:1])[CH2:4][O:5][NH:6][C:7](=[O:8])[NH:9][CH2:10][c:11]1[cH:12][cH:13][cH:14][c:15]2[cH:16][cH:17][cH:18][cH:19][c:20]12.Cl>>[O:1]=[C:2]([OH:3])[CH2:4][O:5][NH:6][C:7](=[O:8])[NH:9][CH2:10][c:11]1[cH:12][cH:13][cH:14][c:15]2[cH:16][cH:17][cH:18][cH:19][c:20]12',\n  'confidence': 0.9704424331552834}]\n```\n\nTo account for batching and error handling automatically, you can use `BatchedMapper` instead:\n```python\nfrom rxnmapper import BatchedMapper\nrxn_mapper = BatchedMapper(batch_size=32)\nrxns = ['CC[O-]~[Na+].BrCC>>CCOCC', 'invalid>>reaction']\n\n# The following calls work with input of arbitrary size. Also, they do not raise \n# any exceptions but will return \">>\" or an empty dictionary for the second reaction.\nresults = list(rxn_mapper.map_reactions(rxns))  # results as strings directly\nresults = list(rxn_mapper.map_reactions_with_info(rxns))  # results as dictionaries (as above)\n```\n\n### Testing\n\nYou can run the examples above with the test suite as well:\n\n1. In your Conda environment: `pip install -e .[dev]`\n2. `pytest tests` from the root \n\n## Examples\n\nTo learn more see the [examples](./examples).\n\n## Data \n\nData can be found at: https://ibm.box.com/v/RXNMapperData\n\n## Citation\n\n```\n@article{schwaller2021extraction,\n  title={Extraction of organic chemistry grammar from unsupervised learning of chemical reactions},\n  author={Schwaller, Philippe and Hoover, Benjamin and Reymond, Jean-Louis and Strobelt, Hendrik and Laino, Teodoro},\n  journal={Science Advances},\n  volume={7},\n  number={15},\n  pages={eabe4166},\n  year={2021},\n  publisher={American Association for the Advancement of Science}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Reaction atom-mapping from transfomers",
    "version": "0.2.9",
    "project_urls": {
        "Homepage": "https://github.com/rxn4chemistry/rxnmapper"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "131241d96a0d559cbb8251fc93ee6ed0c2d5610d358be4e7ce32aa9283f98c96",
                "md5": "0622a50fbc7719126ede340c22779e6f",
                "sha256": "50e77a9090a4c211c05ac9fa10c49f417e5a3512c30128dc63369bacac61a0ac"
            },
            "downloads": -1,
            "filename": "rxnmapper-0.2.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0622a50fbc7719126ede340c22779e6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 3006313,
            "upload_time": "2023-05-15T14:25:26",
            "upload_time_iso_8601": "2023-05-15T14:25:26.110219Z",
            "url": "https://files.pythonhosted.org/packages/13/12/41d96a0d559cbb8251fc93ee6ed0c2d5610d358be4e7ce32aa9283f98c96/rxnmapper-0.2.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3743dfe36e793250c7604656e359d6e4bb9fd03c32505371ec34efcc68b794d",
                "md5": "70b2bc0c6e3b915e2d4ffbe62dbbf89d",
                "sha256": "5d71724cf58c1804234f6568746c52a493e8715cd08c381418b3bad2d86483c9"
            },
            "downloads": -1,
            "filename": "rxnmapper-0.2.9.tar.gz",
            "has_sig": false,
            "md5_digest": "70b2bc0c6e3b915e2d4ffbe62dbbf89d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3005904,
            "upload_time": "2023-05-15T14:25:28",
            "upload_time_iso_8601": "2023-05-15T14:25:28.910225Z",
            "url": "https://files.pythonhosted.org/packages/f3/74/3dfe36e793250c7604656e359d6e4bb9fd03c32505371ec34efcc68b794d/rxnmapper-0.2.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-15 14:25:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rxn4chemistry",
    "github_project": "rxnmapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rxnmapper"
}
        
Elapsed time: 0.06486s