mondalsou/lead_optimization_agent
0
1---2title: Lead Optimization Agent3emoji: ๐งฌ4colorFrom: green5colorTo: blue6sdk: streamlit7sdk_version: 1.35.08app_file: app.py9pinned: false10short_description: AI agent for iterative drug lead optimization with RDKit11---12 13# Lead Optimization Agent14 15An AI-assisted medicinal chemistry sandbox for exploring lead-optimization ideas in a visual, iterative workflow.16 17The app combines:18- an Anthropic-powered agent loop for proposing structural changes19- local RDKit-based property analysis for fast scoring20- a Streamlit UI for reviewing each attempt, change rationale, and property trajectory21 22[](https://huggingface.co/spaces/mondalsou/lead_optimization_agent)23[](https://python.org)24[](https://streamlit.io)25[](https://anthropic.com)26[](https://www.rdkit.org/)27 28**[Try the live demo on HuggingFace Spaces](https://huggingface.co/spaces/mondalsou/lead_optimization_agent)**29 30## What this project does31 32Given a starting molecule and a target optimization brief, the agent:33 341. validates the starting SMILES352. analyzes the molecule locally with RDKit-derived heuristics363. proposes one structural change at a time374. scores each new candidate385. compares property movement across attempts396. surfaces the best candidate found in the run40 41The UI is built to answer the questions a chemist actually cares about:42- What changed in this attempt?43- Why was that change made?44- Did BBB, CNS MPO, QED, or flexibility improve?45- Which candidate is currently the best balance?46 47## Current UI highlights48 49The Streamlit app includes:50- `Candidate Journey` as the first tab, with live attempt-by-attempt cards51- highlighted 2D structures showing the region changed in each attempt52- short plain-English change summaries for each analogue53- `Performance Overview` with metric deltas, trajectory plots, and a start-vs-best radar chart54- local run persistence, so you can reload past runs without spending LLM credits again55 56## Example scenarios57 58The app ships with a few preset briefs:59- `Atenolol โ Brain Penetration`60- `Aspirin โ CNS Drug Profile`61- `Ibuprofen โ Aqueous Solubility`62- `Custom molecule`63 64## How it works65 66### Agent loop67 68The agent is responsible for proposing the next chemical edit and explaining the logic behind it.69 70### Local chemistry scoring71 72Property analysis is performed locally in `agent_utils.py` using RDKit-based calculations and heuristics, including:73- QED74- Lipinski summary75- BBB probability heuristic76- CNS MPO heuristic77- solubility estimate78- GI absorption heuristic79- structural alerts80- synthetic accessibility heuristic81 82This means the chemistry scoring path is local and fast. The Anthropic API is used for the reasoning loop, not for property calculation.83 84## Project structure85 86```text87lead_optimization_agent/88โโโ app.py89โโโ agent_utils.py90โโโ requirements.txt91โโโ candidates.json92โโโ saved_runs/93โโโ notebooks/94 โโโ 01_admet_tool.ipynb95 โโโ 02_agent_loop.ipynb96 โโโ 03_visualization.ipynb97```98 99## Quick start100 101### 1. Clone and install102 103```bash104git clone https://github.com/mondalsou/lead_optimization_agent.git105cd lead_optimization_agent106pip install -r requirements.txt107```108 109If RDKit installation fails via `pip`, use:110 111```bash112conda install -c conda-forge rdkit113```114 115### 2. Set your Anthropic API key116 117```bash118export ANTHROPIC_API_KEY=sk-ant-...119```120 121### 3. Run the app122 123```bash124streamlit run app.py125```126 127Open `http://localhost:8501`.128 129## Using the app130 1311. Pick a preset or paste your own SMILES.1322. Write the optimization brief.1333. Click `Run Optimisation`.1344. Watch `Candidate Journey` update as new molecules are analyzed.1355. Open `Performance Overview` to compare start vs best candidate.136 137## Saved runs138 139Every completed run is saved locally so you can reopen it later without calling the API again.140 141Saved files are written to:142 143```text144saved_runs/latest_run.json145saved_runs/run_YYYYMMDD_HHMMSS.json146```147 148From the sidebar you can:149- load the latest saved run150- upload a saved JSON run151- download the current run152 153## Notebooks154 155The notebooks are still useful for exploration and demos:156- `01_admet_tool.ipynb`: property exploration and tool setup157- `02_agent_loop.ipynb`: agent-loop walkthrough158- `03_visualization.ipynb`: charts and candidate visualization159 160## Requirements161 162Core dependencies:163 164```text165streamlit>=1.35.0166anthropic>=0.40.0167rdkit>=2023.9.5168pandas>=2.0.0169plotly>=5.18.0170matplotlib>=3.8.0171```172 173## What this repo is good for174 175- portfolio/demo project for AI + chemistry tooling176- medicinal chemistry workflow prototyping177- showing iterative agent behavior instead of one-shot prompting178- experimenting with optimization briefs and visual candidate review179 180## Limitations181 182- this is a heuristic prototyping tool, not a validated drug-discovery platform183- property outputs are local approximations and should not be treated as experimental truth184- agent suggestions should be reviewed by a domain expert before any serious decision-making185 186## Why this is interesting187 188This project sits at the intersection of:189- agentic workflows190- chemistry-aware UI design191- human-in-the-loop lead optimization192- LLM reasoning paired with deterministic local analysis193 194## Author195 196Sourav Mondal197- GitHub: [@mondalsou](https://github.com/mondalsou)198- LinkedIn: [Sourav Mondal](https://www.linkedin.com/in/soura1/)199 