Metadata-Version: 2.1
Name: hypothesis-rdkit
Version: 0.5.3
Summary: Hypothesis strategies for RDKit
Home-page: https://github.com/shirte/hypothesis-rdkit
Maintainer: Steffen Hirte
Maintainer-email: shirte@users.noreply.github.com
License: MIT
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Framework :: Hypothesis
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: hypothesis
Requires-Dist: tqdm
Requires-Dist: importlib-resources>=5; python_version < "3.9"
Requires-Dist: rdkit>=2022.3.3
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-watch; extra == "test"

# hypothesis-rdkit

A strategy to generate random molecules for the hypothesis testing framework.

![demo](demo.png)


## Installation

```sh
pip install -U hypothesis-rdkit
```

## Usage

The module ```hypothesis-rdkit``` provides a strategy for generating RDKit 
molecules. During the installation of the package, this strategy is linked to the 
```rdkit.Chem.Mol``` type:


```python
from hypothesis import given
from rdkit.Chem import Mol

@given(...)
def test_molecule_method(mol : Mol):
    # mol is a randomly generated molecule
    assert mol.GetNumAtoms() > 0
```

You can use the ```mols``` strategy directly for further customization:

```python
from hypothesis import given  # import hypothesis before hypothesis_rdkit!
from hypothesis_rdkit import mols
from rdkit.Chem import GetMolFrags, Mol
from rdkit.Chem.rdMolDescriptors import CalcNumRotatableBonds

@given(mols(n_connected_components=2, max_rotatable_bonds=5))
def test_molecule_mixtures(mol : Mol):
    frags = GetMolFrags(mol, asMols=True)
    assert len(frags) == 2

    for frag in frags:
        assert CalcNumRotatableBonds(frag) <= 5
```
