PhDFlo commited on
Commit
67f7561
·
1 Parent(s): 669a9d8

dev interface

Browse files
app.py CHANGED
@@ -8,16 +8,69 @@ import gradio as gr
8
  import gemmi
9
  from gradio_molecule3d import Molecule3D
10
  from modal_app import app, chai1_inference, download_inference_dependencies, here
 
 
11
 
12
- # Definition of the tools for the MCP server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # Function to return a fasta file
15
- def create_fasta_file(sequence: str, name: Optional[str] = None) -> str:
16
  """Create a FASTA file from a protein sequence string with a unique name.
17
 
18
  Args:
19
  sequence (str): The protein sequence string with optional line breaks
20
- name (str, optional): The name/identifier for the sequence. Defaults to "PROTEIN"
 
 
21
 
22
  Returns:
23
  str: Name of the created FASTA file
@@ -28,30 +81,30 @@ def create_fasta_file(sequence: str, name: Optional[str] = None) -> str:
28
  # Check if the first line is a FASTA header
29
  if not lines[0].startswith('>'):
30
  # If no header provided, add one
31
- if name is None:
32
- name = "PROTEIN"
33
- sequence = f">{name}\n{sequence}"
34
 
35
  # Create FASTA content (preserving line breaks)
36
  fasta_content = sequence
37
 
38
  # Generate a unique file name
39
  unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
40
- file_name = f"chai1_{unique_id}_input.fasta"
41
- file_path = here / "inputs" / file_name
42
 
43
  # Write the FASTA file
44
  with open(file_path, "w") as f:
45
  f.write(fasta_content)
46
-
47
- return file_name
48
 
49
  # Function to create a JSON file
50
  def create_json_config(
51
  num_diffn_timesteps: int,
52
  num_trunk_recycles: int,
53
  seed: int,
54
- options: list
 
55
  ) -> str:
56
  """Create a JSON configuration file from the Gradio interface inputs.
57
 
