samsl commited on
Commit
a73e54e
1 Parent(s): a1d4104

Update gradio version and fix error logging

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +12 -7
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 📚
4
  colorFrom: green
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.41.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: green
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 4.38.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.py CHANGED
@@ -52,6 +52,7 @@ our funders that it is being used. Thank you!
52
  # """
53
 
54
  article = """
 
55
 
56
  Note that running here with the "TT3D" model does not run structure prediction on the sequences, but rather uses the [ProstT5](https://github.com/mheinzinger/ProstT5) language model to
57
  translate amino acid to 3di sequences. This is much faster than running structure prediction, but the results may not be as accurate.
@@ -95,7 +96,8 @@ def predict(model_name, pairs_file, sequence_file, progress = gr.Progress()):
95
  # gr.Info("Loading files...")
96
  try:
97
  seqs = SeqIO.to_dict(SeqIO.parse(sequence_file.name, "fasta"))
98
- except ValueError as _:
 
99
  raise gr.Error("Invalid FASTA file - duplicate entry")
100
 
101
  if Path(pairs_file.name).suffix == ".csv":
@@ -104,7 +106,8 @@ def predict(model_name, pairs_file, sequence_file, progress = gr.Progress()):
104
  pairs = pd.read_csv(pairs_file.name, sep="\t")
105
  try:
106
  pairs.columns = ["protein1", "protein2"]
107
- except ValueError as _:
 
108
  raise gr.Error("Invalid pairs file - must have two columns 'protein1' and 'protein2'")
109
 
110
  do_foldseek = False
@@ -134,6 +137,7 @@ def predict(model_name, pairs_file, sequence_file, progress = gr.Progress()):
134
  # print(foldseek_embeddings[k])
135
  # print(foldseek_embeddings[k].shape)
136
 
 
137
  progress(0, desc="Starting...")
138
  results = []
139
  for i in progress.tqdm(range(len(pairs))):
@@ -165,7 +169,8 @@ def predict(model_name, pairs_file, sequence_file, progress = gr.Progress()):
165
  return results, file_path
166
 
167
  except Exception as e:
168
- gr.Error(e)
 
169
  return None, None
170
 
171
  demo = gr.Interface(
@@ -177,13 +182,13 @@ demo = gr.Interface(
177
  ],
178
  outputs = [
179
  gr.DataFrame(label='Results', headers=['Protein 1', 'Protein 2', 'Interaction']),
180
- gr.File(label="Download results", type="file")
181
  ],
182
- # title = title,
183
- # description = description,
184
  article = article,
185
  theme = theme,
186
  )
187
 
188
  if __name__ == "__main__":
189
- demo.queue(max_size=20).launch()
 
52
  # """
53
 
54
  article = """
55
+ Pairs file should be a comma-separated or tab-separated (.csv/.tsv) file with two columns, "protein1" and "protein2", where each row contains the names of two proteins. The sequences should be a FASTA file with the corresponding protein names as the headers.
56
 
57
  Note that running here with the "TT3D" model does not run structure prediction on the sequences, but rather uses the [ProstT5](https://github.com/mheinzinger/ProstT5) language model to
58
  translate amino acid to 3di sequences. This is much faster than running structure prediction, but the results may not be as accurate.
 
96
  # gr.Info("Loading files...")
97
  try:
98
  seqs = SeqIO.to_dict(SeqIO.parse(sequence_file.name, "fasta"))
99
+ except ValueError as e:
100
+ print(e)
101
  raise gr.Error("Invalid FASTA file - duplicate entry")
102
 
103
  if Path(pairs_file.name).suffix == ".csv":
 
106
  pairs = pd.read_csv(pairs_file.name, sep="\t")
107
  try:
108
  pairs.columns = ["protein1", "protein2"]
109
+ except ValueError as e:
110
+ print(e)
111
  raise gr.Error("Invalid pairs file - must have two columns 'protein1' and 'protein2'")
112
 
113
  do_foldseek = False
 
137
  # print(foldseek_embeddings[k])
138
  # print(foldseek_embeddings[k].shape)
139
 
140
+ print("Starting predictions")
141
  progress(0, desc="Starting...")
142
  results = []
143
  for i in progress.tqdm(range(len(pairs))):
 
169
  return results, file_path
170
 
171
  except Exception as e:
172
+ print(e)
173
+ raise gr.Error(e)
174
  return None, None
175
 
176
  demo = gr.Interface(
 
182
  ],
183
  outputs = [
184
  gr.DataFrame(label='Results', headers=['Protein 1', 'Protein 2', 'Interaction']),
185
+ gr.File(label="Download results", type="filepath")
186
  ],
187
+ title = title,
188
+ description = description,
189
  article = article,
190
  theme = theme,
191
  )
192
 
193
  if __name__ == "__main__":
194
+ demo.queue(max_size=20).launch()