Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -172,99 +172,99 @@ def run_inference(mode: str, model_name: str, num_molecules: int, seed_num: str,
|
|
172 |
|
173 |
with gr.Blocks(theme=gr.themes.Ocean()) as demo:
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
gr.
|
191 |
-
|
192 |
-
gr.HTML("""
|
193 |
-
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
194 |
-
<!-- arXiv badge -->
|
195 |
-
<a href="https://arxiv.org/abs/2302.07868" target="_blank" style="text-decoration: none;">
|
196 |
-
<div style="
|
197 |
-
display: inline-block;
|
198 |
-
background-color: #b31b1b;
|
199 |
-
color: #ffffff !important;
|
200 |
-
padding: 5px 10px;
|
201 |
-
border-radius: 5px;
|
202 |
-
font-size: 14px;">
|
203 |
-
<span style="font-weight: bold;">arXiv</span> 2302.07868
|
204 |
-
</div>
|
205 |
-
</a>
|
206 |
-
|
207 |
-
<!-- GitHub badge -->
|
208 |
-
<a href="https://github.com/HUBioDataLab/DrugGEN" target="_blank" style="text-decoration: none;">
|
209 |
-
<div style="
|
210 |
-
display: inline-block;
|
211 |
-
background-color: #24292e;
|
212 |
-
color: #ffffff !important;
|
213 |
-
padding: 5px 10px;
|
214 |
-
border-radius: 5px;
|
215 |
-
font-size: 14px;">
|
216 |
-
<span style="font-weight: bold;">GitHub</span> Repository
|
217 |
-
</div>
|
218 |
-
</a>
|
219 |
-
</div>
|
220 |
-
""")
|
221 |
-
|
222 |
-
with gr.Accordion("About DrugGEN Models", open=False):
|
223 |
-
gr.Markdown("""
|
224 |
-
## Model Variations
|
225 |
-
|
226 |
-
### DrugGEN-AKT1
|
227 |
-
This model is designed to generate molecules targeting the human AKT1 protein (UniProt ID: P31749).
|
228 |
-
|
229 |
-
### DrugGEN-CDK2
|
230 |
-
This model is designed to generate molecules targeting the human CDK2 protein (UniProt ID: P24941).
|
231 |
-
|
232 |
-
### DrugGEN-NoTarget
|
233 |
-
This is a general-purpose model that generates diverse drug-like molecules without targeting a specific protein.
|
234 |
-
- Useful for exploring chemical space, generating diverse scaffolds, and creating molecules with drug-like properties.
|
235 |
-
|
236 |
-
For more details, see our [paper on arXiv](https://arxiv.org/abs/2302.07868).
|
237 |
-
""")
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
- **Internal Diversity**: Diversity within the generated set (higher is more diverse)
|
257 |
-
|
258 |
-
### Drug-likeness Metrics
|
259 |
-
- **QED (Quantitative Estimate of Drug-likeness)**: Score from 0-1 measuring how drug-like a molecule is (higher is better)
|
260 |
-
- **SA Score (Synthetic Accessibility)**: Score from 1-10 indicating ease of synthesis (lower is better)
|
261 |
-
|
262 |
-
### Similarity Metrics
|
263 |
-
- **SNN ChEMBL**: Similarity to ChEMBL molecules (higher means more similar to known drug-like compounds)
|
264 |
-
- **SNN Real Inhibitors**: Similarity to known drugs (higher means more similar to approved drugs)
|
265 |
""")
|
266 |
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
model_name = gr.Radio(
|
269 |
choices=("DrugGEN-AKT1", "DrugGEN-CDK2", "DrugGEN-NoTarget"),
|
270 |
value="DrugGEN-AKT1",
|
@@ -272,62 +272,60 @@ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
|
|
272 |
info="Choose which protein target or general model to use for molecule generation"
|
273 |
)
|
274 |
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
-
|
300 |
-
custom_smiles = gr.Textbox(
|
301 |
-
label="Input SMILES (one per line, maximum 100 molecules)",
|
302 |
-
placeholder="C(C(=O)O)N\nCCO\n...",
|
303 |
-
lines=10
|
304 |
-
)
|
305 |
-
|
306 |
-
custom_submit = gr.Button(
|
307 |
-
value="Generate Molecules using Custom SMILES",
|
308 |
-
variant="primary",
|
309 |
-
size="lg"
|
310 |
-
)
|
311 |
-
|
312 |
-
gr.Markdown("### Created by the HUBioDataLab | [GitHub](https://github.com/HUBioDataLab/DrugGEN) | [Paper](https://arxiv.org/abs/2302.07868)")
|
313 |
-
|
314 |
-
with gr.Column(scale=2):
|
315 |
-
basic_metrics_df = gr.Dataframe(
|
316 |
-
headers=["Validity", "Uniqueness", "Novelty (Train)", "Novelty (Inference)", "Novelty (Real Inhibitors)", "Runtime (s)"],
|
317 |
-
elem_id="basic-metrics"
|
318 |
-
)
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
elem_id="advanced-metrics"
|
323 |
-
)
|
324 |
-
|
325 |
-
file_download = gr.File(label="Download All Generated Molecules (SMILES format)")
|
326 |
-
|
327 |
-
image_output = gr.Image(label="Structures of Randomly Selected Generated Molecules",
|
328 |
-
elem_id="molecule_display")
|
329 |
|
330 |
|
|
|
331 |
|
332 |
# Set up the click actions for each tab.
|
333 |
classical_submit.click(
|
|
|
172 |
|
173 |
with gr.Blocks(theme=gr.themes.Ocean()) as demo:
|
174 |
|
175 |
+
# Add custom CSS for styling
|
176 |
+
gr.HTML("""
|
177 |
+
<style>
|
178 |
+
#metrics-container {
|
179 |
+
border: 1px solid rgba(128, 128, 128, 0.3);
|
180 |
+
border-radius: 8px;
|
181 |
+
padding: 15px;
|
182 |
+
margin-top: 15px;
|
183 |
+
margin-bottom: 15px;
|
184 |
+
background-color: rgba(255, 255, 255, 0.05);
|
185 |
+
}
|
186 |
+
</style>
|
187 |
+
""")
|
188 |
+
|
189 |
+
with gr.Row():
|
190 |
+
with gr.Column(scale=1):
|
191 |
+
gr.Markdown("# DrugGEN: Target Centric De Novo Design of Drug Candidate Molecules with Graph Generative Deep Adversarial Networks")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
+
gr.HTML("""
|
194 |
+
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
195 |
+
<!-- arXiv badge -->
|
196 |
+
<a href="https://arxiv.org/abs/2302.07868" target="_blank" style="text-decoration: none;">
|
197 |
+
<div style="
|
198 |
+
display: inline-block;
|
199 |
+
background-color: #b31b1b;
|
200 |
+
color: #ffffff !important;
|
201 |
+
padding: 5px 10px;
|
202 |
+
border-radius: 5px;
|
203 |
+
font-size: 14px;">
|
204 |
+
<span style="font-weight: bold;">arXiv</span> 2302.07868
|
205 |
+
</div>
|
206 |
+
</a>
|
207 |
|
208 |
+
<!-- GitHub badge -->
|
209 |
+
<a href="https://github.com/HUBioDataLab/DrugGEN" target="_blank" style="text-decoration: none;">
|
210 |
+
<div style="
|
211 |
+
display: inline-block;
|
212 |
+
background-color: #24292e;
|
213 |
+
color: #ffffff !important;
|
214 |
+
padding: 5px 10px;
|
215 |
+
border-radius: 5px;
|
216 |
+
font-size: 14px;">
|
217 |
+
<span style="font-weight: bold;">GitHub</span> Repository
|
218 |
+
</div>
|
219 |
+
</a>
|
220 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
""")
|
222 |
|
223 |
+
with gr.Accordion("About DrugGEN Models", open=False):
|
224 |
+
gr.Markdown("""
|
225 |
+
## Model Variations
|
226 |
+
|
227 |
+
### DrugGEN-AKT1
|
228 |
+
This model is designed to generate molecules targeting the human AKT1 protein (UniProt ID: P31749).
|
229 |
+
|
230 |
+
### DrugGEN-CDK2
|
231 |
+
This model is designed to generate molecules targeting the human CDK2 protein (UniProt ID: P24941).
|
232 |
+
|
233 |
+
### DrugGEN-NoTarget
|
234 |
+
This is a general-purpose model that generates diverse drug-like molecules without targeting a specific protein.
|
235 |
+
- Useful for exploring chemical space, generating diverse scaffolds, and creating molecules with drug-like properties.
|
236 |
+
|
237 |
+
For more details, see our [paper on arXiv](https://arxiv.org/abs/2302.07868).
|
238 |
+
""")
|
239 |
+
|
240 |
+
with gr.Accordion("Understanding the Metrics", open=False):
|
241 |
+
gr.Markdown("""
|
242 |
+
## Evaluation Metrics
|
243 |
+
|
244 |
+
### Basic Metrics
|
245 |
+
- **Validity**: Percentage of generated molecules that are chemically valid
|
246 |
+
- **Uniqueness**: Percentage of unique molecules among valid ones
|
247 |
+
- **Runtime**: Time taken to generate or evaluate the molecules
|
248 |
+
|
249 |
+
### Novelty Metrics
|
250 |
+
- **Novelty (Train)**: Percentage of molecules not found in the training set
|
251 |
+
- **Novelty (Inference)**: Percentage of molecules not found in the test set
|
252 |
+
- **Novelty (Real Inhibitors)**: Percentage of molecules not found in known inhibitors of the target protein
|
253 |
+
|
254 |
+
### Structural Metrics
|
255 |
+
- **Average Length**: Average component length in the generated molecules
|
256 |
+
- **Mean Atom Type**: Average distribution of atom types
|
257 |
+
- **Internal Diversity**: Diversity within the generated set (higher is more diverse)
|
258 |
+
|
259 |
+
### Drug-likeness Metrics
|
260 |
+
- **QED (Quantitative Estimate of Drug-likeness)**: Score from 0-1 measuring how drug-like a molecule is (higher is better)
|
261 |
+
- **SA Score (Synthetic Accessibility)**: Score from 1-10 indicating ease of synthesis (lower is better)
|
262 |
+
|
263 |
+
### Similarity Metrics
|
264 |
+
- **SNN ChEMBL**: Similarity to ChEMBL molecules (higher means more similar to known drug-like compounds)
|
265 |
+
- **SNN Real Inhibitors**: Similarity to known drugs (higher means more similar to approved drugs)
|
266 |
+
""")
|
267 |
+
|
268 |
model_name = gr.Radio(
|
269 |
choices=("DrugGEN-AKT1", "DrugGEN-CDK2", "DrugGEN-NoTarget"),
|
270 |
value="DrugGEN-AKT1",
|
|
|
272 |
info="Choose which protein target or general model to use for molecule generation"
|
273 |
)
|
274 |
|
275 |
+
with gr.Tabs():
|
276 |
+
with gr.TabItem("Classical Generation"):
|
277 |
+
num_molecules = gr.Slider(
|
278 |
+
minimum=10,
|
279 |
+
maximum=200,
|
280 |
+
value=100,
|
281 |
+
step=10,
|
282 |
+
label="Number of Molecules to Generate",
|
283 |
+
info="This space runs on a CPU, which may result in slower performance. Generating 100 molecules takes approximately 6 minutes. Therefore, we set a 200-molecule cap."
|
284 |
+
)
|
285 |
+
|
286 |
+
seed_num = gr.Textbox(
|
287 |
+
label="Random Seed (Optional)",
|
288 |
+
value="",
|
289 |
+
info="Set a specific seed for reproducible results, or leave empty for random generation"
|
290 |
+
)
|
291 |
+
|
292 |
+
classical_submit = gr.Button(
|
293 |
+
value="Generate Molecules",
|
294 |
+
variant="primary",
|
295 |
+
size="lg"
|
296 |
+
)
|
297 |
+
|
298 |
+
with gr.TabItem("Custom Input SMILES"):
|
299 |
+
custom_smiles = gr.Textbox(
|
300 |
+
label="Input SMILES (one per line, maximum 100 molecules)",
|
301 |
+
placeholder="C(C(=O)O)N\nCCO\n...",
|
302 |
+
lines=10
|
303 |
+
)
|
304 |
+
|
305 |
+
custom_submit = gr.Button(
|
306 |
+
value="Generate Molecules using Custom SMILES",
|
307 |
+
variant="primary",
|
308 |
+
size="lg"
|
309 |
+
)
|
310 |
+
|
311 |
+
with gr.Column(scale=2):
|
312 |
+
basic_metrics_df = gr.Dataframe(
|
313 |
+
headers=["Validity", "Uniqueness", "Novelty (Train)", "Novelty (Inference)", "Novelty (Real Inhibitors)", "Runtime (s)"],
|
314 |
+
elem_id="basic-metrics"
|
315 |
+
)
|
316 |
+
|
317 |
+
advanced_metrics_df = gr.Dataframe(
|
318 |
+
headers=["QED", "SA Score", "Internal Diversity", "SNN (ChEMBL)", "SNN (Real Inhibitors)", "Average Length"],
|
319 |
+
elem_id="advanced-metrics"
|
320 |
+
)
|
321 |
|
322 |
+
file_download = gr.File(label="Download All Generated Molecules (SMILES format)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
|
324 |
+
image_output = gr.Image(label="Structures of Randomly Selected Generated Molecules",
|
325 |
+
elem_id="molecule_display")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
|
328 |
+
gr.Markdown("### Created by the HUBioDataLab | [GitHub](https://github.com/HUBioDataLab/DrugGEN) | [Paper](https://arxiv.org/abs/2302.07868)")
|
329 |
|
330 |
# Set up the click actions for each tab.
|
331 |
classical_submit.click(
|