@peterspackman/selfies
v0.2.0
Published
SELFIES: a robust representation of semantically constrained graphs with an example application in chemistry
Maintainers
Readme
@peterspackman/selfies
TypeScript port of the Python SELFIES library for robust molecular string representation.
Installation
npm install @peterspackman/selfiesUsage
import * as selfies from '@peterspackman/selfies';
// SMILES to SELFIES
const benzene = "c1ccccc1";
const benzeneSelfies = selfies.encoder(benzene);
// "[C][=C][C][=C][C][=C][Ring1][=Branch1]"
// SELFIES to SMILES
const smiles = selfies.decoder(benzeneSelfies);
// "C1=CC=CC=C1"
// Working with SELFIES
const length = selfies.lenSelfies(benzeneSelfies); // 8
const symbols = [...selfies.splitSelfies(benzeneSelfies)];
// ['[C]', '[=C]', '[C]', '[=C]', '[C]', '[=C]', '[Ring1]', '[=Branch1]']API
encoder(smiles)- Convert SMILES to SELFIESdecoder(selfies)- Convert SELFIES to SMILESsetSemanticConstraints()- Configure bonding constraintslenSelfies(selfies)- Get symbol countsplitSelfies(selfies)- Split into symbolsgetAlphabetFromSelfies(selfies[])- Extract unique symbolsselfiesToEncoding()/encodingToSelfies()- ML encodings
License
Apache 2.0 (same as original Python implementation)
Citation
If you use this in research, please cite the original SELFIES paper:
@article{krenn2020selfies,
title={Self-referencing embedded strings (SELFIES): A 100% robust molecular string representation},
author={Krenn, Mario and H{\"a}se, Florian and Nigam, AkshatKumar and Friederich, Pascal and Aspuru-Guzik, Alan},
journal={Machine Learning: Science and Technology},
volume={1},
number={4},
pages={045024},
year={2020},
publisher={IOP Publishing}
}