Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,15 +115,11 @@ def spectrum_processing(s):
|
|
| 115 |
return s
|
| 116 |
|
| 117 |
def draw_mass_spectrum(peak_data_path):
|
| 118 |
-
# 解析输入的质谱峰数据
|
| 119 |
ms2 = list(load_from_msp(peak_data_path.name))[0]
|
| 120 |
ms2 = spectrum_processing(ms2)
|
| 121 |
-
|
| 122 |
-
# 示例数据(m/z值和强度)
|
| 123 |
Mz = np.array(ms2.mz)
|
| 124 |
-
Intens = np.array(ms2.intensities)
|
| 125 |
plt.figure(figsize=(8.5,5))
|
| 126 |
-
# 绘制质谱图
|
| 127 |
for i in range(len(Mz)):
|
| 128 |
plt.axvline(x=Mz[i], ymin=0, ymax=Intens[i],c='red')
|
| 129 |
plt.xlabel("m/z")
|
|
@@ -287,10 +283,8 @@ def retrieve_similarity_scores( table_name, target_mass,collision_energy, ms2_em
|
|
| 287 |
weighted_similarity = 0.2 * low_similarity + 0.3 * median_similarity + 0.5 * high_similarity
|
| 288 |
weighted_similarity_scores.append((smile, weighted_similarity))
|
| 289 |
|
| 290 |
-
# 按加权相似度降序排序
|
| 291 |
weighted_similarity_scores.sort(key=lambda x: x[1], reverse=True)
|
| 292 |
|
| 293 |
-
# 取出前10个 SMILES
|
| 294 |
top_10_smiles = weighted_similarity_scores[:10]
|
| 295 |
cur.close()
|
| 296 |
#conn.close()
|
|
@@ -406,7 +400,6 @@ with gr.Blocks(theme=seafoam) as demo:
|
|
| 406 |
|
| 407 |
#gr.Markdown('<div style="font-size:20px;">You can select from a list of collected databases or upload your structural file by Clicking the button. The MS/MS spectrum to be identified can be uploaded in MSP format. You also need to set the necessary experimental parameters for the input spectrum, including accurate precursor mass and collision energy. Finally, by clicking the "Cross-Modal Retrieval" button, you can retrieve candidates from the selected database or your own structural file and access identification results that include compound structures, scores, and rankings.</div>')
|
| 408 |
with gr.Tab(label="📶 Struture library", elem_id='custom_tab'):
|
| 409 |
-
#Blocks特有组件,设置所有子组件按垂直排列
|
| 410 |
with gr.Row():
|
| 411 |
with gr.Column():
|
| 412 |
peak_data = gr.File(file_count="single", label="Upload MS/MS spectrum file in .msp format", elem_classes=".file-upload-height")
|
|
|
|
| 115 |
return s
|
| 116 |
|
| 117 |
def draw_mass_spectrum(peak_data_path):
|
|
|
|
| 118 |
ms2 = list(load_from_msp(peak_data_path.name))[0]
|
| 119 |
ms2 = spectrum_processing(ms2)
|
|
|
|
|
|
|
| 120 |
Mz = np.array(ms2.mz)
|
| 121 |
+
Intens = np.array(ms2.intensities)
|
| 122 |
plt.figure(figsize=(8.5,5))
|
|
|
|
| 123 |
for i in range(len(Mz)):
|
| 124 |
plt.axvline(x=Mz[i], ymin=0, ymax=Intens[i],c='red')
|
| 125 |
plt.xlabel("m/z")
|
|
|
|
| 283 |
weighted_similarity = 0.2 * low_similarity + 0.3 * median_similarity + 0.5 * high_similarity
|
| 284 |
weighted_similarity_scores.append((smile, weighted_similarity))
|
| 285 |
|
|
|
|
| 286 |
weighted_similarity_scores.sort(key=lambda x: x[1], reverse=True)
|
| 287 |
|
|
|
|
| 288 |
top_10_smiles = weighted_similarity_scores[:10]
|
| 289 |
cur.close()
|
| 290 |
#conn.close()
|
|
|
|
| 400 |
|
| 401 |
#gr.Markdown('<div style="font-size:20px;">You can select from a list of collected databases or upload your structural file by Clicking the button. The MS/MS spectrum to be identified can be uploaded in MSP format. You also need to set the necessary experimental parameters for the input spectrum, including accurate precursor mass and collision energy. Finally, by clicking the "Cross-Modal Retrieval" button, you can retrieve candidates from the selected database or your own structural file and access identification results that include compound structures, scores, and rankings.</div>')
|
| 402 |
with gr.Tab(label="📶 Struture library", elem_id='custom_tab'):
|
|
|
|
| 403 |
with gr.Row():
|
| 404 |
with gr.Column():
|
| 405 |
peak_data = gr.File(file_count="single", label="Upload MS/MS spectrum file in .msp format", elem_classes=".file-upload-height")
|