Cheminformatics for PHP, powered by RDKit
Run:
composer require ankane/rdkitAdd 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 installCreate 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();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.
Add or remove hydrogen atoms
$mol->addHs();
$mol->removeHs();Standardize
$mol->cleanup();
$mol->normalize();
$mol->neutralize();
$mol->reionize();
$mol->canonicalTautomer();
$mol->chargeParent();
$mol->fragmentParent();SMILES
$mol->toSmiles();SMARTS
$mol->toSmarts();CXSMILES
$mol->toCXSmiles();CXSMARTS
$mol->toCXSmarts();JSON
$mol->toJson();Create a reaction
use RDKit\Reaction;
$rxn = Reaction::fromSmarts('[CH3:1][OH:2]>>[CH2:1]=[OH0:2]');Generate an SVG
$rxn->toSvg();View the changelog
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