https://github.com/tjkessler/smiles-encoder
One-hot encoding for simple molecular-input line-entry system (SMILES) strings
https://github.com/tjkessler/smiles-encoder
computational-chemistry one-hot-encoding smiles smiles-strings
Last synced: about 1 month ago
JSON representation
One-hot encoding for simple molecular-input line-entry system (SMILES) strings
- Host: GitHub
- URL: https://github.com/tjkessler/smiles-encoder
- Owner: tjkessler
- License: mit
- Created: 2023-03-27T00:56:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-02T20:10:13.000Z (almost 3 years ago)
- Last Synced: 2025-11-27T20:20:33.332Z (8 months ago)
- Topics: computational-chemistry, one-hot-encoding, smiles, smiles-strings
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smiles-encoder: One-hot encoding for simple molecular-input line-entry system (SMILES) strings
[](https://badge.fury.io/gh/tjkessler%2Fsmiles-encoder)
[](https://badge.fury.io/py/smiles-encoder)
[](https://raw.githubusercontent.com/tjkessler/smiles-encoder/master/LICENSE.txt)
smiles-encoder is a Python package used to generate one-hot vectors representing SMILES strings (each string element is a one-hot vector).
## Installation
Installation via pip:
```
$ pip install smiles-encoder
```
Installation via cloned repository:
```
$ git clone https://github.com/tjkessler/smiles-encoder
$ cd smiles-encoder
$ python setup.py install
```
smiles-encoder does not require any dependencies.
## Basic Usage
First, assemble a list of SMILES strings:
```python
smiles_strings = [
'O=Cc1ccc(O)c(OC)c1', # Vanillin
'CC(=O)NCCC1=CNc2c1cc(OC)cc2', # Melatonin
'C1CCCCC1', # Cyclohexane
'C1=CC=CC=C1' # Benzene
]
```
Import the SmilesEncoder object, and pass it the list of SMILES strings during initialization to construct the element dictionary:
```python
from smiles_encoder import SmilesEncoder
encoder = SmilesEncoder(smiles_strings)
```
Use the encoder to encode SMILES strings:
```python
encoded_smiles = encoder.encode_many(smiles_strings)
# OR
encoded_smiles = [encoder.encode(s) for s in smiles_strings]
```
Use the encoder to decode encoded SMILES strings:
```python
decoded_smiles = encoder.decode_many(encoded_smiles)
# OR
decoded_smiles = [encoder.decode(e) for e in encoded_smiles]
```
## Contributing, Reporting Issues and Other Support
To contribute to smiles-encoder, make a pull request. Contributions should include extensive documentation.
To report problems with the software or feature requests, file an issue. When reporting problems, include information such as error messages, your OS/environment and Python version.
For additional support/questions, contact Travis Kessler (travis.j.kessler@gmail.com).