https://github.com/apahl/rdkit_nim
Nim bindings for the C++ cheminformatics toolkit RDKit.
https://github.com/apahl/rdkit_nim
nim nim-lang rdkit
Last synced: 5 days ago
JSON representation
Nim bindings for the C++ cheminformatics toolkit RDKit.
- Host: GitHub
- URL: https://github.com/apahl/rdkit_nim
- Owner: apahl
- License: mit
- Created: 2020-01-13T11:29:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-27T14:01:34.000Z (over 2 years ago)
- Last Synced: 2025-03-29T08:07:56.513Z (about 2 months ago)
- Topics: nim, nim-lang, rdkit
- Language: Nim
- Homepage:
- Size: 85 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nim RDKit Bindings
Rudimentary binding of the C++ cheminformatics toolkit [RDKit](http://rdkit.org/) for the [Nim](https://nim-lang.org) programming language. All functionality in this project is wrapped from the totally awesome RDKit directly or a re-write of available Python code (e.g. the `qed` module).
[Example](examples/ex01_mol_from_smiles.nim) for creating the mol object from the Smiles "c1ccccc1C(=O)NC" (methyl benzamide) and calculating some properties:
$ nim build examples/ex01_mol_from_smiles.nim
$ LD_LIBRARY_PATH=$RDKIT_CONDA/lib ./bin/ex01_mol_from_smiles
Output (shortened):
Mol Ok: true
Num Atoms: 10
Mol weight: 135.166
Rot. Bonds: 1
Num HetAtoms: 2
Canonical Smiles: CNC(=O)c1ccccc1
TPSA: 29.1
SSSR: 1Pre-requisites:
* Installations of RDKit (e.g. via `conda`) and NimThe path to your conda installation of the RDKit has to be set by an environment variable, e.g. in `~/.profile`:
export RDKIT_CONDA=/home/pahl/anaconda3/envs/chem
Obviously, this project will change quickly. In the current state it is mainly for showing off my first success.
The following functionality from RDKit has been wrapped so far:* Parsing of molecules to / from Smiles and Smarts: `molFromSmiles (smilesToMol), molFromSmarts; toSmiles`
* Calculation of molecular properties: `numAtoms, molWt, numRings, cLogP, numHBA, numHBD, numRotatableBonds, fractionCSP3, tPSA, findSSSR`
* Substructure search: `hasSubstructMatch, numSubstructMatches, substructMatches`
* Murcko scaffolds
* Morgan fingerprints and Tanimoto similarity
* Drug-Like properties: The Python [QED](https://github.com/rdkit/rdkit/blob/master/rdkit/Chem/QED.py) module has been re-written in Nim.
* Drawing molecules to SVG format
- the molecules can be drawn to SVG strings (`mol.toSVG()`), using either the CoordGen method (default) or the original RDKit functionality (`mol.toSVG(coordGen = RDKit)`).
For further usage, until a real documentation becomes available, please have a look at the tests and the examples.
## Installation
Clone the repo, `cd` into it and install with `nimble install`.
From the repo dir you can also run the tests with `nimble test`.
The output should look like this:$ nimble test
Executing task test in /home/pahl/dev/nim/rdkit_nim/rdkit.nimble
[draw.nim] passed.
[fingerprints.nim] passed.
[mol.nim] passed.
[qed.nim] passed.
[scaffolds.nim] passed.
[sss.nim] passed.All tests passed.
The package documentation can be generated with `nimble docs`.
## Using the package
To use the package in your own projects, the imports have to be of the form:
import rdkit / [molecule, descriptors]
### Running the Compiled Programs
When running the compiled programs, remember to prepend the call to the binary with the `LD_LIBRARY_PATH`, e.g.:
$ LD_LIBRARY_PATH=$RDKIT_CONDA/lib my_program
Permanently modifying `LD_LIBRARY_PATH` (e.g. in `~/.profile`) or adding the path in `/etc/ld.so.conf.d/` has messed up my system and lead to errors in other programs, this is therefore not recommended. If someone has an idea how to do this more elegantly, please let me know.