|
| 1 | +# Contributing to smartreact |
| 2 | + |
| 3 | +Thanks for your interest in contributing! `smartreact` is an open scientific tool, and we welcome contributions from chemists, cheminformaticians, and software developers alike. |
| 4 | + |
| 5 | +## Ways to contribute |
| 6 | + |
| 7 | +- **Report bugs** — open a GitHub issue with a minimal reproducible example (input SMILES, expected vs. actual output, traceback). |
| 8 | +- **Suggest features** — open an issue describing the use case before sending a PR for larger changes. |
| 9 | +- **Contribute reaction templates** — see [Adding reaction templates](#adding-reaction-templates) below. |
| 10 | +- **Improve documentation** — fixes to the README, docstrings, or notebooks are always welcome. |
| 11 | +- **Fix bugs or add features** — see [Development workflow](#development-workflow). |
| 12 | + |
| 13 | +## Development workflow |
| 14 | + |
| 15 | +### 1. Set up the environment |
| 16 | + |
| 17 | +This project uses [pixi](https://pixi.sh) for dependency management. |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone https://github.com/MolecularAI/smartreact.git |
| 21 | +cd smartreact |
| 22 | +pixi install -e dev |
| 23 | +``` |
| 24 | + |
| 25 | +The `dev` environment adds `pytest` and `ruff` on top of the runtime dependencies. (The `default` environment installs only what end users get.) Other environments are available when needed: |
| 26 | + |
| 27 | +```bash |
| 28 | +pixi install -e notebook # dev + jupyter + ipywidgets for working with notebooks/ |
| 29 | +pixi install -e casestudy # dev + scikit-learn, umap-learn, pyarrow, matplotlib for the case study |
| 30 | +``` |
| 31 | + |
| 32 | +All environments share a single dependency solve, so versions stay consistent across them. |
| 33 | + |
| 34 | +### 2. Create a branch |
| 35 | + |
| 36 | +```bash |
| 37 | +git checkout -b your-feature-name |
| 38 | +``` |
| 39 | + |
| 40 | +### 3. Make your changes |
| 41 | + |
| 42 | +The pipeline is **SMILES → SMARTS-RX classification → template matching → RDKit reaction → products**. The core modules live in `src/smartreact/` — see the `README.md` for an overview. |
| 43 | + |
| 44 | +### 4. Run tests, linting, and formatting |
| 45 | + |
| 46 | +Run these in the `dev` environment: |
| 47 | + |
| 48 | +```bash |
| 49 | +pixi run -e dev test # run the test suite |
| 50 | +pixi run -e dev lint # check for lint errors |
| 51 | +pixi run -e dev format # auto-format with ruff |
| 52 | +pixi run -e dev format-check # verify formatting without modifying files |
| 53 | +``` |
| 54 | + |
| 55 | +All of these must pass before opening a pull request. |
| 56 | + |
| 57 | +### 5. Open a pull request |
| 58 | + |
| 59 | +- Reference any related issue (e.g. `Fixes #42`). |
| 60 | +- Describe what changed and why. |
| 61 | +- Include tests for new behavior. |
| 62 | +- Keep PRs focused; split unrelated changes into separate PRs. |
| 63 | + |
| 64 | +## Adding reaction templates |
| 65 | + |
| 66 | +Reaction templates live in `src/smartreact/data/templates.txt` (TSV with columns `reaction_name`, `template_id`, `example`, `reaction_template`, `reactant_categories`). |
| 67 | + |
| 68 | +When proposing a new template: |
| 69 | + |
| 70 | +- Provide a clear `reaction_name` and a unique `template_id`. |
| 71 | +- Include an `example` reaction (SMILES `reactants>>product`) so the template's intended behavior is obvious. |
| 72 | +- Document the chemistry: cite a reference (paper, named reaction, etc.) in the PR description. |
| 73 | +- Ensure `reactant_categories` correctly references SMARTS-RX functional group keys defined in `src/smartreact/data/keys.txt`. |
| 74 | +- Add a test in `tests/` demonstrating the template fires on a known substrate pair and produces the expected product. |
| 75 | + |
| 76 | +Template additions should be reviewed by a maintainer with chemistry expertise (currently Thierry Kogej). |
| 77 | + |
| 78 | +## Code style |
| 79 | + |
| 80 | +- Python 3.10+, ruff-formatted, line length 100. |
| 81 | +- Lint rules: `E, F, W, I, UP, B, SIM` (configured in `pyproject.toml`). |
| 82 | +- `smartreact` is treated as first-party for import sorting. |
| 83 | +- Prefer explicit, well-named functions over clever one-liners. Avoid unnecessary comments; let identifiers speak. |
| 84 | + |
| 85 | +## Testing |
| 86 | + |
| 87 | +- Tests live in `tests/` and use `pytest`. |
| 88 | +- New features should include unit tests; bug fixes should include a regression test. |
| 89 | +- Run a single test with: `pixi run -e dev test -- tests/test_enumerator.py::test_name`. |
| 90 | + |
| 91 | +## Reporting security issues |
| 92 | + |
| 93 | +Please do not report security vulnerabilities through public GitHub issues. Instead, contact the maintainers directly. |
| 94 | + |
| 95 | +## Code of conduct |
| 96 | + |
| 97 | +Be respectful and constructive. We aim for a welcoming environment for contributors of all backgrounds and experience levels. |
| 98 | + |
| 99 | +## License |
| 100 | + |
| 101 | +By contributing, you agree that your contributions will be licensed under the Apache License 2.0 (see `LICENSE`). |
0 commit comments