mondalsou/lead_optimization_agent
Lead Optimization Agent
An AI-assisted medicinal chemistry sandbox for exploring lead-optimization ideas in a visual, iterative workflow.
The app combines:
- an Anthropic-powered agent loop for proposing structural changes
- local RDKit-based property analysis for fast scoring
- a Streamlit UI for reviewing each attempt, change rationale, and property trajectory
    
[Try the live demo on HuggingFace Spaces](https://huggingface.co/spaces/mondalsou/lead_optimization_agent)
What this project does
Given a starting molecule and a target optimization brief, the agent:
- validates the starting SMILES
- analyzes the molecule locally with RDKit-derived heuristics
- proposes one structural change at a time
- scores each new candidate
- compares property movement across attempts
- surfaces the best candidate found in the run
The UI is built to answer the questions a chemist actually cares about:
- What changed in this attempt?
- Why was that change made?
- Did BBB, CNS MPO, QED, or flexibility improve?
- Which candidate is currently the best balance?
Current UI highlights
The Streamlit app includes:
Candidate Journeyas the first tab, with live attempt-by-attempt cards- highlighted 2D structures showing the region changed in each attempt
- short plain-English change summaries for each analogue
Performance Overviewwith metric deltas, trajectory plots, and a start-vs-best radar chart- local run persistence, so you can reload past runs without spending LLM credits again
Example scenarios
The app ships with a few preset briefs:
Atenolol → Brain PenetrationAspirin → CNS Drug ProfileIbuprofen → Aqueous SolubilityCustom molecule
How it works
Agent loop
The agent is responsible for proposing the next chemical edit and explaining the logic behind it.
Local chemistry scoring
Property analysis is performed locally in agent_utils.py using RDKit-based calculations and heuristics, including:
- QED
- Lipinski summary
- BBB probability heuristic
- CNS MPO heuristic
- solubility estimate
- GI absorption heuristic
- structural alerts
- synthetic accessibility heuristic
This means the chemistry scoring path is local and fast. The Anthropic API is used for the reasoning loop, not for property calculation.
Project structure
lead_optimization_agent/
├── app.py
├── agent_utils.py
├── requirements.txt
├── candidates.json
├── saved_runs/
└── notebooks/
├── 01_admet_tool.ipynb
├── 02_agent_loop.ipynb
└── 03_visualization.ipynbQuick start
1. Clone and install
git clone https://github.com/mondalsou/lead_optimization_agent.git
cd lead_optimization_agent
pip install -r requirements.txtIf RDKit installation fails via pip, use:
conda install -c conda-forge rdkit2. Set your Anthropic API key
export ANTHROPIC_API_KEY=sk-ant-...3. Run the app
streamlit run app.pyOpen http://localhost:8501.
Using the app
- Pick a preset or paste your own SMILES.
- Write the optimization brief.
- Click
Run Optimisation. - Watch
Candidate Journeyupdate as new molecules are analyzed. - Open
Performance Overviewto compare start vs best candidate.
Saved runs
Every completed run is saved locally so you can reopen it later without calling the API again.
Saved files are written to:
saved_runs/latest_run.json
saved_runs/run_YYYYMMDD_HHMMSS.jsonFrom the sidebar you can:
- load the latest saved run
- upload a saved JSON run
- download the current run
Notebooks
The notebooks are still useful for exploration and demos:
01_admet_tool.ipynb: property exploration and tool setup02_agent_loop.ipynb: agent-loop walkthrough03_visualization.ipynb: charts and candidate visualization
Requirements
Core dependencies:
streamlit>=1.35.0
anthropic>=0.40.0
rdkit>=2023.9.5
pandas>=2.0.0
plotly>=5.18.0
matplotlib>=3.8.0What this repo is good for
- portfolio/demo project for AI + chemistry tooling
- medicinal chemistry workflow prototyping
- showing iterative agent behavior instead of one-shot prompting
- experimenting with optimization briefs and visual candidate review
Limitations
- this is a heuristic prototyping tool, not a validated drug-discovery platform
- property outputs are local approximations and should not be treated as experimental truth
- agent suggestions should be reviewed by a domain expert before any serious decision-making
Why this is interesting
This project sits at the intersection of:
- agentic workflows
- chemistry-aware UI design
- human-in-the-loop lead optimization
- LLM reasoning paired with deterministic local analysis
Author
Sourav Mondal
- GitHub: @mondalsou
- LinkedIn: Sourav Mondal