@@ -60,6 +113,7 @@ def create_json_config(
60
  num_trunk_recycles (int): Number of trunk recycles from slider
61
  seed (int): Random seed from slider
62
  options (list): List of selected options from checkbox group
 
63
 
64
  Returns:
65
  str: Name of the created JSON file
@@ -77,16 +131,13 @@ def create_json_config(
77
  "use_msa_server": use_msa_server
78
  }
79
 
80
- # Generate a unique file name
81
- unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
82
- file_name = f"chai1_{unique_id}_config.json"
83
- file_path = here / "inputs" / file_name
84
 
85
- # Write the JSON file
86
  with open(file_path, "w") as f:
87
  json.dump(config, f, indent=4)
88
-
89
- return file_name
90
 
91
 
92
  # Function to compute Chai1 inference
@@ -97,10 +148,13 @@ def compute_Chai1(
97
  """Compute a Chai1 simulation.
98
 
99
  Args:
100
- x (float | int): The number to square.
 
 
 
101
 
102
  Returns:
103
- float: The square of the input number.
104
  """
105
  with app.run():
106
 
@@ -111,16 +165,16 @@ def compute_Chai1(
111
 
112
  # Define fasta file
113
  if not fasta_file:
114
- fasta_file = here / "inputs" / "chai1_default_input.fasta"
115
  print(f"🧬 running Chai inference on {fasta_file}")
116
- fasta_file = here / "inputs" / fasta_file
117
  print(fasta_file)
118
  fasta_content = Path(fasta_file).read_text()
119
 
120
  # Define inference config file
121
  if not inference_config_file:
122
- inference_config_file = here / "inputs" / "chai1_quick_inference.json"
123
- inference_config_file = here / "inputs" / inference_config_file
124
  print(f"🧬 loading Chai inference config from {inference_config_file}")
125
  inference_config = json.loads(Path(inference_config_file).read_text())
126
 
@@ -136,11 +190,17 @@ def compute_Chai1(
136
 
137
  print(f"🧬 saving results to disk locally in {output_dir}")
138
  for ii, (scores, cif) in enumerate(results):
139
- (Path(output_dir) / f"{run_id}-scores.model_idx_{ii}.npz").write_bytes(scores)
140
- (Path(output_dir) / f"{run_id}-preds.model_idx_{ii}.cif").write_text(cif)
141
 
 
 
 
 
 
 
142
  # Take the last cif file and convert it to pdb
143
- cif_name = str(output_dir)+"/"+str(run_id)+"-preds.model_idx_"+str(ii)+".cif"
144
  pdb_name = cif_name.split('.cif')[0] + '.pdb'
145
  st = gemmi.read_structure(cif_name)
146
  st.write_minimal_pdb(pdb_name)
@@ -151,73 +211,170 @@ def compute_Chai1(
151
  # Create the Gradio interface
152
  reps = [{"model": 0,"style": "cartoon","color": "hydrophobicity"}]
153
 
154
- with gr.Blocks() as demo:
155
 
156
  gr.Markdown(
157
  """
158
- # Protein Folding Simulation with Chai1
159
- This interface allows you to run Chai1 simulations on a given Fasta sequence file.
160
  """)
161
 
162
  with gr.Tab("Introduction 🔭"):
163
 
 
 
164
  gr.Markdown(
165
  """
166
- ## Chai1 Simulation Interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  This interface allows you to run Chai1 simulations on a given Fasta sequence file.
168
  The Chai1 model is designed to predict the 3D structure of proteins based on their amino acid sequences.
169
  You can input a Fasta file containing the sequence of the molecule you want to simulate, and the output will be a 3D representation of the molecule based on the Chai1 model.
170
- """)
 
 
 
 
 
 
 
 
 
171
 
172
  with gr.Tab("Configuration 📦"):
173
 
 
 
 
 
 
174
  with gr.Row():
175
  with gr.Column(scale=1):
176
- slider_nb = gr.Slider(1, 500, value=200, label="Number of diffusion time steps", info="Choose the number of diffusion time steps for the simulation", step=1, interactive=True, elem_id="num_iterations")
177
  slider_trunk = gr.Slider(1, 5, value=3, label="Number of trunk recycles", info="Choose the number of iterations for the simulation", step=1, interactive=True, elem_id="trunk_number")
178
  slider_seed = gr.Slider(1, 100, value=42, label="Seed", info="Choose the seed", step=1, interactive=True, elem_id="seed")
179
  check_options = gr.CheckboxGroup(["ESM_embeddings", "MSA_server"], value=["ESM_embeddings",], label="Additionnal options", info="Options to use ESM embeddings and MSA server", elem_id="options")
180
- json_output = gr.Textbox(placeholder="Config file name", label="Config file name")
181
  button_json = gr.Button("Create Config file")
182
- button_json.click(fn=create_json_config, inputs=[slider_nb, slider_trunk, slider_seed, check_options], outputs=[json_output])
 
183
 
184
  with gr.Column(scale=1):
185
- text_input = gr.Textbox(placeholder="Fasta format sequences", label="Fasta content", lines=10)
186
- text_output = gr.Textbox(placeholder="Fasta file name", label="Fasta file name")
187
- text_button = gr.Button("Create Fasta file")
188
- text_button.click(fn=create_fasta_file, inputs=[text_input], outputs=[text_output])
189
-
190
-
191
- gr.Markdown(
192
- """
193
- You can input a Fasta file containing the sequence of the molecule you want to simulate.
194
- The output will be a 3D representation of the molecule based on the Chai1 model.
195
- ## Instructions
196
- 1. Upload a Fasta sequence file containing the molecule sequence.
197
- 2. Click the "Run" button to start the simulation.
198
- 3. The output will be a 3D visualization of the molecule.
199
- ## Example Input
200
- You can use the default Fasta file provided in the inputs directory, or upload your own.
201
- ## Output
202
- The output will be a 3D representation of the molecule, which you can interact with.
203
- ## Note
204
- Make sure to have the necessary dependencies installed and the Chai1 model available in the specified directory.
205
- ## Disclaimer
206
- This interface is for educational and research purposes only. The results may vary based on the input sequence and the Chai1 model's capabilities.
207
- ## Contact
208
- For any issues or questions, please contact the developer or refer to the documentation.
209
- ## Example Fasta File
210
- ```
211
- >protein|name=example-protein
212
- AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFD
213
- """)
214
 
215
- with gr.Tab("Run folding simulation 🚀"):
216
- inp1 = gr.Textbox(placeholder="Fasta Sequence file", label="Input Fasta file")
217
- inp2 = gr.Textbox(placeholder="Config file", label="JSON Config file")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  btn = gr.Button("Run")
219
- out = Molecule3D(label="Molecule3D", reps=reps)
220
  btn.click(fn=compute_Chai1, inputs=[inp1 , inp2], outputs=[out])
 
221
 
222
  # Launch both the Gradio web interface and the MCP server
223
  if __name__ == "__main__":
 
8
  import gemmi
9
  from gradio_molecule3d import Molecule3D
10
  from modal_app import app, chai1_inference, download_inference_dependencies, here
11
+ from numpy import load
12
+ from typing import List
13
 
14
+ theme = gr.themes.Default(
15
+ text_size="md",
16
+ radius_size="lg",
17
+ )
18
+
19
+ # Helper functions
20
+ def select_best_model(
21
+ run_id: str,
22
+ number_of_scores: int=5,
23
+ scores_to_print: List[str]=None,
24
+ results_dir: str="results/score",
25
+ prefix: str="-scores.model_idx_",
26
+ ):
27
+ """
28
+ Selects the best model based on the aggregate score among several simulation results.
29
+
30
+ Args:
31
+ run_id (str): Unique identifier for the inference run.
32
+ number_of_scores (int, optional): Number of models to evaluate (number of score files to read). Default is 5.
33
+ scores_to_print (List[str], optional): List of score names to display for each model (e.g., ["aggregate_score", "ptm", "iptm"]). Default is ["aggregate_score", "ptm", "iptm"].
34
+ results_dir (str, optional): Directory where the result files are located. Default is "results/score".
35
+ prefix (str, optional): Prefix used in the score file names. Default is "-scores.model_idx_".
36
 
37
+ Returns:
38
+ Tuple[int, float]:
39
+ - best_model (int): Index of the best model (the one with the highest aggregate score and without inter-chain clashes).
40
+ - max_aggregate_score (float): Value of the highest aggregate score.
41
+ """
42
+ print(f"🧬 Start reading scores for each inference...")
43
+ if scores_to_print is None:
44
+ scores_to_print = ["aggregate_score", "ptm", "iptm"]
45
+ max_aggregate_score = 0
46
+ best_model = None
47
+ for model_index in range(number_of_scores):
48
+ print(f" 🧬 Reading scores for model {model_index}...")
49
+ data = load(f"{results_dir}/{run_id}{prefix}{model_index}.npz")
50
+ if data["has_inter_chain_clashes"][0] == False:
51
+ for item in scores_to_print:
52
+ print(f"{item}: {data[item][0]}")
53
+ else:
54
+ print(f" 🧬 Model {model_index} has inter-chain clashes, skipping scores.")
55
+ continue
56
+ if data["aggregate_score"][0] > max_aggregate_score:
57
+ max_aggregate_score = data["aggregate_score"][0]
58
+ best_model = int(model_index)
59
+ print(
60
+ f"🧬 Best model is {best_model} with an aggregate score of {max_aggregate_score}."
61
+ )
62
+ return best_model, max_aggregate_score
63
+
64
+ # Definition of the tools for the MCP server
65
  # Function to return a fasta file
66
+ def create_fasta_file(sequence: str, name: Optional[str] = None, seq_name: Optional[str] = None) -> str:
67
  """Create a FASTA file from a protein sequence string with a unique name.
68
 
69
  Args:
70
  sequence (str): The protein sequence string with optional line breaks
71
+ name (str, optional): Name to use for the FASATA file. If not provided, a unique ID will be generated
72
+ seq_name (str, optional): The name/identifier for the sequence. Defaults to "PROTEIN"
73
+
74
 
75
  Returns:
76
  str: Name of the created FASTA file
 
81
  # Check if the first line is a FASTA header
82
  if not lines[0].startswith('>'):
83
  # If no header provided, add one
84
+ if seq_name is None:
85
+ seq_name = "PROTEIN"
86
+ sequence = f">{seq_name}\n{sequence}"
87
 
88
  # Create FASTA content (preserving line breaks)
89
  fasta_content = sequence
90
 
91
  # Generate a unique file name
92
  unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
93
+ file_name = f"chai1_{name if name else unique_id}_input.fasta"
94
+ file_path = here / "inputs/fasta" / file_name
95
 
96
  # Write the FASTA file
97
  with open(file_path, "w") as f:
98
  f.write(fasta_content)
99
+
 
100
 
101
  # Function to create a JSON file
102
  def create_json_config(
103
  num_diffn_timesteps: int,
104
  num_trunk_recycles: int,
105
  seed: int,
106
+ options: list,
107
+ name: Optional[str] = None
108
  ) -> str:
109
  """Create a JSON configuration file from the Gradio interface inputs.
110
 
 
113
  num_trunk_recycles (int): Number of trunk recycles from slider
114
  seed (int): Random seed from slider
115
  options (list): List of selected options from checkbox group
116
+ name (str, optional): Name to use for the config file. If not provided, a unique ID will be generated
117
 
118
  Returns:
119
  str: Name of the created JSON file
 
131
  "use_msa_server": use_msa_server
132
  }
133
 
134
+ # Generate file name based on provided name or unique ID
135
+ file_name = f"chai1_{name if name else hashlib.sha256(uuid4().bytes).hexdigest()[:8]}_config.json"
136
+ file_path = here / "inputs/config" / file_name
 
137
 
138
+ # Write the JSON file
139
  with open(file_path, "w") as f:
140
  json.dump(config, f, indent=4)
 
 
141
 
142
 
143
  # Function to compute Chai1 inference
 
148
  """Compute a Chai1 simulation.
149
 
150
  Args:
151
+ fasta_file (str, optional): FASTA file name containing the protein sequence.
152
+ If not provided, uses the default input file.
153
+ inference_config_file (str, optional): JSON configuration file name for inference.
154
+ If not provided, uses the default quick inference configuration.
155
 
156
  Returns:
157
+ str: Output PDB file name containing the predicted structure.
158
  """
159
  with app.run():
160
 
 
165
 
166
  # Define fasta file
167
  if not fasta_file:
168
+ fasta_file = here / "inputs/fasta" / "chai1_default_input.fasta"
169
  print(f"🧬 running Chai inference on {fasta_file}")
170
+ fasta_file = here / "inputs/fasta" / fasta_file
171
  print(fasta_file)
172
  fasta_content = Path(fasta_file).read_text()
173
 
174
  # Define inference config file
175
  if not inference_config_file:
176
+ inference_config_file = here / "inputs/config" / "chai1_quick_inference.json"
177
+ inference_config_file = here / "inputs/config" / inference_config_file
178
  print(f"🧬 loading Chai inference config from {inference_config_file}")
179
  inference_config = json.loads(Path(inference_config_file).read_text())
180
 
 
190
 
191
  print(f"🧬 saving results to disk locally in {output_dir}")
192
  for ii, (scores, cif) in enumerate(results):
193
+ (Path(output_dir, "score") / f"{run_id}-scores.model_idx_{ii}.npz").write_bytes(scores)
194
+ (Path(output_dir, "molecules") / f"{run_id}-preds.model_idx_{ii}.cif").write_text(cif)
195
 
196
+ best_model, max_aggregate_score = select_best_model(
197
+ run_id=run_id,
198
+ scores_to_print=["aggregate_score", "ptm", "iptm"],
199
+ number_of_scores=len(results),
200
+ results_dir=str(Path(output_dir, "score"))
201
+ )
202
  # Take the last cif file and convert it to pdb
203
+ cif_name = str(Path(output_dir, "molecules"))+"/"+str(run_id)+"-preds.model_idx_"+str(best_model)+".cif"
204
  pdb_name = cif_name.split('.cif')[0] + '.pdb'
205
  st = gemmi.read_structure(cif_name)
206
  st.write_minimal_pdb(pdb_name)
 
211
  # Create the Gradio interface
212
  reps = [{"model": 0,"style": "cartoon","color": "hydrophobicity"}]
213
 
214
+ with gr.Blocks(theme=theme) as demo:
215
 
216
  gr.Markdown(
217
  """
218
+ # Protein Folding Simulation Interface
219
+ This interface provides you the tools to fold any FASTA chain based on Chai-1 model. Also, this is a MCP server to provide all the tools to automate the process of folding proteins with LLMs.
220
  """)
221
 
222
  with gr.Tab("Introduction 🔭"):
223
 
224
+ gr.Image("images/logo1.png", show_label=False,width=400)
225
+
226
  gr.Markdown(
227
  """
228
+
229
+ # Stakes
230
+
231
+ The industry is being deeply changed by the development of LLMs and the recent possibilities to provide them access to external tools.
232
+ For years now companies are using simulation tools in order faster and reduce the development cost of a product.
233
+ One of the challenge in the coming years will be to create agents that can setup, run and process simulations to faster the development of new products.
234
+
235
+ # Objective
236
+
237
+ This project is a first step in this creating AI agents that perform simulations on existing softwares.
238
+ 1) Several domains are of major interest:
239
+ - CFD (Computational Fluid Dynamics) simulations
240
+ - Biology simulations (Protein Folding, Molecular Dynamics, etc.)
241
+ - All applications that use neural networks
242
+
243
+ --> This project is focused on the protein folding domain, but the same principles can be applied to other domains.
244
+
245
+ 2) Generally, industrial computations are performed on HPC clusters, which have access to large ressources.
246
+
247
+ --> The simulation need to run on a separate server
248
+
249
+ 3) The LLM needs to be able to access the simulation results in order to provide a complete answer to the user.
250
+
251
+ --> The simulation results need to be accessible by the LLM
252
+
253
+ ## Modal
254
+
255
+ Modal (https://modal.com/) is a serverless platform that provides a simple way to run any application with the latest CPU and GPU hardware.
256
+
257
+ ## Chai-1 Model
258
+
259
+ Chai-1 (https://www.chaidiscovery.com/blog/introducing-chai-1) is a multi-modal foundation model for molecular structure prediction that performs at the state-of-the-art across a variety of benchmarks.
260
+ Chai-1 enables unified prediction of proteins, small molecules, DNA, RNA, glycosylations, and more.
261
+ Chai-1 use on Modal server is an example on how to run folding simulations.
262
+ Thus, it is a good choice to start with.
263
+
264
+ # Instructions
265
+ 1. Upload a Fasta sequence file containing the molecule sequence.
266
+ 2. Click the "Run" button to start the simulation.
267
+ 3. The output will be a 3D visualization of the molecule.
268
+
269
+ ## Simulation parameters choice
270
+ If no config or fasta files are created, default values are chosen:
271
+ - chai1_default_input.fasta
272
+ - chai1_quick_inference.json
273
+
274
+ The files content is diplayed at the bottom of the page.
275
+ The default json configuration makes the computation fast (about 2min) but results can be disappointing.
276
+ Please use chai1_default_inference.json to have a wonderful protein 😃.
277
+
278
+ - chai1_default_input.fasta
279
+ ```
280
+ >protein|name=example-of-long-protein
281
+ AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASPRGEPRAPWVEQEGPEYWDRETQKYKRQAQTDRVSLRNLRGYYNQSEAGSHTLQWMFGCDLGPDGRLLRGYDQSAYDGKDYIALNEDLRSWTAADTAAQITQRKWEAAREAEQRRAYLEGTCVEWLRRYLENGKETLQRAEHPKTHVTHHPVSDHEATLRCWALGFYPAEITLTWQWDGEDQTQDTELVETRPAGDGTFQKWAAVVVPSGEEQRYTCHVQHEGLPEPLTLRWEP
282
+ >protein|name=example-of-short-protein
283
+ AIQRTPKIQVYSRHPAENGKSNFLNCYVSGFHPSDIEVDLLKNGERIEKVEHSDLSFSKDWSFYLLYYTEFTPTEKDEYACRVNHVTLSQPKIVKWDRDM
284
+ >protein|name=example-peptide
285
+ GAAL
286
+ >ligand|name=example-ligand-as-smiles
287
+ CCCCCCCCCCCCCC(=O)O
288
+ ```
289
+ - chai1_quick_inference.json
290
+ ```json
291
+ {
292
+ "num_trunk_recycles": 1,
293
+ "num_diffn_timesteps": 10,
294
+ "seed": 42,
295
+ "use_esm_embeddings": true
296
+ "use_msa_server": false
297
+ }
298
+ ```
299
+
300
+ # Work performed
301
  This interface allows you to run Chai1 simulations on a given Fasta sequence file.
302
  The Chai1 model is designed to predict the 3D structure of proteins based on their amino acid sequences.
303
  You can input a Fasta file containing the sequence of the molecule you want to simulate, and the output will be a 3D representation of the molecule based on the Chai1 model.
304
+
305
+ You can input a Fasta file containing the sequence of the molecule you want to simulate.
306
+ The output will be a 3D representation of the molecule based on the Chai1 model.
307
+
308
+ # Disclaimer
309
+ This interface is for educational and research purposes only. The results may vary based on the input sequence and the Chai1 model's capabilities.
310
+ # Contact
311
+ For any issues or questions, please contact the developer or refer to the documentation.
312
+ """)
313
+
314
 
315
  with gr.Tab("Configuration 📦"):
316
 
317
+ gr.Markdown(
318
+ """
319
+ ## Fasta file and configuration generator
320
+ """)
321
+
322
  with gr.Row():
323
  with gr.Column(scale=1):
324
+ slider_nb = gr.Slider(1, 500, value=300, label="Number of diffusion time steps", info="Choose the number of diffusion time steps for the simulation", step=1, interactive=True, elem_id="num_iterations")
325
  slider_trunk = gr.Slider(1, 5, value=3, label="Number of trunk recycles", info="Choose the number of iterations for the simulation", step=1, interactive=True, elem_id="trunk_number")
326
  slider_seed = gr.Slider(1, 100, value=42, label="Seed", info="Choose the seed", step=1, interactive=True, elem_id="seed")
327
  check_options = gr.CheckboxGroup(["ESM_embeddings", "MSA_server"], value=["ESM_embeddings",], label="Additionnal options", info="Options to use ESM embeddings and MSA server", elem_id="options")
328
+ config_name = gr.Textbox(placeholder="Enter a name for the config (optional)", label="Configuration file name")
329
  button_json = gr.Button("Create Config file")
330
+ button_json.click(fn=create_json_config, inputs=[slider_nb, slider_trunk, slider_seed, check_options, config_name], outputs=[])
331
+
332
 
333
  with gr.Column(scale=1):
334
+ fasta_input = gr.Textbox(placeholder="Fasta format sequences", label="Fasta content", lines=10)
335
+ fasta_name = gr.Textbox(placeholder="Enter a name for the fasta file (optional)", label="Fasta file name")
336
+ fasta_button = gr.Button("Create Fasta file")
337
+ fasta_button.click(fn=create_fasta_file, inputs=[fasta_input, fasta_name], outputs=[])
338
+
339
+ gr.Markdown(
340
+ """
341
+ ## Example Fasta File
342
+ ```
343
+ >protein|name=example-protein
344
+ AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFD
345
+ ```
346
+ """)
347
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
 
349
+ with gr.Tab("Run folding simulation 🚀"):
350
+ with gr.Row():
351
+ with gr.Column(scale=1):
352
+ inp1 = gr.FileExplorer(root_dir=here / "inputs/fasta",
353
+ value="chai1_default_input.fasta",
354
+ label="Input Fasta file",
355
+ file_count='single',
356
+ glob="*.fasta")
357
+
358
+ with gr.Column(scale=1):
359
+ inp2 = gr.FileExplorer(root_dir=here / "inputs/config",
360
+ value="chai1_quick_inference.json",
361
+ label="Configuration file",
362
+ file_count='single',
363
+ glob="*.json")
364
+ btn_refresh = gr.Button("Refresh available files")
365
+
366
+ # Only workaround I found to update the file explorer
367
+ def update_file_explorer():
368
+ return gr.FileExplorer(root_dir=here), gr.FileExplorer(root_dir=here)
369
+ def update_file_explorer_2():
370
+ return gr.FileExplorer(root_dir=here / "inputs/fasta"), gr.FileExplorer(root_dir=here / "inputs/config")
371
+
372
+ btn_refresh.click(update_file_explorer, outputs=[inp1,inp2]).then(update_file_explorer_2, outputs=[inp1, inp2])
373
+
374
+ out = Molecule3D(label="Plot the 3D Molecule", reps=reps)
375
  btn = gr.Button("Run")
 
376
  btn.click(fn=compute_Chai1, inputs=[inp1 , inp2], outputs=[out])
377
+
378
 
379
  # Launch both the Gradio web interface and the MCP server
380
  if __name__ == "__main__":
inputs/boltz1_ligand.yaml DELETED
@@ -1,11 +0,0 @@
1
- sequences:
2
- - protein:
3
- id: [A, B]
4
- sequence: MVTPEGNVSLVDESLLVGVTDEDRAVRSAHQFYERLIGLWAPAVMEAAHELGVFAALAEAPADSGELARRLDCDARAMRVLLDALYAYDVIDRIHDTNGFRYLLSAEARECLLPGTLFSLVGKFMHDINVAWPAWRNLAEVVRHGARDTSGAESPNGIAQEDYESLVGGINFWAPPIVTTLSRKLRASGRSGDATASVLDVGCGTGLYSQLLLREFPRWTATGLDVERIATLANAQALRLGVEERFATRAGDFWRGGWGTGYDLVLFANIFHLQTPASAVRLMRHAAACLAPDGLVAVVDQIVDADREPKTPQDRFALLFAASMTNTGGGDAYTFQEYEEWFTAAGLQRIETLDTPMHRILLARRATEPSAVPEGQASENLYFQ
5
- msa: ./seq1.a3m
6
- - ligand:
7
- id: [C, D]
8
- ccd: SAH
9
- - ligand:
10
- id: [E, F]
11
- smiles: N[C@@H](Cc1ccc(O)cc1)C(=O)O
 
 
 
 
 
 
 
 
 
 
 
 
inputs/{chai1_default_inference.json → config/chai1_default_inference.json} RENAMED
File without changes
inputs/{chai1_quick_inference.json → config/chai1_quick_inference.json} RENAMED
File without changes
inputs/{chai1_default_input.fasta → fasta/chai1_default_input.fasta} RENAMED
File without changes
inputs/seq1.a3m DELETED
The diff for this file is too large to render. See raw diff