@@ -54,24 +54,24 @@ def load_example():
54
54
return ft , md
55
55
56
56
@st .cache_data
57
- def load_from_gnps (task_id , merge_annotations ):
57
+ def load_from_gnps (task_id ):
58
58
try : # GNPS2 will run here
59
59
ft = workflow_fbmn .get_quantification_dataframe (task_id , gnps2 = True )
60
60
md = workflow_fbmn .get_metadata_dataframe (task_id , gnps2 = True ).set_index ("filename" )
61
- if merge_annotations :
62
- an = taskresult .get_gnps2_task_resultfile_dataframe (task_id , "nf_output/library/merged_results_with_gnps.tsv" )[["#Scan#" , "Compound_Name" ]].set_index ("#Scan#" )
61
+ an = taskresult .get_gnps2_task_resultfile_dataframe (task_id , "nf_output/library/merged_results_with_gnps.tsv" )[["#Scan#" , "Compound_Name" ]].set_index ("#Scan#" )
63
62
except urllib .error .HTTPError : # GNPS1 task IDs can not be retrieved and throw HTTP Error 500
64
63
ft_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={ task_id } &file=quantification_table_reformatted/&block=main"
65
64
md_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={ task_id } &file=metadata_merged/&block=main"
66
65
ft = pd .read_csv (ft_url )
67
66
md = pd .read_csv (md_url , sep = "\t " , index_col = "filename" )
68
- if merge_annotations :
69
- an_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={ task_id } &file=DB_result/&block=main"
70
- an = pd .read_csv (an_url , sep = "\t " )[["#Scan#" , "Compound_Name" ]].set_index ("#Scan#" )
71
- if merge_annotations :
72
- ft .index = pd .Index (ft .apply (lambda x : f'{ an .loc [x ["row ID" ], "Compound_Name" ]} _{ round (x ["row m/z" ], 4 )} _{ round (x ["row retention time" ], 2 )} ' if x ["row ID" ] in an .index else f'{ x ["row ID" ]} _{ round (x ["row m/z" ], 4 )} _{ round (x ["row retention time" ], 2 )} ' , axis = 1 ))
73
- else :
74
- ft .index = pd .Index (ft .apply (lambda x : f'{ x ["row ID" ]} _{ round (x ["row m/z" ], 4 )} _{ round (x ["row retention time" ], 2 )} ' , axis = 1 ))
67
+ an_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={ task_id } &file=DB_result/&block=main"
68
+ an = pd .read_csv (an_url , sep = "\t " )[["#Scan#" , "Compound_Name" ]].set_index ("#Scan#" )
69
+
70
+ index_with_annotations = pd .Index (ft .apply (lambda x : f'{ x ["row ID" ]} _{ round (x ["row m/z" ], 4 )} _{ round (x ["row retention time" ], 2 )} ' , axis = 1 ))
71
+ ft .index = index_with_annotations
72
+ st .session_state ["df_gnps_annotations" ].index = index_with_annotations
73
+ st .session_state ["df_gnps_annotations" ]["GNPS annotation" ] = ft ["row ID" ].apply (lambda x : an .loc [x , "Compound_Name" ] if x in an .index else pd .NA )
74
+ st .session_state ["df_gnps_annotations" ].dropna (inplace = True )
75
75
return ft , md
76
76
77
77
def load_ft (ft_file ):
0 commit comments