PhDFlo commited on
Commit
895bdb9
·
1 Parent(s): 1648059
Files changed (2) hide show
  1. app.py +34 -13
  2. introduction_page.md +30 -29
app.py CHANGED
@@ -95,7 +95,7 @@ def create_fasta_file(file_content: str, name: Optional[str] = None, seq_name: O
95
 
96
  # Generate a unique file name
97
  unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
98
- file_name = f"{name if name else unique_id}"
99
  file_path = here / "inputs/fasta" / file_name
100
 
101
  # Write the FASTA file
@@ -137,7 +137,7 @@ def create_json_config(
137
  }
138
 
139
  # Generate file name based on provided name or unique ID
140
- file_name = f"{name if name else hashlib.sha256(uuid4().bytes).hexdigest()[:8]}"
141
  file_path = here / "inputs/config" / file_name
142
 
143
  # Write the JSON file
@@ -279,12 +279,12 @@ with gr.Blocks(theme=theme) as demo:
279
  gr.Markdown(
280
  """
281
  # Protein Folding Simulation Interface
282
- 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.
283
  """)
284
 
285
  with gr.Tab("Introduction 🔭"):
286
 
287
- gr.Image("images/logo1.png", show_label=False,width=400)
288
 
289
  gr.Markdown(
290
  """
@@ -307,7 +307,13 @@ with gr.Blocks(theme=theme) as demo:
307
  )
308
 
309
  gr.HTML(
310
- """<iframe width="600" height="338"
 
 
 
 
 
 
311
  src="https://www.youtube.com/embed/P9cAKxJ9Zh8"
312
  frameborder="0" allowfullscreen></iframe>""",
313
  label="MCP demonstration video"
@@ -316,7 +322,22 @@ with gr.Blocks(theme=theme) as demo:
316
  with open("introduction_page.md", "r") as f:
317
  intro_md = f.read()
318
  gr.Markdown(intro_md)
 
 
 
 
 
 
 
 
 
319
 
 
 
 
 
 
 
320
 
321
  with gr.Tab("Configuration 📦"):
322
 
@@ -353,18 +374,18 @@ with gr.Blocks(theme=theme) as demo:
353
 
354
 
355
  with gr.Tab("Run folding simulation 🚀"):
356
- with gr.Row():
357
- with gr.Column(scale=1):
358
- inp1 = gr.FileExplorer(root_dir=here / "inputs/fasta",
359
- value="chai1_default_input.fasta",
360
- label="Input Fasta file",
361
- file_count='single')
362
-
363
  with gr.Column(scale=1):
364
  inp2 = gr.FileExplorer(root_dir=here / "inputs/config",
365
  value="chai1_quick_inference.json",
366
  label="Configuration file",
367
  file_count='single')
 
 
 
 
 
 
368
  btn_refresh = gr.Button("Refresh available files")
369
 
370
  # Only workaround I found to update the file explorer
@@ -394,7 +415,7 @@ with gr.Blocks(theme=theme) as demo:
394
  )
395
 
396
 
397
- with gr.Tab("Show protein from a cif file 💻"):
398
 
399
  gr.Markdown(
400
  """
 
95
 
96
  # Generate a unique file name
97
  unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
98
+ file_name = f"{name if name else "chai1_"+unique_id+".fasta"}"
99
  file_path = here / "inputs/fasta" / file_name
100
 
101
  # Write the FASTA file
 
137
  }
138
 
139
  # Generate file name based on provided name or unique ID
140
+ file_name = f"{name if name else "chai1_"+hashlib.sha256(uuid4().bytes).hexdigest()[:8]+".json"}"
141
  file_path = here / "inputs/config" / file_name
142
 
143
  # Write the JSON file
 
279
  gr.Markdown(
280
  """
281
  # Protein Folding Simulation Interface
282
+ This interface provides 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.
283
  """)
284
 
285
  with gr.Tab("Introduction 🔭"):
286
 
287
+ gr.Image("images/logo1.png", show_label=False, width=600, show_download_button=False, show_fullscreen_button=False)
288
 
289
  gr.Markdown(
290
  """
 
307
  )
308
 
309
  gr.HTML(
310
+ """<style>
311
+ iframe {
312
+ display: block;
313
+ margin: 0 auto;
314
+ }
315
+ </style>
316
+ <iframe width="600" height="338"
317
  src="https://www.youtube.com/embed/P9cAKxJ9Zh8"
318
  frameborder="0" allowfullscreen></iframe>""",
319
  label="MCP demonstration video"
 
322
  with open("introduction_page.md", "r") as f:
323
  intro_md = f.read()
324
  gr.Markdown(intro_md)
325
+
326
+ gr.Markdown(
327
+ """
328
+ # Result example
329
+ The following image shows an example of a protein folding simulation using the Chai-1 model.
330
+ The simulation was run with the default configuration and the image is 3D view from the Gradio interface.
331
+ """)
332
+
333
+ gr.Image("images/protein.png", show_label=True, width=400, label="Protein Folding example", show_download_button=False, show_fullscreen_button=False)
334
 
335
+ gr.Markdown(
336
+ """
337
+ # Contact
338
+ For any issues or questions, please contact the developer or refer to the documentation.
339
+ """)
340
+
341
 
342
  with gr.Tab("Configuration 📦"):
343
 
 
374
 
375
 
376
  with gr.Tab("Run folding simulation 🚀"):
377
+ with gr.Row():
 
 
 
 
 
 
378
  with gr.Column(scale=1):
379
  inp2 = gr.FileExplorer(root_dir=here / "inputs/config",
380
  value="chai1_quick_inference.json",
381
  label="Configuration file",
382
  file_count='single')
383
+
384
+ with gr.Column(scale=1):
385
+ inp1 = gr.FileExplorer(root_dir=here / "inputs/fasta",
386
+ value="chai1_default_input.fasta",
387
+ label="Input Fasta file",
388
+ file_count='single')
389
  btn_refresh = gr.Button("Refresh available files")
390
 
391
  # Only workaround I found to update the file explorer
 
415
  )
416
 
417
 
418
+ with gr.Tab("Show molecule from a CIF file 💻"):
419
 
420
  gr.Markdown(
421
  """
introduction_page.md CHANGED
@@ -10,10 +10,10 @@ code[class*="language-bash"], pre[class*="language-bash"] {
10
 
11
  <div style="background-color:#f5f5f5; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
12
 
13
- ### 1. <span style="color:#2563eb;">(Optional) Create your JSON configuration file</span>
14
  <small>Default configuration is available if you skip this step.</small>
15
 
16
- - Set your simulation parameters and generate the JSON config file. A unique identifier will be assigned (e.g., `chai_{run_id}_config.json`).
17
  - **Parameters:**
18
  - <b>Number of diffusion time steps:</b> 1 to 500
19
  - <b>Number of trunk recycles:</b> 1 to 5
@@ -21,22 +21,28 @@ code[class*="language-bash"], pre[class*="language-bash"] {
21
  - <b>ESM_embeddings:</b> Include or not
22
  - <b>MSA_server:</b> Include or not
23
 
24
- ### 2. <span style="color:#2563eb;">(Optional) Upload a FASTA file with your molecule sequence</span>
25
  <small>Default FASTA files are available if you skip this step.</small>
26
 
27
- - Write your FASTA content and create the file. A unique identifier will be assigned (e.g., `chai_{run_id}_input.fasta`).
28
  - <b style="color:#b91c1c;">Warning:</b> The header must be well formatted for Chai1 to process it.
29
 
30
  **FASTA template:**
 
 
31
  ```fasta
32
  >{molecule_type}|{molecule_name}
33
  Sequence (for protein/RNA/DNA) or SMILES for ligand
34
  ```
35
 
 
 
36
  **Accepted molecule types:**
37
  `protein`/ `rna`/ `dna` / `ligand`
38
 
39
  **Default input (provided by Chai1):**
 
 
40
  ```fasta
41
  >protein|name=example-of-long-protein
42
  AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASPRGEPRAPWVEQEGPEYWDRETQKYKRQAQTDRVSLRNLRGYYNQSEAGSHTLQWMFGCDLGPDGRLLRGYDQSAYDGKDYIALNEDLRSWTAADTAAQITQRKWEAAREAEQRRAYLEGTCVEWLRRYLENGKETLQRAEHPKTHVTHHPVSDHEATLRCWALGFYPAEITLTWQWDGEDQTQDTELVETRPAGDGTFQKWAAVVVPSGEEQRYTCHVQHEGLPEPLTLRWEP
@@ -50,40 +56,35 @@ GAAL
50
  >ligand|name=example-ligand-as-smiles
51
  CCCCCCCCCCCCCC(=O)O
52
  ```
 
 
53
  <small>For a peptide, use `protein` as the molecule type.</small>
54
 
55
  **Other example:**
 
 
56
  ```fasta
57
  >protein|lysozyme
58
  MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPDLNAAKSELDKAIGRNCNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRCAAINQVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPDRAKRVITTFRTGTWDAYKNL
59
  ```
60
- ### 3. <span style="color:#2563eb;">Select your config and FASTA files</span>
 
 
 
61
  <small>Files are stored in your working directory as you create them.</small>
62
 
63
- ### 4. <span style="color:#2563eb;">Click the "Run" button to start the simulation</span>
64
 
65
- ### 5. <span style="color:#2563eb;">View the 3D visualization of your molecule</span>
66
- </div>
67
 
68
- ## Simulation parameters choice
69
- If no config or fasta files are created, default values are chosen:
70
- - chai1_default_input.fasta
71
- - chai1_quick_inference.json
72
-
73
- The files content is diplayed at the bottom of the page.
74
- The default json configuration makes the computation fast (about 2min) but results can be disappointing.
75
- Please use chai1_default_inference.json to have a wonderful protein 😃.
76
-
77
- - chai1_quick_inference.json
78
- ```json
79
- {
80
- "num_trunk_recycles": 1,
81
- "num_diffn_timesteps": 10,
82
- "seed": 42,
83
- "use_esm_embeddings": true
84
- "use_msa_server": false
85
- }
86
- ```
87
 
88
- # Contact
89
- For any issues or questions, please contact the developer or refer to the documentation.
 
10
 
11
  <div style="background-color:#f5f5f5; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
12
 
13
+ ### 1. <span style="color:#e98935;">Create your JSON configuration file (Optional)</span>
14
  <small>Default configuration is available if you skip this step.</small>
15
 
16
+ - In the `Configuration 📦` window, set your simulation parameters and generate the JSON config file. You can provide a file name in the dedicated box that will appear in the list of available configuration files. If you don't, a unique identifier will be assigned (e.g., `chai_{run_id}_config.json`).
17
  - **Parameters:**
18
  - <b>Number of diffusion time steps:</b> 1 to 500
19
  - <b>Number of trunk recycles:</b> 1 to 5
 
21
  - <b>ESM_embeddings:</b> Include or not
22
  - <b>MSA_server:</b> Include or not
23
 
24
+ ### 2. <span style="color:#e98935;">Upload a FASTA file with your molecule sequence (Optional)</span>
25
  <small>Default FASTA files are available if you skip this step.</small>
26
 
27
+ - In the `Configuration 📦` window, write your FASTA content and create the file. You can provide a file name in the dedicated box that will appear in the list of available configuration files. If you don't provide a file name a unique identifier will be assigned (e.g., `chai_{run_id}_input.fasta`). Also, if you don't provide a fasta content a default sequence will be written in the file.
28
  - <b style="color:#b91c1c;">Warning:</b> The header must be well formatted for Chai1 to process it.
29
 
30
  **FASTA template:**
31
+ <div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
32
+
33
  ```fasta
34
  >{molecule_type}|{molecule_name}
35
  Sequence (for protein/RNA/DNA) or SMILES for ligand
36
  ```
37
 
38
+ </div>
39
+
40
  **Accepted molecule types:**
41
  `protein`/ `rna`/ `dna` / `ligand`
42
 
43
  **Default input (provided by Chai1):**
44
+ <div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
45
+
46
  ```fasta
47
  >protein|name=example-of-long-protein
48
  AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASPRGEPRAPWVEQEGPEYWDRETQKYKRQAQTDRVSLRNLRGYYNQSEAGSHTLQWMFGCDLGPDGRLLRGYDQSAYDGKDYIALNEDLRSWTAADTAAQITQRKWEAAREAEQRRAYLEGTCVEWLRRYLENGKETLQRAEHPKTHVTHHPVSDHEATLRCWALGFYPAEITLTWQWDGEDQTQDTELVETRPAGDGTFQKWAAVVVPSGEEQRYTCHVQHEGLPEPLTLRWEP
 
56
  >ligand|name=example-ligand-as-smiles
57
  CCCCCCCCCCCCCC(=O)O
58
  ```
59
+
60
+ </div>
61
  <small>For a peptide, use `protein` as the molecule type.</small>
62
 
63
  **Other example:**
64
+ <div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
65
+
66
  ```fasta
67
  >protein|lysozyme
68
  MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPDLNAAKSELDKAIGRNCNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRCAAINQVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPDRAKRVITTFRTGTWDAYKNL
69
  ```
70
+
71
+ </div>
72
+
73
+ ### 3. <span style="color:#e98935;">Select your config and FASTA files</span>
74
  <small>Files are stored in your working directory as you create them.</small>
75
 
76
+ In the `Run folding simulation 🚀` window, refresh the file list by clicking on the `Refresh available files`. Then select the configuration and fasta file you want.
77
 
78
+ ### 4. <span style="color:#e98935;">Run the simulation</span>
 
79
 
80
+ Press the `Run Simulation` button to start de folding Simulation. Five protein folding simulations will be performed. Unfortunately, this parameter is hard coded in Chai-1. The simulation time is expected to be from 2min to 10min depending on the molecule.
81
+
82
+ ### 5. <span style="color:#e98935;">Analyse the results of your simulation</span>
83
+
84
+ To analyse the results of the simulation, two outputs are provided:
85
+ - A table showing the score of the 5 folding performed
86
+ - Interactive 3D visualization of the molecule
87
+
88
+ Finally, you can get to the `Show molecule from a CIF file 💻` window to watch the cif files. This is mainly used to visualize CIF files after using this tool as an MCP server.
 
 
 
 
 
 
 
 
 
 
89
 
90
+ </div>