File size: 4,259 Bytes
a70ff5b
43e7ae4
 
 
a70ff5b
 
 
 
 
43e7ae4
 
 
 
 
a70ff5b
 
43e7ae4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
title: HITL Drug Discovery
emoji: 🧬
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_scopes:
- inference-api
license: apache-2.0
short_description: HITL Drug Discovery with AI Chat and Molecular Analysis
---

# 🧬 HITL Drug Discovery Platform

An advanced drug discovery platform combining AI-powered chat with molecular visualization and property analysis using [Gradio](https://gradio.app), [RDKit](https://www.rdkit.org/), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).

## πŸš€ Quick Start

### Running the Application
```bash
# Easy launcher (recommended)
python run.py

# Direct launch
python app.py

# Legacy version (backup)
python legacy/app_legacy.py
```

### Access
Once running, open your browser to: **http://localhost:7860**

## ✨ Key Features

- **πŸ€– AI Chat Assistant**: Expert medicinal chemistry guidance and structure generation
- **πŸ”¬ Molecular Analysis**: Calculate drug-likeness properties and Lipinski's Rule of Five
- **🎨 Interactive Visualization**: High-quality molecular structure rendering with multiple styles
- **πŸ“š Drug Discovery Library**: Curated collection of pharmaceutical compounds
- **⚑ Real-time Property Calculation**: Molecular weight, LogP, TPSA, hydrogen bonding, and more
- **πŸ”„ Chemical Variations**: Generate multiple visualization styles of molecular structures
- **πŸ’Ύ Bookmarking**: Save and manage favorite molecular structures

## πŸ—οΈ Project Structure

```
HITL_Drug_Discovery/
β”œβ”€β”€ app.py                  # Main entry point
β”œβ”€β”€ run.py                  # Easy launcher script
β”œβ”€β”€ requirements.txt        # Dependencies
β”œβ”€β”€ src/                   # Modular source code
β”‚   β”œβ”€β”€ app.py             # Main application orchestrator
β”‚   β”œβ”€β”€ molecules/         # Molecular analysis and variations
β”‚   β”‚   β”œβ”€β”€ analysis.py    # Property calculations & validation
β”‚   β”‚   └── variations.py  # Structure variation generation
β”‚   β”œβ”€β”€ ai/                # AI services
β”‚   β”‚   └── services.py    # AI chat and structure generation
β”‚   β”œβ”€β”€ ui/                # UI components and handlers
β”‚   β”‚   β”œβ”€β”€ components.py  # UI component definitions
β”‚   β”‚   └── handlers.py    # Event handlers and business logic
β”‚   └── config/            # Configuration and settings
β”‚       └── settings.py    # App configuration and styling
└── legacy/                # Legacy monolithic version (backup)
    └── app_legacy.py
```

## πŸ”§ Technical Architecture

### Modular Design Benefits
- **Maintainability**: Each module has a single responsibility
- **Testability**: Individual modules can be tested in isolation
- **Scalability**: Easy to add new features without affecting existing code
- **Readability**: Clear separation of concerns
- **Reusability**: Components can be reused across different parts of the app

### Key Modules
- **`molecules/analysis.py`**: SMILES validation, property calculations, drug-likeness assessment
- **`molecules/variations.py`**: Generation of multiple molecular structure visualizations
- **`ai/services.py`**: AI-powered chat responses using Hugging Face models
- **`ui/components.py`**: Reusable UI component definitions for Gradio interface
- **`ui/handlers.py`**: Event handlers, business logic, and state management

## πŸ› οΈ Troubleshooting

### Virtual Environment Issues
```bash
# Create virtual environment
python -m venv venv

# Activate it
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
```

### Common Issues
- **Import Errors**: Make sure you're in the project directory and virtual environment is activated
- **Port Already in Use**: The app will automatically use the next available port
- **Missing Dependencies**: Run `pip install -r requirements.txt`

## πŸš€ Future Enhancements

With the modular structure, it's easy to:
- Add new molecular analysis algorithms
- Implement additional AI models
- Create new UI components
- Add database integration
- Implement user authentication
- Add API endpoints
- Create unit tests for each module