{"id":13560938,"url":"https://github.com/rxn4chemistry/rxnmapper","last_synced_at":"2026-01-16T12:02:26.958Z","repository":{"id":37582502,"uuid":"263718868","full_name":"rxn4chemistry/rxnmapper","owner":"rxn4chemistry","description":"RXNMapper: Unsupervised attention-guided atom-mapping. Code complementing our Science Advances publication on \"Extraction of organic chemistry grammar from unsupervised learning of chemical reactions\" (https://advances.sciencemag.org/content/7/15/eabe4166). ","archived":false,"fork":false,"pushed_at":"2024-09-19T20:40:41.000Z","size":8843,"stargazers_count":301,"open_issues_count":4,"forks_count":72,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-07T00:48:25.788Z","etag":null,"topics":["atom-mapping","chemistry","reactions","rxn","smiles","transformer"],"latest_commit_sha":null,"homepage":"http://rxnmapper.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rxn4chemistry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-13T19:01:05.000Z","updated_at":"2025-03-02T20:25:32.000Z","dependencies_parsed_at":"2023-02-19T17:01:05.363Z","dependency_job_id":"4fd906ce-7c99-4efd-a4d0-be9121e738b9","html_url":"https://github.com/rxn4chemistry/rxnmapper","commit_stats":{"total_commits":46,"total_committers":10,"mean_commits":4.6,"dds":0.7173913043478262,"last_synced_commit":"90a7012c9c0127f4a347baf815e270d8807b5a39"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxn4chemistry%2Frxnmapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxn4chemistry%2Frxnmapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxn4chemistry%2Frxnmapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxn4chemistry%2Frxnmapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxn4chemistry","download_url":"https://codeload.github.com/rxn4chemistry/rxnmapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247037021,"owners_count":20873081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom-mapping","chemistry","reactions","rxn","smiles","transformer"],"created_at":"2024-08-01T13:00:50.989Z","updated_at":"2026-01-16T12:02:26.939Z","avatar_url":"https://github.com/rxn4chemistry.png","language":"Python","funding_links":[],"categories":["Atom Mapping"],"sub_categories":[],"readme":"# 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### Create virtual environment (optional)\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n```\n\n### Install from pip\n\n```bash\npip install \"rxnmapper[rdkit]\"\n```\n\nYou can leave out `[rdkit]` if RDKit is already available in your Python environment.\n\n### From source\n\n```bash\ngit clone https://github.com/rxn4chemistry/rxnmapper.git\ncd rxnmapper\npip install -e \".[rdkit]\"\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+]\u003e\u003eCC(C)Sc1ncccc1F', 'C1COCCO1.CC(C)(C)OC(=O)CONC(=O)NCc1cccc2ccccc12.Cl\u003e\u003eO=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+]\u003e\u003e[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\u003e\u003e[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\u003e\u003eCCOCC', 'invalid\u003e\u003ereaction']\n\n# The following calls work with input of arbitrary size. Also, they do not raise \n# any exceptions but will return \"\u003e\u003e\" 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 test suite with:\n\n```bash\npip install -e .[dev,rdkit]\npytest tests\n```\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxn4chemistry%2Frxnmapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxn4chemistry%2Frxnmapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxn4chemistry%2Frxnmapper/lists"}