Anton Bushuiev commited on
Commit
5676685
1 Parent(s): a2d12e9

Add .csv download, add inputs info

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -7,6 +7,7 @@ from functools import partial
7
  import gradio as gr
8
  import torch
9
  import numpy as np
 
10
  from Bio.PDB.Polypeptide import protein_letters_3to1
11
  from biopandas.pdb import PandasPdb
12
  from colour import Color
@@ -229,10 +230,14 @@ def predict(models, temp_dir, *inputs):
229
  ddg = np.round(ddg, 3)
230
  df = list(zip(muts, ddg))
231
 
 
 
 
 
232
  # Create 3DMol plot
233
  plot = plot_3dmol(pdb_path, ppi_path, muts, attn)
234
 
235
- return df, plot
236
 
237
 
238
  app = gr.Blocks(theme=gr.themes.Default(primary_hue="green", secondary_hue="pink"))
@@ -261,13 +266,13 @@ with app:
261
  with gr.Column():
262
  gr.Markdown("## PPI structure")
263
  with gr.Row():
264
- pdb_code = gr.Textbox(placeholder="1BUI", label="PDB code")
265
- partners = gr.Textbox(placeholder="A,B,C", label="Partners")
266
  pdb_path = gr.File(file_count="single", label="Or PDB file instead of PDB code")
267
 
268
  with gr.Column():
269
  gr.Markdown("## Mutations")
270
- muts = gr.Textbox(placeholder="SC16A,FC47A", label="List of (multi-point) mutations")
271
  muts_path = gr.File(file_count="single", label="Or file with mutations")
272
 
273
  examples = gr.Examples(
@@ -285,6 +290,7 @@ with app:
285
 
286
  # Output GUI
287
  gr.Markdown("## Predictions")
 
288
  df = gr.Dataframe(
289
  headers=["Mutation", "ddG [kcal/mol]"],
290
  datatype=["str", "number"],
@@ -310,7 +316,7 @@ with app:
310
 
311
  # Main logic
312
  inputs = [pdb_code, pdb_path, partners, muts, muts_path]
313
- outputs = [df, plot]
314
  predict = partial(predict, models, temp_dir)
315
  predict_button.click(predict, inputs=inputs, outputs=outputs)
316
 
 
7
  import gradio as gr
8
  import torch
9
  import numpy as np
10
+ import pandas as pd
11
  from Bio.PDB.Polypeptide import protein_letters_3to1
12
  from biopandas.pdb import PandasPdb
13
  from colour import Color
 
230
  ddg = np.round(ddg, 3)
231
  df = list(zip(muts, ddg))
232
 
233
+ # Create dataframe file
234
+ path = 'ppiformer_ddg_predictions.csv'
235
+ pd.DataFrame(df).rename(columns={0: "Mutation", 1: "ddG [kcal/mol]"}).to_csv(path, index=False)
236
+
237
  # Create 3DMol plot
238
  plot = plot_3dmol(pdb_path, ppi_path, muts, attn)
239
 
240
+ return df, path, plot
241
 
242
 
243
  app = gr.Blocks(theme=gr.themes.Default(primary_hue="green", secondary_hue="pink"))
 
266
  with gr.Column():
267
  gr.Markdown("## PPI structure")
268
  with gr.Row():
269
+ pdb_code = gr.Textbox(placeholder="1BUI", label="PDB code", info="Protein Data Bank code (https://www.rcsb.org/)")
270
+ partners = gr.Textbox(placeholder="A,B,C", label="Partners", info="Protein chains in the PDB file forming the PPI interface")
271
  pdb_path = gr.File(file_count="single", label="Or PDB file instead of PDB code")
272
 
273
  with gr.Column():
274
  gr.Markdown("## Mutations")
275
+ muts = gr.Textbox(placeholder="SC16A;FC47A;SC16A,FC47A", label="List of (multi-point) mutations", info="SC16A,FC47A;SC16A;FC47A for three mutations: serine to alanine at position 16 in chain C, phenylalanine to alanine at position 47 in chain C, and their double-point combination")
276
  muts_path = gr.File(file_count="single", label="Or file with mutations")
277
 
278
  examples = gr.Examples(
 
290
 
291
  # Output GUI
292
  gr.Markdown("## Predictions")
293
+ df_file = gr.File(label="Download predictions as .csv", interactive=False, visible=True)
294
  df = gr.Dataframe(
295
  headers=["Mutation", "ddG [kcal/mol]"],
296
  datatype=["str", "number"],
 
316
 
317
  # Main logic
318
  inputs = [pdb_code, pdb_path, partners, muts, muts_path]
319
+ outputs = [df, df_file, plot]
320
  predict = partial(predict, models, temp_dir)
321
  predict_button.click(predict, inputs=inputs, outputs=outputs)
322