final commit
Browse files- README.md +173 -0
- app.py +60 -14
- introduction_page.md +5 -5
README.md
CHANGED
|
@@ -11,6 +11,179 @@ license: apache-2.0
|
|
| 11 |
short_description: MCP server to simulate protein folding on Modal cluster
|
| 12 |
tags:
|
| 13 |
- mcp-server-track
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
short_description: MCP server to simulate protein folding on Modal cluster
|
| 12 |
tags:
|
| 13 |
- mcp-server-track
|
| 14 |
+
- Modal Labs Choice Award
|
| 15 |
---
|
| 16 |
|
| 17 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
|
| 21 |
+
# Stakes
|
| 22 |
+
The industry is undergoing a profound transformation due to the development of Large Language Models (LLMs) and the recent advancements that enable them to access external tools.
|
| 23 |
+
For years, companies have leveraged simulation tools to accelerate and reduce the costs of product development.
|
| 24 |
+
One of the primary challenges in the coming years will be to create agents capable of setting up, running, and processing simulations to further expedite innovation.
|
| 25 |
+
Engineers will focus on analysis rather than simulation setup, allowing them to concentrate on the most critical aspects of their work.
|
| 26 |
+
|
| 27 |
+
# Objective
|
| 28 |
+
|
| 29 |
+
This project represents a first step towards developing AI agents that can perform simulations using existing engineering softwares.
|
| 30 |
+
Key domains of application include:
|
| 31 |
+
- **CFD** (Computational Fluid Dynamics) simulations
|
| 32 |
+
- **Biology** (Protein Folding, Molecular Dynamics, etc.)
|
| 33 |
+
- **Neural network applications**
|
| 34 |
+
|
| 35 |
+
While this project focuses on biomolecules folding, the principles employed can be extended to other domains.
|
| 36 |
+
Specifically, it uses [Chai-1](https://www.chaidiscovery.com/blog/introducing-chai-1), a multi-modal foundation model for molecular structure prediction that achieves state-of-the-art performance across various benchmarks.
|
| 37 |
+
Chai-1 enables unified prediction of proteins, small molecules, DNA, RNA, glycosylations, and more.
|
| 38 |
+
|
| 39 |
+
Industrial computations frequently require substantial resources (large number of CPUs and GPUs) that are performed on High-Performance Computing (HPC) clusters.
|
| 40 |
+
To this end, [Modal Labs](https://modal.com/), a serverless platform that offers a straightforward method to run any application with the latest CPU and GPU hardware, will be used.
|
| 41 |
+
|
| 42 |
+
MCP servers are an efficient solution to connect LLMs to real world engineering applications by providing access to a set of tools.
|
| 43 |
+
The purpose of this project is to enable users to run biomolecule folding simulations using the Chai-1 model through any LLM chat or with a Gradio interface.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# Benefits
|
| 47 |
+
|
| 48 |
+
1. **Efficiency**: The MCP server's connected to high-performance computing capabilities ensure that simulations are run quickly and efficiently.
|
| 49 |
+
|
| 50 |
+
2. **Ease of Use**: Only provide necessary parameters to the user to simplify the process of setting up and running complex simulations.
|
| 51 |
+
|
| 52 |
+
3. **Integration**: The seamless integration between the LLM's chat interface and the MCP server allows for a streamlined workflow, from simulation setup to results analysis.
|
| 53 |
+
|
| 54 |
+
The following video illustrates a practical use of the MCP server to run a biomolecules folding simulation using the Chai-1 model.
|
| 55 |
+
In this scenario, Copilot is used in Agent mode with Claude 3.5 Sonnet to leverage the tools provided by the MCP server.
|
| 56 |
+
|
| 57 |
+
# MCP tools
|
| 58 |
+
1. `create_fasta_file`: Create a FASTA file from a biomolecule sequence string with a unique name.
|
| 59 |
+
2. `create_json_config`: Create a JSON configuration file from the Gradio interface inputs.
|
| 60 |
+
3. `compute_Chai1`: Compute a Chai-1 simulation on Modal labs server. Return a DataFrame with predicted scores: aggregated, pTM and ipTM.
|
| 61 |
+
4. `plot_protein`: Plot the 3D structure of a biomolecule using the DataFrame from `compute_Chai1` (Use for Gradio interface).
|
| 62 |
+
5. `show_cif_file`: Plot a 3D structure from a CIF file with the Molecule3D library (Use for the Gradio interface).
|
| 63 |
+
|
| 64 |
+
# Result example
|
| 65 |
+
The following image shows an example of a protein folding simulation using the Chai-1 model.
|
| 66 |
+
The simulation was run with the default configuration and the image is 3D view from the Gradio interface.
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# What's next?
|
| 72 |
+
1. Expose additional tools to post-process the results of the simulations.
|
| 73 |
+
The current post-processing tools are suited for the Gradio interface (ex: Plot images of the molecule structure from a file).
|
| 74 |
+
2. Continue the pipeline by adding softawres like [OpenMM](https://openmm.org/) or [Gromacs](https://www.gromacs.org/) for molecular dynamics simulations.
|
| 75 |
+
3. Perform complete simulation plans including loops over parameters fully automated by the LLM.
|
| 76 |
+
|
| 77 |
+
# Contact
|
| 78 |
+
For any issues or questions, please contact the developer or refer to the documentation.
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# Environment creation with uv
|
| 82 |
+
Run the following in a bash shell:
|
| 83 |
+
```bash
|
| 84 |
+
uv venv
|
| 85 |
+
source .venv/bin/activate
|
| 86 |
+
uv pip install gradio[mcp] modal gemmi gradio_molecule3d
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
# Connect to Modal
|
| 90 |
+
Create an account on Modal [website](https://modal.com) and run in your local terminal:
|
| 91 |
+
```
|
| 92 |
+
python -m modal setup
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
# Run the app
|
| 97 |
+
Run in a bash shell:
|
| 98 |
+
```bash
|
| 99 |
+
gradio app.py
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
# Gradio interface instructions
|
| 105 |
+
|
| 106 |
+
<div style="background-color:#f5f5f5; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
|
| 107 |
+
|
| 108 |
+
### 1. <span style="color:#e98935;">Create your JSON configuration file (Optional)</span>
|
| 109 |
+
<small>Default configuration is available if you skip this step.</small>
|
| 110 |
+
|
| 111 |
+
- 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_{unique_id}_config.json`).
|
| 112 |
+
- **Parameters:**
|
| 113 |
+
- <b>Number of diffusion time steps:</b> 1 to 500
|
| 114 |
+
- <b>Number of trunk recycles:</b> 1 to 5
|
| 115 |
+
- <b>Seed:</b> 1 to 100
|
| 116 |
+
- <b>ESM_embeddings:</b> Include or not
|
| 117 |
+
- <b>MSA_server:</b> Include or not
|
| 118 |
+
|
| 119 |
+
### 2. <span style="color:#e98935;">Upload a FASTA file with your molecule sequence (Optional)</span>
|
| 120 |
+
<small>Default FASTA files are available if you skip this step.</small>
|
| 121 |
+
|
| 122 |
+
- 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_{unique_id}_input.fasta`). Also, if you don't provide a fasta content a default sequence will be written in the file.
|
| 123 |
+
- <b style="color:#b91c1c;">Warning:</b> The header must be well formatted for Chai1 to process it.
|
| 124 |
+
|
| 125 |
+
**FASTA template:**
|
| 126 |
+
<div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
|
| 127 |
+
|
| 128 |
+
```fasta
|
| 129 |
+
>{molecule_type}|{molecule_name}
|
| 130 |
+
Sequence (for protein/RNA/DNA) or SMILES for ligand
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
**Accepted molecule types:**
|
| 136 |
+
`protein`/ `rna`/ `dna` / `ligand`
|
| 137 |
+
|
| 138 |
+
**Default input (provided by Chai1):**
|
| 139 |
+
<div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
|
| 140 |
+
|
| 141 |
+
```fasta
|
| 142 |
+
>protein|name=example-of-long-protein
|
| 143 |
+
AGSHSMRYFSTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASPRGEPRAPWVEQEGPEYWDRETQKYKRQAQTDRVSLRNLRGYYNQSEAGSHTLQWMFGCDLGPDGRLLRGYDQSAYDGKDYIALNEDLRSWTAADTAAQITQRKWEAAREAEQRRAYLEGTCVEWLRRYLENGKETLQRAEHPKTHVTHHPVSDHEATLRCWALGFYPAEITLTWQWDGEDQTQDTELVETRPAGDGTFQKWAAVVVPSGEEQRYTCHVQHEGLPEPLTLRWEP
|
| 144 |
+
|
| 145 |
+
>protein|name=example-of-short-protein
|
| 146 |
+
AIQRTPKIQVYSRHPAENGKSNFLNCYVSGFHPSDIEVDLLKNGERIEKVEHSDLSFSKDWSFYLLYYTEFTPTEKDEYACRVNHVTLSQPKIVKWDRDM
|
| 147 |
+
|
| 148 |
+
>protein|name=example-peptide
|
| 149 |
+
GAAL
|
| 150 |
+
|
| 151 |
+
>ligand|name=example-ligand-as-smiles
|
| 152 |
+
CCCCCCCCCCCCCC(=O)O
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
</div>
|
| 156 |
+
<small>For a peptide, use `protein` as the molecule type.</small>
|
| 157 |
+
|
| 158 |
+
**Other example:**
|
| 159 |
+
<div style="background-color:#ffffff; border-radius:8px; padding:18px 24px; margin-bottom:24px; border:1px solid #cccccc;">
|
| 160 |
+
|
| 161 |
+
```fasta
|
| 162 |
+
>protein|lysozyme
|
| 163 |
+
MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPDLNAAKSELDKAIGRNCNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRCAAINQVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPDRAKRVITTFRTGTWDAYKNL
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
```fasta
|
| 167 |
+
>rna|Chain B
|
| 168 |
+
UUAGGCGGCCACAGCGGUGGGGUUGCCUCCCGUACCCAUCCCGAACACGGAAGAUAAGCCCACCAGCGUUCCGGGGAGUACUGGAGUGCGCGAGCCUCUGGGAAACCCGGUUCGCCGCCACC
|
| 169 |
+
MNIFEMLRIDEGLRLKIYKDTEGYYTIGIGHLLTKSPDLNAAKSELDKAIGRNCNGVITKDEAEKLFNQDVDAAVRGILRNAKLKPVYDSLDAVRRCAAINQVFQMGETGVAGFTNSLRMLQQKRWDEAAVNLAKSRWYNQTPDRAKRVITTFRTGTWDAYKNL
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
</div>
|
| 173 |
+
|
| 174 |
+
### 3. <span style="color:#e98935;">Select your config and FASTA files</span>
|
| 175 |
+
<small>Files are stored in your working directory as you create them.</small>
|
| 176 |
+
|
| 177 |
+
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.
|
| 178 |
+
|
| 179 |
+
### 4. <span style="color:#e98935;">Run the simulation</span>
|
| 180 |
+
|
| 181 |
+
Press the `Run Simulation` button to start de folding Simulation. Five proteins folding simulations will be performed. This parameter is hard coded in Chai-1. The simulation time is expected to be from 2min to 10min depending on the molecule.
|
| 182 |
+
|
| 183 |
+
### 5. <span style="color:#e98935;">Analyse the results of your simulation</span>
|
| 184 |
+
|
| 185 |
+
To analyse the results of the simulation, two outputs are provided:
|
| 186 |
+
- A table showing the score of the 5 folding performed
|
| 187 |
+
- Interactive 3D visualization of the molecule
|
| 188 |
+
|
| 189 |
+
Finally, you can get to the `Plot CIF file π»` window to watch the cif files. This is mainly used to visualize CIF files after using this tool as an MCP server.
|
app.py
CHANGED
|
@@ -64,7 +64,7 @@ def select_best_model(
|
|
| 64 |
#Β Definition of the tools for the MCP server
|
| 65 |
#Β Function to return a fasta file
|
| 66 |
def create_fasta_file(file_content: str, name: Optional[str] = None, seq_name: Optional[str] = None) -> str:
|
| 67 |
-
"""Create a FASTA file from a
|
| 68 |
|
| 69 |
Args:
|
| 70 |
file_content (str): The content of the FASTA file required with optional line breaks
|
|
@@ -95,7 +95,10 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
| 99 |
file_path = here / "inputs/fasta" / file_name
|
| 100 |
|
| 101 |
# Write the FASTA file
|
|
@@ -137,7 +140,11 @@ def create_json_config(
|
|
| 137 |
}
|
| 138 |
|
| 139 |
# Generate file name based on provided name or unique ID
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
file_path = here / "inputs/config" / file_name
|
| 142 |
|
| 143 |
# Write the JSON file
|
|
@@ -225,7 +232,7 @@ def compute_Chai1(
|
|
| 225 |
|
| 226 |
# Function to plot the 3D protein structure
|
| 227 |
def plot_protein(result_df) -> str:
|
| 228 |
-
"""Plot the 3D structure of a
|
| 229 |
|
| 230 |
Args:
|
| 231 |
result_df (pd.DataFrame): DataFrame containing model information and scores
|
|
@@ -249,12 +256,13 @@ def plot_protein(result_df) -> str:
|
|
| 249 |
|
| 250 |
return pdb_file
|
| 251 |
|
|
|
|
| 252 |
# Function to plot a CIF file
|
| 253 |
def show_cif_file(cif_file):
|
| 254 |
"""Plot a 3D structure from a CIF file with the Molecule3D library.
|
| 255 |
|
| 256 |
Args:
|
| 257 |
-
cif_file: A
|
| 258 |
If None, the function will return None.
|
| 259 |
|
| 260 |
Returns:
|
|
@@ -271,6 +279,7 @@ def show_cif_file(cif_file):
|
|
| 271 |
|
| 272 |
return str(pdb_file)
|
| 273 |
|
|
|
|
| 274 |
# Create the Gradio interface
|
| 275 |
reps = [{"model": 0,"style": "cartoon","color": "hydrophobicity"}]
|
| 276 |
|
|
@@ -279,29 +288,50 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 279 |
gr.Markdown(
|
| 280 |
"""
|
| 281 |
# Protein Folding Simulation Interface
|
| 282 |
-
This interface provides the tools to fold
|
| 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 |
"""
|
| 291 |
# Stakes
|
| 292 |
|
| 293 |
-
The industry is
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
# Objective
|
| 296 |
|
| 297 |
-
This project
|
|
|
|
| 298 |
- **CFD** (Computational Fluid Dynamics) simulations
|
| 299 |
- **Biology** (Protein Folding, Molecular Dynamics, etc.)
|
| 300 |
- **Neural network applications**
|
| 301 |
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
"""
|
| 307 |
)
|
|
@@ -319,6 +349,16 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 319 |
label="MCP demonstration video"
|
| 320 |
)
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
with open("introduction_page.md", "r") as f:
|
| 323 |
intro_md = f.read()
|
| 324 |
gr.Markdown(intro_md)
|
|
@@ -330,10 +370,16 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 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 |
""")
|
|
@@ -377,7 +423,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 377 |
with gr.Row():
|
| 378 |
with gr.Column(scale=1):
|
| 379 |
inp2 = gr.FileExplorer(root_dir=here / "inputs/config",
|
| 380 |
-
value="
|
| 381 |
label="Configuration file",
|
| 382 |
file_count='single')
|
| 383 |
|
|
@@ -415,7 +461,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 415 |
)
|
| 416 |
|
| 417 |
|
| 418 |
-
with gr.Tab("
|
| 419 |
|
| 420 |
gr.Markdown(
|
| 421 |
"""
|
|
|
|
| 64 |
#Β Definition of the tools for the MCP server
|
| 65 |
#Β Function to return a fasta file
|
| 66 |
def create_fasta_file(file_content: str, name: Optional[str] = None, seq_name: Optional[str] = None) -> str:
|
| 67 |
+
"""Create a FASTA file from a biomolecule sequence string with a unique name.
|
| 68 |
|
| 69 |
Args:
|
| 70 |
file_content (str): The content of the FASTA file required with optional line breaks
|
|
|
|
| 95 |
|
| 96 |
# Generate a unique file name
|
| 97 |
unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
|
| 98 |
+
if name:
|
| 99 |
+
file_name = name
|
| 100 |
+
else:
|
| 101 |
+
file_name = f"chai1_{unique_id}.fasta"
|
| 102 |
file_path = here / "inputs/fasta" / file_name
|
| 103 |
|
| 104 |
# Write the FASTA file
|
|
|
|
| 140 |
}
|
| 141 |
|
| 142 |
# Generate file name based on provided name or unique ID
|
| 143 |
+
unique_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8]
|
| 144 |
+
if name:
|
| 145 |
+
file_name = name
|
| 146 |
+
else:
|
| 147 |
+
file_name = f"chai1_{unique_id}.json"
|
| 148 |
file_path = here / "inputs/config" / file_name
|
| 149 |
|
| 150 |
# Write the JSON file
|
|
|
|
| 232 |
|
| 233 |
# Function to plot the 3D protein structure
|
| 234 |
def plot_protein(result_df) -> str:
|
| 235 |
+
"""Plot the 3D structure of a biomolecule using the DataFrame from compute_Chai1.
|
| 236 |
|
| 237 |
Args:
|
| 238 |
result_df (pd.DataFrame): DataFrame containing model information and scores
|
|
|
|
| 256 |
|
| 257 |
return pdb_file
|
| 258 |
|
| 259 |
+
|
| 260 |
# Function to plot a CIF file
|
| 261 |
def show_cif_file(cif_file):
|
| 262 |
"""Plot a 3D structure from a CIF file with the Molecule3D library.
|
| 263 |
|
| 264 |
Args:
|
| 265 |
+
cif_file: A biomolecule structure file in CIF format. This can be a file uploaded by the user.
|
| 266 |
If None, the function will return None.
|
| 267 |
|
| 268 |
Returns:
|
|
|
|
| 279 |
|
| 280 |
return str(pdb_file)
|
| 281 |
|
| 282 |
+
|
| 283 |
# Create the Gradio interface
|
| 284 |
reps = [{"model": 0,"style": "cartoon","color": "hydrophobicity"}]
|
| 285 |
|
|
|
|
| 288 |
gr.Markdown(
|
| 289 |
"""
|
| 290 |
# Protein Folding Simulation Interface
|
| 291 |
+
This interface provides the tools to fold FASTA chains based on Chai-1 model. Also, this is a MCP server to provide all the tools to automate the process of folding biomolecules with LLMs.
|
| 292 |
""")
|
| 293 |
|
| 294 |
with gr.Tab("Introduction π"):
|
| 295 |
|
| 296 |
+
gr.Image("images/logo1.png", show_label=False, width=600, show_download_button=False, show_fullscreen_button=False, show_share_button=False)
|
| 297 |
|
| 298 |
gr.Markdown(
|
| 299 |
"""
|
| 300 |
# Stakes
|
| 301 |
|
| 302 |
+
The industry is undergoing a profound transformation due to the development of Large Language Models (LLMs) and the recent advancements that enable them to access external tools.
|
| 303 |
+
For years, companies have leveraged simulation tools to accelerate and reduce the costs of product development.
|
| 304 |
+
One of the primary challenges in the coming years will be to create agents capable of setting up, running, and processing simulations to further expedite innovation.
|
| 305 |
+
Engineers will focus on analysis rather than simulation setup, allowing them to concentrate on the most critical aspects of their work.
|
| 306 |
|
| 307 |
# Objective
|
| 308 |
|
| 309 |
+
This project represents a first step towards developing AI agents that can perform simulations using existing engineering softwares.
|
| 310 |
+
Key domains of application include:
|
| 311 |
- **CFD** (Computational Fluid Dynamics) simulations
|
| 312 |
- **Biology** (Protein Folding, Molecular Dynamics, etc.)
|
| 313 |
- **Neural network applications**
|
| 314 |
|
| 315 |
+
While this project focuses on biomolecules folding, the principles employed can be extended to other domains.
|
| 316 |
+
Specifically, it uses [Chai-1](https://www.chaidiscovery.com/blog/introducing-chai-1), a multi-modal foundation model for molecular structure prediction that achieves state-of-the-art performance across various benchmarks.
|
| 317 |
+
Chai-1 enables unified prediction of proteins, small molecules, DNA, RNA, glycosylations, and more.
|
| 318 |
+
|
| 319 |
+
Industrial computations frequently require substantial resources (large number of CPUs and GPUs) that are performed on High-Performance Computing (HPC) clusters.
|
| 320 |
+
To this end, [Modal Labs](https://modal.com/), a serverless platform that offers a straightforward method to run any application with the latest CPU and GPU hardware, will be used.
|
| 321 |
+
|
| 322 |
+
MCP servers are an efficient solution to connect LLMs to real world engineering applications by providing access to a set of tools.
|
| 323 |
+
The purpose of this project is to enable users to run biomolecule folding simulations using the Chai-1 model through any LLM chat or with a Gradio interface.
|
| 324 |
+
|
| 325 |
+
# Benefits
|
| 326 |
+
|
| 327 |
+
1. **Efficiency**: The MCP server's connected to high-performance computing capabilities ensure that simulations are run quickly and efficiently.
|
| 328 |
|
| 329 |
+
2. **Ease of Use**: Only provide necessary parameters to the user to simplify the process of setting up and running complex simulations.
|
| 330 |
+
|
| 331 |
+
3. **Integration**: The seamless integration between the LLM's chat interface and the MCP server allows for a streamlined workflow, from simulation setup to results analysis.
|
| 332 |
+
|
| 333 |
+
The following video illustrates a practical use of the MCP server to run a biomolecule folding simulation using the Chai-1 model.
|
| 334 |
+
In this scenario, Copilot is used in Agent mode with Claude 3.5 Sonnet to leverage the tools provided by the MCP server.
|
| 335 |
|
| 336 |
"""
|
| 337 |
)
|
|
|
|
| 349 |
label="MCP demonstration video"
|
| 350 |
)
|
| 351 |
|
| 352 |
+
gr.Markdown(
|
| 353 |
+
"""
|
| 354 |
+
# MCP tools
|
| 355 |
+
1. `create_fasta_file`: Create a FASTA file from a biomolecule sequence string with a unique name.
|
| 356 |
+
2. `create_json_config`: Create a JSON configuration file from the Gradio interface inputs.
|
| 357 |
+
3. `compute_Chai1`: Compute a Chai-1 simulation on Modal labs server. Return a DataFrame with protein scores.
|
| 358 |
+
4. `plot_protein`: Plot the 3D structure of a biomolecule using the DataFrame from `compute_Chai1` (Use for Gradio interface).
|
| 359 |
+
5. `show_cif_file`: Plot a 3D structure from a CIF file with the Molecule3D library (Use for the Gradio interface).
|
| 360 |
+
""")
|
| 361 |
+
|
| 362 |
with open("introduction_page.md", "r") as f:
|
| 363 |
intro_md = f.read()
|
| 364 |
gr.Markdown(intro_md)
|
|
|
|
| 370 |
The simulation was run with the default configuration and the image is 3D view from the Gradio interface.
|
| 371 |
""")
|
| 372 |
|
| 373 |
+
gr.Image("images/protein.png", show_label=True, width=400, label="Protein Folding example", show_download_button=False, show_fullscreen_button=False, show_share_button=False)
|
| 374 |
|
| 375 |
gr.Markdown(
|
| 376 |
"""
|
| 377 |
+
# What's next?
|
| 378 |
+
1. Expose additional tools to post-process the results of the simulations (ex: Plot images of the molecule structure from a file).
|
| 379 |
+
The current post-processing tools are suited for the Gradio interface.
|
| 380 |
+
2. Continue the pipeline by adding softawres like [OpenMM](https://openmm.org/) or [Gromacs](https://www.gromacs.org/) for molecular dynamics simulations.
|
| 381 |
+
3. Perform full simulation plans including loops over parameters fully automated by the LLM.
|
| 382 |
+
|
| 383 |
# Contact
|
| 384 |
For any issues or questions, please contact the developer or refer to the documentation.
|
| 385 |
""")
|
|
|
|
| 423 |
with gr.Row():
|
| 424 |
with gr.Column(scale=1):
|
| 425 |
inp2 = gr.FileExplorer(root_dir=here / "inputs/config",
|
| 426 |
+
value="chai1_default_inference.json",
|
| 427 |
label="Configuration file",
|
| 428 |
file_count='single')
|
| 429 |
|
|
|
|
| 461 |
)
|
| 462 |
|
| 463 |
|
| 464 |
+
with gr.Tab("Plot CIF file π»"):
|
| 465 |
|
| 466 |
gr.Markdown(
|
| 467 |
"""
|
introduction_page.md
CHANGED
|
@@ -6,14 +6,14 @@ code[class*="language-bash"], pre[class*="language-bash"] {
|
|
| 6 |
|
| 7 |
---
|
| 8 |
|
| 9 |
-
#
|
| 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_{
|
| 17 |
- **Parameters:**
|
| 18 |
- <b>Number of diffusion time steps:</b> 1 to 500
|
| 19 |
- <b>Number of trunk recycles:</b> 1 to 5
|
|
@@ -24,7 +24,7 @@ code[class*="language-bash"], pre[class*="language-bash"] {
|
|
| 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_{
|
| 28 |
- <b style="color:#b91c1c;">Warning:</b> The header must be well formatted for Chai1 to process it.
|
| 29 |
|
| 30 |
**FASTA template:**
|
|
@@ -77,7 +77,7 @@ In the `Run folding simulation π` window, refresh the file list by clicking o
|
|
| 77 |
|
| 78 |
### 4. <span style="color:#e98935;">Run the simulation</span>
|
| 79 |
|
| 80 |
-
Press the `Run Simulation` button to start
|
| 81 |
|
| 82 |
### 5. <span style="color:#e98935;">Analyse the results of your simulation</span>
|
| 83 |
|
|
@@ -85,6 +85,6 @@ 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 `
|
| 89 |
|
| 90 |
</div>
|
|
|
|
| 6 |
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# Gradio interface instructions
|
| 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_{unique_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
|
|
|
|
| 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_{unique_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:**
|
|
|
|
| 77 |
|
| 78 |
### 4. <span style="color:#e98935;">Run the simulation</span>
|
| 79 |
|
| 80 |
+
Press the `Run Simulation` button to start the folding simulation. Five biomolecules folding simulations will be performed. 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 |
|
|
|
|
| 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 `Plot 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>
|