ankane / rdkit
Cheminformatics for PHP, powered by RDKit
Requires
- php: >= 8.1
- ext-ffi: >= 8.1
Requires (Dev)
- phpunit/phpunit: ^10
This package is not auto-updated.
Last update: 2024-11-22 23:56:08 UTC
README
Cheminformatics for PHP, powered by RDKit
Installation
Run:
composer require ankane/rdkit
Add scripts to composer.json
to download the shared library:
"scripts": { "post-install-cmd": "RDKit\\Vendor::check", "post-update-cmd": "RDKit\\Vendor::check" }
And run:
composer install
Getting Started
Create a molecule
use RDKit\Molecule; $mol = Molecule::fromSmiles('c1ccccc1O');
Get the number of atoms
$mol->numAtoms();
Get substructure matches
$mol->match(Molecule::fromSmarts('ccO'));
Get fragments
$mol->fragments();
Generate an SVG
$mol->toSvg();
Fingerprints
A number of fingerprints are supported.
RDKit
$mol->rdkitFingerprint();
Morgan
$mol->morganFingerprint();
Pattern
$mol->patternFingerprint();
Atom pair
$mol->atomPairFingerprint();
Topological torsion
$mol->topologicalTorsionFingerprint();
MACCS
$mol->maccsFingerprint();
You can use a library like pgvector-php to find similar molecules. See an example.
Updates
Add or remove hydrogen atoms
$mol->addHs(); $mol->removeHs();
Standardize
$mol->cleanup(); $mol->normalize(); $mol->neutralize(); $mol->reionize(); $mol->canonicalTautomer(); $mol->chargeParent(); $mol->fragmentParent();
Conversion
SMILES
$mol->toSmiles();
SMARTS
$mol->toSmarts();
CXSMILES
$mol->toCXSmiles();
CXSMARTS
$mol->toCXSmarts();
JSON
$mol->toJson();
Reactions
Create a reaction
use RDKit\Reaction; $rxn = Reaction::fromSmarts('[CH3:1][OH:2]>>[CH2:1]=[OH0:2]');
Generate an SVG
$rxn->toSvg();
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/rdkit-php.git cd rdkit-php composer install composer test