sagawa commited on
Commit
e443961
1 Parent(s): aa82e0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -53
app.py CHANGED
@@ -29,58 +29,6 @@ class Config:
29
 
30
 
31
 
32
- def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Config()):
33
- try:
34
- results = []
35
- for pdb_file in pdb_files:
36
- pdb_path = pdb_file.name
37
- os.system("chmod 777 bin/foldseek")
38
- sequences = get_foldseek_seq(pdb_path)
39
- if not sequences:
40
- return "Failed to extract sequence from the PDB file."
41
- sequence = sequences[2] if model_choice == "SaProt" else sequences[0]
42
-
43
- prediction = predict_stability_core(model_choice, organism_choice, sequence, cfg)
44
-
45
- To modify the existing Gradio interface to accept multiple PDB files and process them, you need to adjust the file input component and modify the function that processes the PDB files. Here’s how you can do it:
46
-
47
- Adjusting the Gradio Interface
48
- Allow Multiple File Uploads: Modify the gr.File component to accept multiple files.
49
- Process Each File Separately: Adjust the prediction function to loop over all uploaded files and process each one.
50
- Here's the updated code:
51
-
52
- python
53
- Copy code
54
- import gradio as gr
55
- import sys
56
- import random
57
- import os
58
- import pandas as pd
59
- import torch
60
- import itertools
61
- from torch.utils.data import DataLoader
62
- from transformers import AutoTokenizer
63
-
64
- sys.path.append("scripts/")
65
- from foldseek_util import get_struc_seq
66
- from utils import seed_everything
67
- from models import PLTNUM_PreTrainedModel
68
- from datasets_ import PLTNUMDataset
69
-
70
-
71
- class Config:
72
- def __init__(self):
73
- self.batch_size = 2
74
- self.use_amp = False
75
- self.num_workers = 1
76
- self.max_length = 512
77
- self.used_sequence = "left"
78
- self.padding_side = "right"
79
- self.task = "classification"
80
- self.sequence_col = "sequence"
81
- self.seed = 42
82
-
83
-
84
  def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Config()):
85
  try:
86
  results = []
@@ -95,7 +43,6 @@ def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Con
95
 
96
  prediction = predict_stability_core(model_choice, organism_choice, sequence, cfg)
97
  results.append(f"Prediction for {pdb_file.name}: {prediction}")
98
-
99
  return "<br>".join(results)
100
  except Exception as e:
101
  return f"An error occurred: {str(e)}"
 
29
 
30
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Config()):
33
  try:
34
  results = []
 
43
 
44
  prediction = predict_stability_core(model_choice, organism_choice, sequence, cfg)
45
  results.append(f"Prediction for {pdb_file.name}: {prediction}")
 
46
  return "<br>".join(results)
47
  except Exception as e:
48
  return f"An error occurred: {str(e)}"