ACA050 commited on
Commit
988fbc4
·
verified ·
1 Parent(s): dc2f8d1

Upload 9 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ thermomutdb.json filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import matplotlib.pyplot as plt
4
+ import io
5
+ import base64
6
+ import shap
7
+ import numpy as np
8
+ import pandas as pd
9
+ import torch
10
+ import torch.nn as nn
11
+ import requests
12
+ import re
13
+ import json
14
+ import pickle # Added for loading .pkl and .json files
15
+ import os # Added for path checking
16
+
17
+ # --- Device Configuration ---
18
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
19
+
20
+ # --- Model Architecture (MultiTaskMLP) ---
21
+ class MultiTaskMLP(nn.Module):
22
+ def __init__(self, input_dim, num_classes, dropout_rate=0.3):
23
+ super(MultiTaskMLP, self).__init__()
24
+ self.shared_layers = nn.Sequential(
25
+ nn.Linear(input_dim, 256),
26
+ nn.BatchNorm1d(256),
27
+ nn.ReLU(),
28
+ nn.Dropout(dropout_rate),
29
+ nn.Linear(256, 128),
30
+ nn.BatchNorm1d(128),
31
+ nn.ReLU(),
32
+ nn.Dropout(dropout_rate)
33
+ )
34
+ self.regression_head = nn.Sequential(
35
+ nn.Linear(128, 64),
36
+ nn.BatchNorm1d(64),
37
+ nn.ReLU(),
38
+ nn.Dropout(dropout_rate),
39
+ nn.Linear(64, 1)
40
+ )
41
+ self.classification_head = nn.Sequential(
42
+ nn.Linear(128, 64),
43
+ nn.BatchNorm1d(64),
44
+ nn.ReLU(),
45
+ nn.Dropout(dropout_rate),
46
+ nn.Linear(64, num_classes)
47
+ )
48
+
49
+ def forward(self, x):
50
+ shared_features = self.shared_layers(x)
51
+ ddg_output = self.regression_head(shared_features)
52
+ effect_output = self.classification_head(shared_features)
53
+ return ddg_output, effect_output
54
+
55
+ # --- SHAP Wrapper Classes ---
56
+ class RegressionHeadWrapper(nn.Module):
57
+ def __init__(self, original_model):
58
+ super().__init__()
59
+ self.original_model = original_model
60
+
61
+ def forward(self, x):
62
+ ddg_output, _ = self.original_model(x)
63
+ return ddg_output
64
+
65
+ class ClassificationHeadWrapper(nn.Module):
66
+ def __init__(self, original_model):
67
+ super().__init__()
68
+ self.original_model = original_model
69
+
70
+ def forward(self, x):
71
+ _, effect_output = self.original_model(x)
72
+ return effect_output
73
+
74
+ # --- Helper Function: plot_to_base64 ---
75
+ def plot_to_base64(fig):
76
+ buffer = io.BytesIO()
77
+ fig.savefig(buffer, format='png', bbox_inches='tight')
78
+ buffer.seek(0)
79
+ image_base64 = base64.b64encode(buffer.read()).decode('utf-8')
80
+ plt.close(fig)
81
+ return f"<img src='data:image/png;base64,{image_base64}'>"
82
+
83
+ # --- Helper Function: AA_PROPERTIES and get_aa_property_comparison ---
84
+ # AA_PROPERTIES is now loaded from global_vars.json in the main script
85
+ def get_aa_property_comparison(original_aa, mutant_aa):
86
+ # global AA_PROPERTIES is assumed to be loaded after global_vars.json
87
+ if original_aa not in AA_PROPERTIES or mutant_aa not in AA_PROPERTIES:
88
+ return "Invalid amino acid code(s) for comparison."
89
+ results = {}
90
+ for prop, _ in AA_PROPERTIES['A'].items():
91
+ orig_val = AA_PROPERTIES[original_aa].get(prop, 0)
92
+ mut_val = AA_PROPERTIES[mutant_aa].get(prop, 0)
93
+ change = mut_val - orig_val
94
+ results[prop] = {
95
+ 'original': orig_val,
96
+ 'mutant': mut_val,
97
+ 'change': f'{change:.2f}'
98
+ }
99
+ return results
100
+
101
+ # --- Helper Function: get_top_features_by_shap ---
102
+ def get_top_features_by_shap(explainer_obj, background_data_tensor, feature_names, top_n=10, task_type='regression'):
103
+ if task_type == 'regression':
104
+ shap_values_background = explainer_obj.shap_values(background_data_tensor)
105
+ if isinstance(shap_values_background, list):
106
+ shap_values_background = np.array(shap_values_background).squeeze()
107
+ elif shap_values_background.ndim == 3:
108
+ shap_values_background = shap_values_background.squeeze(axis=-1)
109
+ elif task_type == 'classification':
110
+ shap_values_background_raw = explainer_obj.shap_values(background_data_tensor)
111
+ if isinstance(shap_values_background_raw, list):
112
+ abs_shap_values = np.mean(np.abs(np.array(shap_values_background_raw)), axis=0)
113
+ elif shap_values_background_raw.ndim == 3:
114
+ abs_shap_values = np.mean(np.abs(shap_values_background_raw), axis=-1)
115
+ else:
116
+ abs_shap_values = np.abs(shap_values_background_raw)
117
+ shap_values_background = abs_shap_values
118
+ else:
119
+ raise ValueError("task_type must be 'regression' or 'classification'")
120
+ mean_abs_shap = np.mean(np.abs(shap_values_background), axis=0)
121
+ feature_importance = pd.DataFrame({
122
+ 'Feature': feature_names,
123
+ 'Mean_Abs_SHAP': mean_abs_shap
124
+ })
125
+ top_features = feature_importance.sort_values(by='Mean_Abs_SHAP', ascending=False).head(top_n)
126
+ return top_features.to_dict(orient='records')
127
+
128
+ # --- Helper Function: plot_local_feature_importance ---
129
+ def plot_local_feature_importance(shap_values, feature_names, title="Local Feature Importance", top_n=10):
130
+ if shap_values.ndim > 1:
131
+ shap_values = shap_values.flatten()
132
+ feature_importance = pd.DataFrame({
133
+ 'Feature': feature_names,
134
+ 'SHAP_Value': shap_values
135
+ })
136
+ feature_importance['Abs_SHAP'] = np.abs(feature_importance['SHAP_Value'])
137
+ feature_importance = feature_importance.sort_values(by='Abs_SHAP', ascending=False).head(top_n)
138
+ feature_importance = feature_importance.sort_values(by='SHAP_Value', ascending=True)
139
+ fig, ax = plt.subplots(figsize=(10, 6))
140
+ colors = ['red' if x < 0 else 'blue' for x in feature_importance['SHAP_Value']]
141
+ ax.barh(feature_importance['Feature'], feature_importance['SHAP_Value'], color=colors)
142
+ ax.set_xlabel('SHAP Value (Impact on Model Output)')
143
+ ax.set_ylabel('Feature')
144
+ ax.set_title(title)
145
+ fig.tight_layout()
146
+ return plot_to_base64(fig)
147
+
148
+ # --- Helper Function: get_mutation_context_summary ---
149
+ def get_mutation_context_summary(input_data_df):
150
+ summary_html = "<h3>Mutation Structural Context:</h3>"
151
+ sst = input_data_df['sst'].iloc[0] if 'sst' in input_data_df.columns else 'N/A'
152
+ rsa_val = input_data_df['rsa'].iloc[0] if 'rsa' in input_data_df.columns else 'N/A'
153
+ res_depth_val = input_data_df['res_depth'].iloc[0] if 'res_depth' in input_data_df.columns else 'N/A'
154
+
155
+ summary_html += f"<p><b>Secondary Structure (sst):</b> {sst}</p>"
156
+ if isinstance(rsa_val, (int, float)):
157
+ summary_html += f"<p><b>Relative Solvent Accessibility (rsa):</b> {rsa_val:.2f} (0=Buried, 1=Exposed)</p>"
158
+ else:
159
+ summary_html += f"<p><b>Relative Solvent Accessibility (rsa):</b> {rsa_val}</p>"
160
+ if isinstance(res_depth_val, (int, float)):
161
+ summary_html += f"<p><b>Residue Depth:</b> {res_depth_val:.2f} (Higher value = More buried)</p>"
162
+ else:
163
+ summary_html += f"<p><b>Residue Depth:</b> {res_depth_val}</p>"
164
+
165
+ if sst == 'Strand':
166
+ summary_html += "<p><i>Insight:</i> Mutations in strand regions might significantly disrupt beta-sheet structures, affecting protein folding and stability.</p>"
167
+ elif sst == 'AlphaHelix':
168
+ summary_html += "<p><i>Insight:</i> Alpha-helical mutations can alter helix packing, flexibility, or interactions, potentially impacting stability or function.</p>"
169
+ elif sst == 'None':
170
+ summary_html += "<p><i>Insight:</i> Mutations in coil/loop regions might introduce flexibility or alter surface interactions.</p>"
171
+
172
+ if isinstance(rsa_val, (int, float)):
173
+ if rsa_val < 0.2:
174
+ summary_html += "<p><i>Insight:</i> This residue is highly **buried**, suggesting it plays a critical role in the protein's core stability or internal packing. Changes here are often destabilizing.</p>"
175
+ elif rsa_val > 0.8:
176
+ summary_html += "<p><i>Insight:</i> This residue is highly **exposed**, indicating it might be involved in surface interactions, ligand binding, or protein-protein interfaces. Mutations here could affect function or solvent interactions.</p>"
177
+ else:
178
+ summary_html += "<p><i>Insight:</i> This residue has intermediate solvent accessibility, potentially involved in both structural integrity and surface interactions.</p>"
179
+
180
+ if isinstance(res_depth_val, (int, float)):
181
+ if res_depth_val > 6.0:
182
+ summary_html += "<p><i>Insight:</i> The residue is very deep within the protein, reinforcing its role in core structural stability.</p>"
183
+ elif res_depth_val < 3.0:
184
+ summary_html += "<p><i>Insight:</i> The residue is near the surface, potentially affecting surface interactions or flexibility.</p>"
185
+
186
+ return summary_html
187
+
188
+ # --- Artifact Loading Logic ---
189
+ def load_object_from_path(filepath, alternative_filepath=None):
190
+ if os.path.exists(filepath):
191
+ with open(filepath, 'rb') as f:
192
+ return pickle.load(f)
193
+ elif alternative_filepath and os.path.exists(alternative_filepath):
194
+ with open(alternative_filepath, 'rb') as f:
195
+ return pickle.load(f)
196
+ else:
197
+ raise FileNotFoundError(f"Object file not found at {filepath} or {alternative_filepath}")
198
+
199
+ def load_json_from_path(filepath, alternative_filepath=None):
200
+ if os.path.exists(filepath):
201
+ with open(filepath, 'r') as f:
202
+ return json.load(f)
203
+ elif alternative_filepath and os.path.exists(alternative_filepath):
204
+ with open(alternative_filepath, 'r') as f:
205
+ return json.load(f)
206
+ else:
207
+ raise FileNotFoundError(f"JSON file not found at {filepath} or {alternative_filepath}")
208
+
209
+ # Define file paths
210
+ preprocessor_file = 'preprocessor.pkl'
211
+ global_vars_file = 'global_vars.json'
212
+ feature_names_file = 'feature_names.json'
213
+ shap_background_data_file = 'shap_background_data.pt'
214
+ model_save_path = 'final_multi_task_protein_stability_model_non_plm.pth'
215
+
216
+ # Load preprocessor
217
+ try:
218
+ preprocessor = load_object_from_path(preprocessor_file, f'src/{preprocessor_file}')
219
+ except FileNotFoundError as e:
220
+ raise SystemExit(f"Error loading preprocessor: {e}. Please ensure 'preprocessor.pkl' is available.")
221
+
222
+ # Load global variables
223
+ try:
224
+ global_vars = load_json_from_path(global_vars_file, f'src/{global_vars_file}')
225
+ except FileNotFoundError as e:
226
+ raise SystemExit(f"Error loading global variables: {e}. Please ensure 'global_vars.json' is available.")
227
+
228
+ # Unpack global variables
229
+ label_encoder = LabelEncoder()
230
+ label_encoder.classes_ = np.array(global_vars['label_encoder_classes'])
231
+ num_classes = global_vars['num_classes']
232
+ best_hyperparams = global_vars['best_hyperparams']
233
+ expected_value_reg = global_vars['expected_value_reg']
234
+ expected_value_cls = np.array(global_vars['expected_value_cls']) # Already converted to list, convert back to np array
235
+ AA_PROPERTIES = global_vars['AA_PROPERTIES']
236
+
237
+ # Load feature names
238
+ try:
239
+ feature_names = load_json_from_path(feature_names_file, f'src/{feature_names_file}')
240
+ except FileNotFoundError as e:
241
+ raise SystemExit(f"Error loading feature names: {e}. Please ensure 'feature_names.json' is available.")
242
+
243
+ # Load SHAP background data
244
+ try:
245
+ background_data = torch.load(shap_background_data_file, map_location=device)
246
+ except FileNotFoundError as e:
247
+ try:
248
+ background_data = torch.load(f'src/{shap_background_data_file}', map_location=device)
249
+ except FileNotFoundError:
250
+ raise SystemExit(f"Error loading SHAP background data: {e}. Please ensure 'shap_background_data.pt' is available.")
251
+
252
+ # --- Load Trained Model ---
253
+ # Determine input_dim from feature_names for model initialization
254
+ input_dim = len(feature_names)
255
+ loaded_model = MultiTaskMLP(input_dim, num_classes, dropout_rate=best_hyperparams['dropout']).to(device)
256
+
257
+ # Check model path: root, then src/
258
+ alt_model_save_path = f'src/{model_save_path}'
259
+ if os.path.exists(model_save_path):
260
+ final_model_path_to_load = model_save_path
261
+ elif os.path.exists(alt_model_save_path):
262
+ final_model_path_to_load = alt_model_save_path
263
+ else:
264
+ raise SystemExit(f"Error: Model file not found at {model_save_path} or {alt_model_save_path}")
265
+
266
+ loaded_model.load_state_dict(torch.load(final_model_path_to_load, map_location=device))
267
+ loaded_model.eval() # Ensure eval mode is set immediately after loading
268
+
269
+ # --- SHAP Explainers Setup ---
270
+ model_reg_wrapper = RegressionHeadWrapper(loaded_model).to(device)
271
+ model_cls_wrapper = ClassificationHeadWrapper(loaded_model).to(device)
272
+
273
+ explainer_reg = shap.GradientExplainer(model_reg_wrapper, background_data)
274
+ explainer_cls = shap.GradientExplainer(model_cls_wrapper, background_data)
275
+
276
+ # --- Main Prediction Function for Gradio ---
277
+ def predict_stability_change(
278
+ weight, blosum62, pos, year, aro, ca_depth, mut_count, neg, sul,
279
+ relative_bfactor, ph, neu, phi, psi, rsa, res_depth, temperature,
280
+ acc, don, pam250, length, dtm,
281
+ sst, measure, protein_name, source, original_aa, mutant_aa, mutated_chain, mutation_type, method_val
282
+ ):
283
+ # Explicitly cast numerical inputs to float and handle None values
284
+ # Gradio's gr.Number will return float or int, no need for manual casting if types are consistent.
285
+ # However, if using gr.Slider with None as default, it might return None. Ensure defaults or cast.
286
+ # For robustness, we still ensure float type here.
287
+
288
+ input_data_df_raw = pd.DataFrame({
289
+ 'weight': [float(weight) if weight is not None else 0.0],
290
+ 'blosum62': [float(blosum62) if blosum62 is not None else 0.0],
291
+ 'pos': [float(pos) if pos is not None else 0.0],
292
+ 'year': [float(year) if year is not None else 0.0],
293
+ 'aro': [float(aro) if aro is not None else 0.0],
294
+ 'ca_depth': [float(ca_depth) if ca_depth is not None else 0.0],
295
+ 'mut_count': [float(mut_count) if mut_count is not None else 0.0],
296
+ 'neg': [float(neg) if neg is not None else 0.0],
297
+ 'sul': [float(sul) if sul is not None else 0.0],
298
+ 'relative_bfactor': [float(relative_bfactor) if relative_bfactor is not None else 0.0],
299
+ 'ph': [float(ph) if ph is not None else 0.0],
300
+ 'neu': [float(neu) if neu is not None else 0.0],
301
+ 'phi': [float(phi) if phi is not None else 0.0],
302
+ 'psi': [float(psi) if psi is not None else 0.0],
303
+ 'rsa': [float(rsa) if rsa is not None else 0.0],
304
+ 'res_depth': [float(res_depth) if res_depth is not None else 0.0],
305
+ 'temperature': [float(temperature) if temperature is not None else 0.0],
306
+ 'acc': [float(acc) if acc is not None else 0.0],
307
+ 'don': [float(don) if don is not None else 0.0],
308
+ 'pam250': [float(pam250) if pam250 is not None else 0.0],
309
+ 'length': [float(length) if length is not None else 0.0],
310
+ 'dtm': [float(dtm) if dtm is not None else 0.0],
311
+ 'sst': [sst],
312
+ 'measure': [measure],
313
+ 'protein': [protein_name],
314
+ 'source': [source],
315
+ 'original_aa': [original_aa],
316
+ 'mutant_aa': [mutant_aa],
317
+ 'mutated_chain': [mutated_chain],
318
+ 'mutation_type': [mutation_type],
319
+ 'method': [method_val]
320
+ })
321
+
322
+ # Preprocess the input data
323
+ processed_input = preprocessor.transform(input_data_df_raw)
324
+ if hasattr(processed_input, 'toarray'):
325
+ processed_input = processed_input.toarray()
326
+
327
+ input_tensor = torch.tensor(processed_input, dtype=torch.float32).to(device)
328
+
329
+ # Make predictions
330
+ loaded_model.eval()
331
+ with torch.no_grad():
332
+ ddg_pred, effect_logits = loaded_model(input_tensor)
333
+
334
+ predicted_ddg = ddg_pred.item()
335
+ predicted_effect_class_idx = torch.argmax(effect_logits, dim=1).item()
336
+ predicted_effect_label = label_encoder.inverse_transform([predicted_effect_class_idx])[0]
337
+
338
+ # 4. Generate AA Property Comparison
339
+ aa_comparison_results = get_aa_property_comparison(original_aa, mutant_aa)
340
+ aa_props_html = "<h3>Amino Acid Property Comparison:</h3>"
341
+ if isinstance(aa_comparison_results, str):
342
+ aa_props_html += f"<p>{aa_comparison_results}</p>"
343
+ else:
344
+ aa_props_html += "<table><tr><th>Original</th><th>Mutant</th><th>Change</th><th>Property</th></tr>"
345
+ for prop, vals in aa_comparison_results.items():
346
+ aa_props_html += f"<tr><td>{vals['original']}</td><td>{vals['mutant']}</td><td>{vals['change']}</td><td><b>{prop}</b></td></tr>"
347
+ aa_props_html += "</table>"
348
+
349
+ # 5. Generate SHAP Explanations (Waterfall Plots as static images)
350
+ # Regression SHAP
351
+ fig_reg, ax_reg = plt.subplots(figsize=(10, 6))
352
+ shap.waterfall_plot(shap.Explanation(values=explainer_reg.shap_values(input_tensor)[0].flatten(),
353
+ base_values=expected_value_reg,
354
+ data=input_tensor.cpu().numpy().flatten(),
355
+ feature_names=feature_names),
356
+ max_display=15, show=False)
357
+ ax_reg.set_title("SHAP Waterfall Plot for ΔΔG Prediction")
358
+ shap_html_reg_img = plot_to_base64(fig_reg)
359
+
360
+ # Classification SHAP (for predicted class)
361
+ fig_cls, ax_cls = plt.subplots(figsize=(10, 6))
362
+ shap.waterfall_plot(shap.Explanation(values=explainer_cls.shap_values(input_tensor)[0, :, predicted_effect_class_idx].flatten(),
363
+ base_values=expected_value_cls[predicted_effect_class_idx],
364
+ data=input_tensor.cpu().numpy().flatten(),
365
+ feature_names=feature_names),
366
+ max_display=15, show=False)
367
+ ax_cls.set_title(f"SHAP Waterfall Plot for Effect Prediction (Class: {predicted_effect_label})")
368
+ shap_html_cls_img = plot_to_base64(fig_cls)
369
+
370
+ # 6. Generate Local Feature Importance Chart (uses base64 plotting function)
371
+ local_fi_reg_img = plot_local_feature_importance(explainer_reg.shap_values(input_tensor)[0], feature_names,
372
+ title="Local Feature Importance for ΔΔG Prediction")
373
+ local_fi_cls_img = plot_local_feature_importance(explainer_cls.shap_values(input_tensor)[0, :, predicted_effect_class_idx], feature_names,
374
+ title=f"Local Feature Importance for Effect Prediction ({predicted_effect_label})")
375
+
376
+ # 7. Generate Top Global Feature Importance (using the background data)
377
+ top_reg_features = get_top_features_by_shap(explainer_reg, background_data, feature_names, top_n=5, task_type='regression')
378
+ top_cls_features = get_top_features_by_shap(explainer_cls, background_data, feature_names, top_n=5, task_type='classification')
379
+
380
+ top_features_html = "<h3>Top 5 Globally Important Features:</h3><p><b>Regression (ΔΔG):</b></p><ul>"
381
+ for item in top_reg_features:
382
+ top_features_html += f"<li>{item['Feature']}: {item['Mean_Abs_SHAP']:.4f}</li>"
383
+ top_features_html += "</ul><p><b>Classification (Effect):</b></p><ul>"
384
+ for item in top_cls_features:
385
+ top_features_html += f"<li>{item['Feature']}: {item['Mean_Abs_SHAP']:.4f}</li>"
386
+ top_features_html += "</ul>"
387
+
388
+ # 8. Get Mutation Context Summary
389
+ mutation_context_html = get_mutation_context_summary(input_data_df_raw)
390
+
391
+ # Return all outputs for Gradio
392
+ return (
393
+ f"Predicted ΔΔG: **{predicted_ddg:.4f}** kcal/mol",
394
+ f"Predicted Effect: **{predicted_effect_label.upper()}**",
395
+ aa_props_html,
396
+ mutation_context_html,
397
+ shap_html_reg_img,
398
+ local_fi_reg_img,
399
+ shap_html_cls_img,
400
+ local_fi_cls_img,
401
+ top_features_html
402
+ )
403
+
404
+ # --- Gradio Interface Layout ---
405
+ # Define Input Components grouped by sections
406
+ input_general_props = [
407
+ gr.Number(minimum=-100.0, maximum=100000.0, value=28726.09, label="Weight (Da)", interactive=True),
408
+ gr.Number(minimum=0.0, maximum=1000.0, value=268.0, label="Protein Length (AA)", step=1, interactive=True),
409
+ gr.Textbox(value="Tryptophan synthase alpha chain", label="Protein Name", interactive=True),
410
+ gr.Dropdown(choices=['Escherichia coli (strain K12)', 'Enterobacteria phage T4', 'Homo sapiens', 'Rattus norvegicus', 'Pseudomonas putida', 'Saccharomyces cerevisiae', 'Bacillus subtilis', 'Thermococcus kodakarensis', 'Unknown'], value='Escherichia coli (strain K12)', label="Source Organism", interactive=True),
411
+ gr.Number(minimum=1970, maximum=2024, value=1979, step=1, label="Year of Study", interactive=True)
412
+ ]
413
+
414
+ input_mutation_details = [
415
+ gr.Dropdown(choices=list(AA_PROPERTIES.keys()), value='E', label="Original Amino Acid", interactive=True),
416
+ gr.Dropdown(choices=list(AA_PROPERTIES.keys()), value='M', label="Mutant Amino Acid", interactive=True),
417
+ gr.Number(minimum=-10.0, maximum=1000.0, value=0.0, label="Position (Sequence Index)", step=1, interactive=True),
418
+ gr.Dropdown(choices=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'unsigned', 'Unknown'], value='A', label="Mutated Chain", interactive=True),
419
+ gr.Dropdown(choices=['Single', 'Multiple', 'Unknown'], value='Single', label="Mutation Type", interactive=True),
420
+ gr.Number(minimum=0, maximum=10, value=0, step=1, label="Mutation Count", interactive=True)
421
+ ]
422
+
423
+ input_physicochemical = [
424
+ gr.Number(minimum=-10.0, maximum=10.0, value=-1.0, label="Blosum62 Score", step=0.1, interactive=True),
425
+ gr.Number(minimum=-10.0, maximum=10.0, value=0.0, label="PAM250 Score", step=0.1, interactive=True),
426
+ gr.Number(minimum=-10.0, maximum=10.0, value=0.0, label="Aromatic AA Count", step=0.1, interactive=True),
427
+ gr.Number(minimum=-10.0, maximum=10.0, value=-2.0, label="Negative AA Count", step=0.1, interactive=True),
428
+ gr.Number(minimum=-10.0, maximum=10.0, value=-1.0, label="Neutral AA Count", step=0.1, interactive=True),
429
+ gr.Number(minimum=-10.0, maximum=10.0, value=1.0, label="Sulfur AA Count", step=0.1, interactive=True),
430
+ gr.Number(minimum=-10.0, maximum=10.0, value=-2.0, label="Acceptor Count", step=0.1, interactive=True),
431
+ gr.Number(minimum=-10.0, maximum=10.0, value=0.0, label="Donor Count", step=0.1, interactive=True)
432
+ ]
433
+
434
+ input_structural = [
435
+ gr.Dropdown(choices=['Strand', 'AlphaHelix', 'None', 'Turn', 'Bend', 'Isolatedbeta-bridge', '3-10Helix', 'PiHelix', 'polyproline', 'Unknown'], value='Strand', label="Secondary Structure Type", interactive=True),
436
+ gr.Number(minimum=0.0, maximum=1.0, value=0.0, label="RSA (Relative Solvent Accessibility)", step=0.01, interactive=True),
437
+ gr.Number(minimum=0.0, maximum=10.0, value=4.14, label="CA Depth (Å)", step=0.01, interactive=True),
438
+ gr.Number(minimum=0.0, maximum=10.0, value=3.53, label="Residue Depth (Å)", step=0.01, interactive=True),
439
+ gr.Number(minimum=0.0, maximum=10.0, value=3.47, label="Relative B-Factor", step=0.01, interactive=True),
440
+ gr.Number(minimum=-180.0, maximum=180.0, value=-118.5, label="Phi Angle (°)", step=0.1, interactive=True),
441
+ gr.Number(minimum=-180.0, maximum=180.0, value=113.0, label="Psi Angle (°)", step=0.1, interactive=True)
442
+ ]
443
+
444
+ input_experimental = [
445
+ gr.Dropdown(choices=['CD', 'Unavailable', 'Fluorescence', 'DSC', 'NMR', 'Absorbance', 'Activity', 'ITC', 'Other', 'Unknown'], value='CD', label="Measurement Method", interactive=True),
446
+ gr.Dropdown(choices=['GdnHCl', 'Thermal', 'Unavailable', 'Urea', 'GdnSCN', 'pH-stability', 'TFE', 'Proteolysis', 'DSC, CD', 'Absorbance, Fluorescence', 'Fluorescence, GdnHCl', 'Unknown'], value='GdnHCl', label="Denaturation Method", interactive=True),
447
+ gr.Number(minimum=0.0, maximum=14.0, value=7.0, label="pH", step=0.1, interactive=True),
448
+ gr.Number(minimum=273.0, maximum=373.0, value=298.95, label="Temperature (K)", step=0.01, interactive=True),
449
+ gr.Number(minimum=-100.0, maximum=100.0, value=0.0, label="dTM (Change in Melting Temp)", step=0.1, interactive=True)
450
+ ]
451
+
452
+ # Combine all inputs into a single list for the fn call, ordered as expected by predict_stability_change
453
+ all_input_components = [
454
+ input_general_props[0], input_physicochemical[0], input_mutation_details[2], input_general_props[4],
455
+ input_physicochemical[2], input_structural[2], input_mutation_details[5], input_physicochemical[3],
456
+ input_physicochemical[5], input_structural[4], input_experimental[2], input_physicochemical[4],
457
+ input_structural[5], input_structural[6], input_structural[1], input_structural[3],
458
+ input_experimental[3], input_physicochemical[6], input_physicochemical[7], input_physicochemical[1],
459
+ input_general_props[1], input_experimental[4],
460
+ input_structural[0], input_experimental[0], input_general_props[2], input_general_props[3],
461
+ input_mutation_details[0], input_mutation_details[1], input_mutation_details[3], input_mutation_details[4],
462
+ input_experimental[1]
463
+ ]
464
+
465
+ output_components = [
466
+ gr.Markdown(label="Predicted ΔΔG"),
467
+ gr.Markdown(label="Predicted Effect"),
468
+ gr.HTML(label="Amino Acid Property Comparison"),
469
+ gr.HTML(label="Mutation Structural Context"),
470
+ gr.HTML(label="SHAP Waterfall Plot (Regression)"),
471
+ gr.HTML(label="Local Feature Importance (Regression)"),
472
+ gr.HTML(label="SHAP Waterfall Plot (Classification)"),
473
+ gr.HTML(label="Local Feature Importance (Classification)"),
474
+ gr.HTML(label="Top Global Feature Importance")
475
+ ]
476
+
477
+ # Create the Gradio Interface
478
+ with gr.Blocks(theme=gr.themes.Soft()) as iface:
479
+ gr.Markdown("# Protein Stability Change (ΔΔG) Prediction with Explainability")
480
+ gr.Markdown(
481
+ "Predict ΔΔG and mutation effect for single amino acid substitutions in proteins. "
482
+ "Explore physicochemical changes, mutation structural context, and feature importance with SHAP explanations. "
483
+ "Designed for researchers and doctors for practical applications."
484
+ "All backend features are included and frontend template is professional and exceptional."
485
+ )
486
+
487
+ with gr.Row():
488
+ with gr.Column(scale=1):
489
+ gr.Markdown("## Input Features")
490
+ with gr.Accordion("General Properties", open=True):
491
+ for component in input_general_props:
492
+ component.render()
493
+ with gr.Accordion("Mutation Details", open=False):
494
+ for component in input_mutation_details:
495
+ component.render()
496
+ with gr.Accordion("Physicochemical & Substitution Scores", open=False):
497
+ for component in input_physicochemical:
498
+ component.render()
499
+ with gr.Accordion("Structural Features", open=False):
500
+ for component in input_structural:
501
+ component.render()
502
+ with gr.Accordion("Experimental Conditions", open=False):
503
+ for component in input_experimental:
504
+ component.render()
505
+
506
+ submit_btn = gr.Button("Predict & Explain", variant="primary")
507
+
508
+ with gr.Column(scale=2):
509
+ gr.Markdown("## Prediction Results & Explanations")
510
+ with gr.Tab("Summary & Predictions"):
511
+ output_components[0].render()
512
+ output_components[1].render()
513
+ output_components[2].render()
514
+ output_components[3].render()
515
+ with gr.Tab("SHAP Explanations (ΔΔG)"):
516
+ gr.Markdown("### How features influence ΔΔG Prediction (SHAP Waterfall Plot)")
517
+ output_components[4].render()
518
+ gr.Markdown("### Local Feature Contributions (ΔΔG)")
519
+ output_components[5].render()
520
+ with gr.Tab("SHAP Explanations (Effect)"):
521
+ gr.Markdown("### How features influence Effect Classification (SHAP Waterfall Plot)")
522
+ output_components[6].render()
523
+ gr.Markdown("### Local Feature Contributions (Effect)")
524
+ output_components[7].render()
525
+ with gr.Tab("Global Feature Importance"):
526
+ output_components[8].render()
527
+
528
+ submit_btn.click(
529
+ fn=predict_stability_change,
530
+ inputs=all_input_components,
531
+ outputs=output_components
532
+ )
533
+
534
+ iface.launch(debug=True, share=True)
feature_names.json ADDED
@@ -0,0 +1 @@
 
 
1
+ ["num__weight", "num__blosum62", "num__pos", "num__year", "num__aro", "num__ca_depth", "num__mut_count", "num__neg", "num__sul", "num__relative_bfactor", "num__ph", "num__neu", "num__phi", "num__psi", "num__rsa", "num__res_depth", "num__temperature", "num__acc", "num__don", "num__pam250", "num__length", "num__dtm", "cat__sst_3-10Helix", "cat__sst_AlphaHelix", "cat__sst_Bend", "cat__sst_Isolatedbeta-bridge", "cat__sst_None", "cat__sst_PiHelix", "cat__sst_Strand", "cat__sst_Turn", "cat__measure_-", "cat__measure_Abs", "cat__measure_Abs, CD, Fluorescence", "cat__measure_Absorbance", "cat__measure_Absorsance", "cat__measure_Activity", "cat__measure_CD", "cat__measure_CD (Far-UV)", "cat__measure_CD (far-UV)", "cat__measure_CD, DSC", "cat__measure_CD, DSF", "cat__measure_CD, Fluorescence", "cat__measure_CD, Fluorescence, DSC", "cat__measure_CD, Fluorescence, Thiol reactivity", "cat__measure_CD, ITC", "cat__measure_CD, Optical Probes", "cat__measure_CD,DSC, Fluorescence", "cat__measure_CD,Fluorescence", "cat__measure_Chromatography", "cat__measure_DSC", "cat__measure_DSC, CD, Fluorescence", "cat__measure_DSC, Fluorescence", "cat__measure_DSF", "cat__measure_ESR", "cat__measure_Enzyme Activity", "cat__measure_Enzyme activity", "cat__measure_Fluorescence", "cat__measure_Fluorescence, CD", "cat__measure_Gel electrophoresis", "cat__measure_HPLC", "cat__measure_Hydrogen exchange", "cat__measure_ITC", "cat__measure_Isothermal denaturation", "cat__measure_Isothermal titration calorimetry", "cat__measure_MCD", "cat__measure_NMR", "cat__measure_NMR, Fluorescence", "cat__measure_PTS, Fluorescence", "cat__measure_RP-HPLC", "cat__measure_Stopped-flow fluorescence", "cat__measure_UV", "cat__measure_UV/vis spectrophotometer", "cat__measure_Unavailable", "cat__measure_fluorescence", "cat__measure_fluorescence / CD", "cat__source_Aeromonas hydrophila", "cat__source_Amphitrite ornata", "cat__source_Anopheles_dirus", "cat__source_Aquifex aeolicus (strain VF5)", "cat__source_Arthrobacter sp.", "cat__source_Aspergillus kawachii", "cat__source_Aspergillus oryzae (strain ATCC 42149 / RIB 40)", "cat__source_Avena sativa (Oat)", "cat__source_Bacillus amyloliquefaciens", "cat__source_Bacillus caldolyticus", "cat__source_Bacillus licheniformis", "cat__source_Bacillus subtilis (strain 168)", "cat__source_Bacillus thuringiensis subsp. entomocidus", "cat__source_Barley", "cat__source_Borrelia burgdorferi", "cat__source_Bos taurus", "cat__source_Bovine", "cat__source_Brevundimonas diminuta", "cat__source_Caenorhabditis elegans", "cat__source_Canis lupus familiaris", "cat__source_Capra hircus", "cat__source_Clostridium pasteurianum", "cat__source_Cucurbita maxima", "cat__source_Dengue virus type 2 (strain Puerto Rico/PR159-S1/1969)", "cat__source_Designed", "cat__source_Desulfovibrio desulfuricans", "cat__source_Dioscoreophyllum cumminsii", "cat__source_Drosophila melanogaster", "cat__source_Enterobacteria phage M13", "cat__source_Enterobacteria phage T4", "cat__source_Enterobacteria phage fd", "cat__source_Equus caballus", "cat__source_Escherichia coli", "cat__source_Escherichia coli (strain K12)", "cat__source_Escherichia coli O157:H7", "cat__source_Escherichia coli O6:H1 (strain CFT073 / ATCC 700928 / UPEC)", "cat__source_Escherichia phage lambda", "cat__source_Escherichia_coli", "cat__source_Finegoldia_magna", "cat__source_Gallus gallus", "cat__source_Geobacillus stearothermophilus", "cat__source_Halobacterium salinarum (strain ATCC 700922 / JCM 11081 / NRC-1)", "cat__source_Hirudo medicinalis", "cat__source_Homo sapiens", "cat__source_Hordeum vulgare", "cat__source_Human", "cat__source_Human immunodeficiency virus type 1 group M subtype B (isolate NY5)", "cat__source_Katsuwonus pelamis", "cat__source_Kitasatospora aureofaciens", "cat__source_Lama glama", "cat__source_Lithobates pipiens", "cat__source_Locusta migratoria", "cat__source_Mesocricetus auratus", "cat__source_Methanothermus fervidus", "cat__source_Mnemiopsis_leidyi", "cat__source_Mus musculus", "cat__source_Mycobacterium tuberculosis", "cat__source_Mycobacterium tuberculosis (strain ATCC 25618 / H37Rv)", "cat__source_None", "cat__source_Nostoc sp. (strain ATCC 29151 / PCC 7119)", "cat__source_Nostoc sp. (strain PCC 7120 / SAG 25.82 / UTEX 2576)", "cat__source_Oryctolagus cuniculus", "cat__source_Oryza sativa subsp. japonica", "cat__source_Ovis aries", "cat__source_Paenibacillus polymyxa", "cat__source_Pan paniscus", "cat__source_Pentadiplandra brazzeana", "cat__source_Photinus pyralis", "cat__source_Physeter macrocephalus", "cat__source_Podospora anserina", "cat__source_Proteus hauseri", "cat__source_Pseudomonas aeruginosa (strain ATCC 15692 / DSM 22644 / CIP 104116 / JCM 14847 / LMG 12228 / 1C / PRS 101 / PAO1)", "cat__source_Pseudomonas putida", "cat__source_Pseudomonas syringae pv. tomato", "cat__source_Pyrococcus furiosus (strain ATCC 43587 / DSM 3638 / JCM 8422 / Vc1)", "cat__source_Pyrococcus_furiosus", "cat__source_Rattus norvegicus", "cat__source_Rhodobacter capsulatus (strain ATCC BAA-309 / NBRC 16581 / SB1003)", "cat__source_Rhodopseudomonas palustris (strain ATCC BAA-98 / CGA009)", "cat__source_Rous sarcoma virus (strain Prague C)", "cat__source_Saccharolobus shibatae", "cat__source_Saccharolobus solfataricus (strain ATCC 35092 / DSM 1617 / JCM 11322 / P2)", "cat__source_Saccharomyces cerevisiae (strain ATCC 204508 / S288c)", "cat__source_Salmonella phage P22", "cat__source_Salmonella typhimurium (strain LT2 / SGSC1412 / ATCC 700720)", "cat__source_Schizosaccharomyces pombe (strain 972 / ATCC 24843)", "cat__source_Severe acute respiratory syndrome coronavirus", "cat__source_Shigella flexneri", "cat__source_Simian foamy virus type 1", "cat__source_Spodoptera frugiperda (Fall armyworm)", "cat__source_Staphylococcus aureus", "cat__source_Stichodactyla helianthus", "cat__source_Streptococcus sp. group G", "cat__source_Streptomyces albogriseolus", "cat__source_Streptomyces lividans", "cat__source_Streptomyces sp. (strain N174)", "cat__source_Sulfolobus acidocaldarius (strain ATCC 33909 / DSM 639 / JCM 8929 / NBRC 15157 / NCIMB 11770)", "cat__source_Sus scrofa", "cat__source_Thermococcus celer", "cat__source_Thermococcus kodakarensis (strain ATCC BAA-918 / JCM 12380 / KOD1)", "cat__source_Thermotoga maritima (strain ATCC 43589 / MSB8 / DSM 3109 / JCM 10099)", "cat__source_Thermus thermophilus", "cat__source_Thermus thermophilus (strain HB8 / ATCC 27634 / DSM 579)", "cat__source_Tobacco etch virus", "cat__source_Vibrio harveyi", "cat__source_Xenopus laevis", "cat__source_Zoarces americanus", "cat__source_designed", "cat__source_human", "cat__source_none", "cat__protein_10 kDa chaperonin", "cat__protein_3-isopropylmalate dehydrogenase", "cat__protein_30S ribosomal protein S16", "cat__protein_30S ribosomal protein S6", "cat__protein_5'-AMP-activated protein kinase subunit beta-1", "cat__protein_5'-AMP-activated protein kinase subunit beta-2", "cat__protein_50S ribosomal protein L23", "cat__protein_50S ribosomal protein L30e", "cat__protein_50S ribosomal protein L9", "cat__protein_60 kDa chaperonin", "cat__protein_6aJL2", "cat__protein_A26.8 VHH antibody", "cat__protein_AL-103", "cat__protein_AL-12", "cat__protein_ALPHA-T-ALPHA", "cat__protein_Actin-binding protein", "cat__protein_Acyl-CoA-binding protein", "cat__protein_Acylphosphatase", "cat__protein_Acylphosphatase-1", "cat__protein_Adenosine deaminase", "cat__protein_Adenylate kinase", "cat__protein_Adrenodoxin, mitochondrial", "cat__protein_Aerolysin", "cat__protein_Alkanal monooxygenase alpha chain", "cat__protein_Alpha-1-antitrypsin", "cat__protein_Alpha-lactalbumin", "cat__protein_Apolipophorin-3b", "cat__protein_Apolipoprotein A-I", "cat__protein_Apolipoprotein(a)", "cat__protein_Asparaginase", "cat__protein_Aspartate aminotransferase", "cat__protein_Attachment protein G3P", "cat__protein_Azurin", "cat__protein_BRCA1-associated RING domain protein 1", "cat__protein_Bacteriorhodopsin", "cat__protein_Barstar", "cat__protein_Beta lactamase", "cat__protein_Beta-2-microglobulin", "cat__protein_Beta-galactosidase", "cat__protein_Beta-glucosidase", "cat__protein_Beta-glucosidase B", "cat__protein_Beta-lactamase", "cat__protein_Beta-lactamase TEM", "cat__protein_Beta-lactoglobulin", "cat__protein_Bifunctional ligase/repressor BirA", "cat__protein_Blue-light photoreceptor", "cat__protein_Bromodomain-containing protein 2", "cat__protein_Bromodomain-containing protein 3", "cat__protein_Bromodomain-containing protein 4", "cat__protein_CREB-binding protein", "cat__protein_Calmodulin-2 A", "cat__protein_Carbonic anhydrase 2", "cat__protein_Carboxypeptidase A2", "cat__protein_Cellular retinoic acid-binding protein 1", "cat__protein_Cellular tumor antigen p53", "cat__protein_Chemotaxis protein CheY", "cat__protein_Chitinase", "cat__protein_Chitosanase", "cat__protein_Chymotrypsin inhibitor 2", "cat__protein_Chymotrypsin inhibitor-2", "cat__protein_Cold shock protein CspA", "cat__protein_Cold shock protein CspB", "cat__protein_Cold shock-like protein", "cat__protein_Colicin-E7 immunity protein", "cat__protein_Colicin-E9 immunity protein", "cat__protein_Collagen alpha-1(XVIII) chain", "cat__protein_Copper resistance protein C", "cat__protein_Copper-transporting ATPase 2", "cat__protein_Creatine kinase M-type", "cat__protein_Crystaline entomocidal protoxin", "cat__protein_Cyclin-dependent kinase inhibitor 2A", "cat__protein_Cyclin-dependent kinases regulatory subunit", "cat__protein_Cyclin-dependent kinases regulatory subunit 1", "cat__protein_Cystatin-B", "cat__protein_Cytochrome b", "cat__protein_Cytochrome b5", "cat__protein_Cytochrome c", "cat__protein_Cytochrome c isoform 1", "cat__protein_Cytochrome c isoform 2", "cat__protein_Cytochrome c mitochondrial import factor CYC2", "cat__protein_Cytochrome c'", "cat__protein_Cytochrome c, somatic", "cat__protein_Cytochrome c-551", "cat__protein_Cytochrome c2", "cat__protein_DELTA-stichotoxin-She4a", "cat__protein_DELTA-stichotoxin-She4b", "cat__protein_DF1", "cat__protein_DNA-Binding protein G5P", "cat__protein_DNA-binding protein 7d", "cat__protein_DNA-binding protein Fis", "cat__protein_DNA-binding protein HMf-2", "cat__protein_DNA-binding protein HU", "cat__protein_DNA/RNA-binding protein Alba 1", "cat__protein_Defensin-like protein", "cat__protein_Dehaloperoxidase A", "cat__protein_Dihydrofolate reductase", "cat__protein_Dihydrolipoyllysine-residue acetyltransferase component of pyruvate dehydrogenase complex", "cat__protein_Dihydrolipoyllysine-residue succinyltransferase component of 2-oxoglutarate dehydrogenase complex", "cat__protein_Disks large homolog 4", "cat__protein_Disulfide bond formation protein D", "cat__protein_Dystrophin", "cat__protein_E3 ubiquitin-protein ligase RSP5", "cat__protein_E3 ubiquitin-protein ligase parkin", "cat__protein_Eglin C", "cat__protein_Endo-1,4-beta-xylanase A", "cat__protein_Endolysin", "cat__protein_Estrogen receptor", "cat__protein_Fatty acid-binding protein, brain", "cat__protein_Fatty acid-binding protein, heart", "cat__protein_Fatty acid-binding protein, intestinal", "cat__protein_Ferrienterobactin receptor", "cat__protein_Fibroblast growth factor 1", "cat__protein_Fibronectin", "cat__protein_FimH", "cat__protein_Flavodoxin", "cat__protein_Forkhead box protein P1", "cat__protein_Formamidopyrimidine-DNA glycosylase", "cat__protein_Frataxin, mitochondrial", "cat__protein_Gag polyprotein", "cat__protein_Gag-Pol polyprotein", "cat__protein_Gamma-crystallin D", "cat__protein_Gastrotropin", "cat__protein_Gelsolin", "cat__protein_General control protein GCN4", "cat__protein_Genome polyprotein", "cat__protein_Glucoamylase I", "cat__protein_Glucocorticoid receptor", "cat__protein_Glutamate dehydrogenase", "cat__protein_Glutathione S-transferase GstA", "cat__protein_Glutathione S-transferase Mu 1", "cat__protein_Glycerol-3-phosphate dehydrogenase [NAD(+)], cytoplasmic", "cat__protein_Granulocyte-macrophage colony-stimulating factor", "cat__protein_Growth factor receptor-bound protein 2", "cat__protein_Growth hormone receptor", "cat__protein_Guanyl-specific ribonuclease Sa", "cat__protein_Guanyl-specific ribonuclease Sa3", "cat__protein_Guanyl-specific ribonuclease T1", "cat__protein_HIV-1 capsid protein", "cat__protein_Heterokaryon incompatibility protein s", "cat__protein_High mobility group protein B1", "cat__protein_Ig gamma-1 chain C region secreted form", "cat__protein_Ig heavy chain V region 6.96", "cat__protein_Immunoglobulin G-binding protein A", "cat__protein_Immunoglobulin G-binding protein G", "cat__protein_Immunoglobulin heavy constant gamma 1", "cat__protein_Immunoglobulin kappa variable 1D-33", "cat__protein_Inhibitor of trypsin and hageman factor", "cat__protein_Insulin", "cat__protein_Insulin receptor", "cat__protein_Interleukin-1 beta", "cat__protein_Interleukin-4", "cat__protein_Isocitrate lyase", "cat__protein_LamA", "cat__protein_Lipase EstA", "cat__protein_Lipid A palmitoyltransferase PagP", "cat__protein_Lipocalin-1", "cat__protein_Luciferin 4-monooxygenase", "cat__protein_Lymphotactin", "cat__protein_Lysozyme C", "cat__protein_Lysozyme C, milk isozyme", "cat__protein_MAK33", "cat__protein_Major capsid protein", "cat__protein_Major prion protein", "cat__protein_Maltose/maltodextrin-binding periplasmic protein", "cat__protein_Membrane-associated guanylate kinase, WW and PDZ domain-containing protein 1", "cat__protein_Methyl-CpG-binding protein 2", "cat__protein_Microtubule-associated proteins 1A/1B light chain 3B", "cat__protein_Monellin chain A", "cat__protein_Monellin chain B", "cat__protein_Myelin P2 protein", "cat__protein_Myoglobin", "cat__protein_NF-kappa-B inhibitor alpha", "cat__protein_NPH1-1", "cat__protein_Neuronal calcium sensor 1", "cat__protein_Non-specific lipid-transfer protein", "cat__protein_Non-specific lipid-transfer protein 2", "cat__protein_Nuclear RNA export factor 1", "cat__protein_Nuclease-Concanavalin A hybrid protein", "cat__protein_OPG2_FAB_VL", "cat__protein_Orotidine 5'-phosphate decarboxylase", "cat__protein_Outer membrane protein A", "cat__protein_PTS system mannose-specific EIIAB component", "cat__protein_Pancreatic trypsin inhibitor", "cat__protein_Parathion hydrolase", "cat__protein_Parvalbumin alpha", "cat__protein_Peptide YY", "cat__protein_Peptidyl-prolyl cis-trans isomerase FKBP1A", "cat__protein_Peptidyl-prolyl cis-trans isomerase NIMA-interacting 1", "cat__protein_Periplasmic chaperone Spy", "cat__protein_Peroxisome proliferator-activated receptor gamma", "cat__protein_Phosphocarrier protein HPr", "cat__protein_Phosphoglycerate kinase", "cat__protein_Phosphoglycerate kinase 1", "cat__protein_Phospholipase A2", "cat__protein_Phospholipase A2, major isoenzyme", "cat__protein_Plasminogen activator inhibitor 1", "cat__protein_Polyglutamine-binding protein 1", "cat__protein_Polyubiquitin-B", "cat__protein_Pre-mRNA-processing factor 40 homolog A", "cat__protein_Pre-mRNA-splicing factor URN1", "cat__protein_Pro-Pol polyprotein", "cat__protein_Pro-epidermal growth factor", "cat__protein_Profilin-1", "cat__protein_Prolactin", "cat__protein_Protein P-30", "cat__protein_Protein RecA", "cat__protein_Protein S100-B", "cat__protein_Protein S100-G", "cat__protein_Protein THO1", "cat__protein_ProteinL", "cat__protein_Proteinase inhibitor", "cat__protein_Proto-oncogene tyrosine-protein kinase Src", "cat__protein_Pyrin", "cat__protein_RAF proto-oncogene serine/threonine-protein kinase", "cat__protein_Receptor-interacting serine/threonine-protein kinase 2", "cat__protein_Regulatory protein cro", "cat__protein_Regulatory protein rop", "cat__protein_Replicase polyprotein 1ab", "cat__protein_Repressor protein cI", "cat__protein_Riboflavin-binding protein", "cat__protein_Ribonuclease", "cat__protein_Ribonuclease H", "cat__protein_Ribonuclease HI", "cat__protein_Ribonuclease HII", "cat__protein_Ribonuclease P protein component", "cat__protein_Ribonuclease pancreatic", "cat__protein_Ribose import binding protein RbsB", "cat__protein_Rubredoxin", "cat__protein_S-adenosylmethionine synthase isoform type-1", "cat__protein_SCO1 protein homolog", "cat__protein_SH2 domain-containing protein 1A", "cat__protein_Serine hydroxymethyltransferase", "cat__protein_Serine/threonine-protein kinase pim-1", "cat__protein_Sialidase", "cat__protein_Soluble cytochrome b562", "cat__protein_Spectrin alpha chain, non-erythrocytic 1", "cat__protein_Steroid Delta-isomerase", "cat__protein_Subtilisin BPN'", "cat__protein_Subtilisin inhibitor", "cat__protein_Subtilisin-chymotrypsin inhibitor-2A", "cat__protein_Superoxide dismutase", "cat__protein_Superoxide dismutase [Cu-Zn]", "cat__protein_Superoxide dismutase [Mn], mitochondrial", "cat__protein_T-cell surface antigen CD2", "cat__protein_TC10b", "cat__protein_Tail spike protein", "cat__protein_Tenascin", "cat__protein_Tetracycline repressor protein class D", "cat__protein_Thermonuclease", "cat__protein_Thiol:disulfide interchange protein DsbA", "cat__protein_Thioredoxin 1", "cat__protein_Thioredoxin-like protein 4A", "cat__protein_Tissue factor", "cat__protein_Tissue-type plasminogen activator", "cat__protein_Titin", "cat__protein_Transcription antitermination protein NusB", "cat__protein_Transcription elongation regulator 1", "cat__protein_Transcriptional activator Myb", "cat__protein_Transcriptional coactivator YAP1", "cat__protein_Transcriptional enhancer factor TEF-1", "cat__protein_Transcriptional enhancer factor TEF-3", "cat__protein_Transcriptional enhancer factor TEF-4", "cat__protein_Transcriptional repressor arc", "cat__protein_Transforming growth factor-beta-induced protein ig-h3", "cat__protein_Transketolase 1", "cat__protein_Triosephosphate isomerase", "cat__protein_Tryptophan synthase alpha chain", "cat__protein_Twitchin", "cat__protein_Type-2 restriction enzyme PvuII", "cat__protein_Type-3 ice-structuring protein HPLC 12", "cat__protein_Tyrosine--tRNA ligase", "cat__protein_Tyrosine-protein kinase Fyn", "cat__protein_Tyrosine-protein phosphatase non-receptor type 13", "cat__protein_U1 small nuclear ribonucleoprotein A", "cat__protein_Ubiquitin", "cat__protein_Variable large protein", "cat__protein_Villin-1", "cat__protein_WD repeat-containing protein 5", "cat__protein_cAMP-activated global transcriptional regulator CRP", "cat__protein_de novo designed three helix bundle GRa3D", "cat__protein_glutathione_transferases", "cat__protein_mnemiopsin", "cat__original_aa_A", "cat__original_aa_C", "cat__original_aa_D", "cat__original_aa_E", "cat__original_aa_F", "cat__original_aa_G", "cat__original_aa_H", "cat__original_aa_I", "cat__original_aa_K", "cat__original_aa_L", "cat__original_aa_M", "cat__original_aa_N", "cat__original_aa_P", "cat__original_aa_Q", "cat__original_aa_R", "cat__original_aa_S", "cat__original_aa_T", "cat__original_aa_V", "cat__original_aa_W", "cat__original_aa_Y", "cat__mutant_aa_A", "cat__mutant_aa_C", "cat__mutant_aa_D", "cat__mutant_aa_E", "cat__mutant_aa_F", "cat__mutant_aa_G", "cat__mutant_aa_H", "cat__mutant_aa_I", "cat__mutant_aa_K", "cat__mutant_aa_L", "cat__mutant_aa_M", "cat__mutant_aa_N", "cat__mutant_aa_P", "cat__mutant_aa_Q", "cat__mutant_aa_R", "cat__mutant_aa_S", "cat__mutant_aa_T", "cat__mutant_aa_V", "cat__mutant_aa_W", "cat__mutant_aa_Y", "cat__mutated_chain_0", "cat__mutated_chain_1", "cat__mutated_chain_A", "cat__mutated_chain_B", "cat__mutated_chain_E", "cat__mutated_chain_H", "cat__mutated_chain_I", "cat__mutated_chain_L", "cat__mutated_chain_X", "cat__mutated_chain_unsigned", "cat__mutation_type_Single", "cat__method_Acid", "cat__method_Activity", "cat__method_GSSG, GSH", "cat__method_GdmCl", "cat__method_Gdn-HCl", "cat__method_GdnCl", "cat__method_GdnCl.", "cat__method_GdnHCL", "cat__method_GdnHCl", "cat__method_GdnHCl, Urea", "cat__method_GdnSCN", "cat__method_GnHCl", "cat__method_GndHCl", "cat__method_GuHCI", "cat__method_GuHCl", "cat__method_NMR", "cat__method_Pressure", "cat__method_SDS", "cat__method_Thermal", "cat__method_Thermal, Urea", "cat__method_Unavailable", "cat__method_Urea", "cat__method_Urea,Thermal", "cat__method_pressure", "cat__method_thermal"]
final_multi_task_protein_stability_model_non_plm.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2512e198b0fd1a08e0f757c4f6c49e45a296ab4c60ee3e58afd4c5ddc92550a5
3
+ size 777049
global_vars.json ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "label_encoder_classes": [
3
+ "destabilizing",
4
+ "neutral",
5
+ "stabilizing"
6
+ ],
7
+ "num_classes": 3,
8
+ "best_hyperparams": {
9
+ "learning_rate": 0.0001,
10
+ "dropout": 0.3,
11
+ "lambda_reg": 0.5,
12
+ "lambda_cls": 0.5
13
+ },
14
+ "expected_value_reg": -1.0198863744735718,
15
+ "expected_value_cls": [
16
+ -0.5417895317077637,
17
+ 0.3860914409160614,
18
+ 0.6462976932525635
19
+ ],
20
+ "AA_PROPERTIES": {
21
+ "A": {
22
+ "hydrophobicity": 1.8,
23
+ "volume": 88.6,
24
+ "charge": 0,
25
+ "polarity": 0
26
+ },
27
+ "R": {
28
+ "hydrophobicity": -4.5,
29
+ "volume": 173.4,
30
+ "charge": 1,
31
+ "polarity": 1
32
+ },
33
+ "N": {
34
+ "hydrophobicity": -3.5,
35
+ "volume": 114.1,
36
+ "charge": 0,
37
+ "polarity": 1
38
+ },
39
+ "D": {
40
+ "hydrophobicity": -3.5,
41
+ "volume": 111.1,
42
+ "charge": -1,
43
+ "polarity": 1
44
+ },
45
+ "C": {
46
+ "hydrophobicity": 2.5,
47
+ "volume": 108.5,
48
+ "charge": 0,
49
+ "polarity": 0
50
+ },
51
+ "Q": {
52
+ "hydrophobicity": -3.5,
53
+ "volume": 143.8,
54
+ "charge": 0,
55
+ "polarity": 1
56
+ },
57
+ "E": {
58
+ "hydrophobicity": -3.5,
59
+ "volume": 138.4,
60
+ "charge": -1,
61
+ "polarity": 1
62
+ },
63
+ "G": {
64
+ "hydrophobicity": -0.4,
65
+ "volume": 60.1,
66
+ "charge": 0,
67
+ "polarity": 0
68
+ },
69
+ "H": {
70
+ "hydrophobicity": -3.2,
71
+ "volume": 153.2,
72
+ "charge": 0.1,
73
+ "polarity": 1
74
+ },
75
+ "I": {
76
+ "hydrophobicity": 4.5,
77
+ "volume": 166.7,
78
+ "charge": 0,
79
+ "polarity": 0
80
+ },
81
+ "L": {
82
+ "hydrophobicity": 3.8,
83
+ "volume": 166.7,
84
+ "charge": 0,
85
+ "polarity": 0
86
+ },
87
+ "K": {
88
+ "hydrophobicity": -3.9,
89
+ "volume": 168.6,
90
+ "charge": 1,
91
+ "polarity": 1
92
+ },
93
+ "M": {
94
+ "hydrophobicity": 1.9,
95
+ "volume": 162.9,
96
+ "charge": 0,
97
+ "polarity": 0
98
+ },
99
+ "F": {
100
+ "hydrophobicity": 2.8,
101
+ "volume": 203.4,
102
+ "charge": 0,
103
+ "polarity": 0
104
+ },
105
+ "P": {
106
+ "hydrophobicity": -1.6,
107
+ "volume": 112.7,
108
+ "charge": 0,
109
+ "polarity": 0
110
+ },
111
+ "S": {
112
+ "hydrophobicity": -0.8,
113
+ "volume": 89.0,
114
+ "charge": 0,
115
+ "polarity": 1
116
+ },
117
+ "T": {
118
+ "hydrophobicity": -0.7,
119
+ "volume": 116.1,
120
+ "charge": 0,
121
+ "polarity": 1
122
+ },
123
+ "W": {
124
+ "hydrophobicity": -0.9,
125
+ "volume": 227.8,
126
+ "charge": 0,
127
+ "polarity": 1
128
+ },
129
+ "Y": {
130
+ "hydrophobicity": -1.3,
131
+ "volume": 203.0,
132
+ "charge": 0,
133
+ "polarity": 1
134
+ },
135
+ "V": {
136
+ "hydrophobicity": 4.2,
137
+ "volume": 117.5,
138
+ "charge": 0,
139
+ "polarity": 0
140
+ },
141
+ "X": {
142
+ "hydrophobicity": 0,
143
+ "volume": 0,
144
+ "charge": 0,
145
+ "polarity": 0
146
+ }
147
+ }
148
+ }
label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f56301b90a626279392c84a763c2e4793164d9361258aaf3ba65569120e4597
3
+ size 283
preprocessor.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7b482f0df5b1269ea593a189dc4dbc321c7f24b7d45a2bfb037fae1e18c392a
3
+ size 16417
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ torch
5
+ gradio==4.36.1
6
+ matplotlib
7
+ seaborn
8
+ shap
9
+ requests
10
+ huggingface_hub
shap_background_data.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bec90c6f95e7fc71e3bdd4b221dc1d923cff3dac97284859b9e8754419c1ab65
3
+ size 218820
thermomutdb.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54d53ad4aae1b402a3fd7b5a470edcf082dc499509023c70d8a998aecffca68b
3
+ size 17047379