66from pathlib import Path
77from src .result_files import *
88from src .run_subprocess import *
9+ from src .view import plot_FDR_plot
910
1011params = page_setup ()
1112
8990 for f in Path (st .session_state .workspace , "result-files" ).iterdir ()
9091 if (
9192 f .name .endswith (".idXML" )
92- and not any (x in f .name for x in ["0.0100" , "0.1000" , "1.0000" ,"RT_feat" , "RT_Int_feat" , "updated_feat" ])
93+ and not any (x in f .name for x in ["0.0100" , "0.1000" , "1.0000" ,"RT_feat" , "RT_Int_feat" , "updated_feat" , "_perc_" , "_sse_perc_" ])
9394 )
9495 ]
9596
105106 selected_id_file = st .selectbox ("Choose a file for rescoring: " , session_idXML_files )
106107 idXML_file = str (Path (st .session_state .workspace , "result-files" , selected_id_file ))
107108 #st.info(f"Full path: {idXML_file}")
108-
109+
109110 protocol = st .selectbox (
110111 'Select the suitable protocol' ,
111112 ['RNA_DEB' , 'RNA_NM' , 'RNA_4SU' , 'RNA_UV' , 'RNA_Other' ],
116117
117118 Max_correlation_features = st .checkbox ("Max correlation features" , value = True , help = "Check this box to use max correlation features during rescoring." )
118119
120+ plot_PseudROC = st .checkbox ("plot pseudo-ROC" , value = True , help = "Check this for pseudo-ROC plot the comparison of rescoring." )
121+
119122 submit_button = st .form_submit_button ("Run-Rescoring" , type = "primary" )
120123
121124 # Create a dictionary to capture the output and status of the subprocess
@@ -177,27 +180,37 @@ def terminate_subprocess():
177180
178181 #st.write(model_path)
179182 #st.write(calibration_data)
183+ idXML_file_100_XLs = result_dir / Path (idXML_file ).name .replace (".idXML" , "_perc_1.0000_XLs.idXML" )
180184
181185 # run the different combinations of features
186+ # RT_feat_
182187 if Retention_time_features and not Max_correlation_features :
183188 st .write ("Using ONLY retention time features." )
184189 # Assume 'posix' for Linux and macOS
185190 args = ["nuxl_rescore" , "run" , "-id" , idXML_file , "-calibration" , calibration_data ,
186191 "-unimod" , unimod , "-feat_config" , feat_config , "-rt_model" , "DeepLC" , "-model_path" , model_path , "-out" , str (result_dir )]
192+ idXML_file_extra_100_XLs = result_dir / f"RT_feat_{ Path (idXML_file ).stem } _perc_1.0000_XLs.idXML"
187193
194+ # Int_feat_
188195 elif not Retention_time_features and Max_correlation_features :
189196 st .write ("Using ONLY max correlation feature." )
190197 # Assume 'posix' for Linux and macOS
191198 args = ["nuxl_rescore" , "run" , "-id" , idXML_file ,"-rt_model" , "None" , "-ms2pip" ,
192199 "-unimod" , unimod , "-feat_config" , feat_config , "-out" , str (result_dir )]
200+ idXML_file_extra_100_XLs = result_dir / f"Int_feat_{ Path (idXML_file ).stem } _perc_1.0000_XLs.idXML"
193201
202+ # RT_Int_feat_
194203 elif Retention_time_features and Max_correlation_features :
195204 st .write ("Using retention time and max correlation feature." )
196205 # Assume 'posix' for Linux and macOS
197206 args = ["nuxl_rescore" , "run" , "-id" , idXML_file , "-calibration" , calibration_data ,
198207 "-unimod" , unimod , "-rt_model" , "DeepLC" , "-ms2pip" , "-feat_config" , feat_config , "-model_path" , model_path , "-out" , str (result_dir )]
208+ idXML_file_extra_100_XLs = result_dir / f"RT_Int_feat_{ Path (idXML_file ).stem } _perc_1.0000_XLs.idXML"
209+
210+
199211 else :
200212 st .error ("Please select at least one feature to use for rescoring." )
213+ idXML_file_extra_100_XLs = result_dir / f"updated_{ Path (idXML_file ).stem } _perc_1.0000_XLs.idXML"
201214 st .stop ()
202215
203216 # Add any additional variables needed for the subprocess (if any)
@@ -255,13 +268,12 @@ def terminate_subprocess():
255268 # want to see the command values and argues
256269 message = f"Running '{ ' ' .join (args )} '"
257270 st .info (message )
258-
271+ st . info ( "check inputs plot: " + str ( idXML_file_100_XLs ) + ' and ' + str ( idXML_file_extra_100_XLs ) + ' ' + str ( Path ( idXML_file ). stem ))
259272 # run subprocess command
260273 run_subprocess (args , variables , result_dict )
261274
262275 # Check if the subprocess was successful
263276 if result_dict ["success" ]:
264- st .info ("⚡️ **Rescoring Completed Successfully!** ⚡️" )
265277 # Here can add code here to handle the results, e.g., display them to the user
266278 extensions_to_remove = {
267279 ".csv" ,
@@ -275,6 +287,21 @@ def terminate_subprocess():
275287 if f .is_file () and f .suffix in extensions_to_remove :
276288 f .unlink ()
277289
290+ if plot_PseudROC :
291+ #ploting_pseudoROC()
292+ st .info ("Generating Pseudo-ROC plot ..." )
293+ fig = plot_FDR_plot (
294+ idXML_id = str (idXML_file_100_XLs ),
295+ idXML_extra = str (idXML_file_extra_100_XLs ),
296+ FDR_level = 20 ,
297+ exp_name = str (Path (idXML_file ).stem )
298+ )
299+
300+ #show figure
301+ show_fig (fig , f"{ Path (idXML_file ).stem } _PseudoROC_plot_rescoring" )
302+
303+ st .success ("⚡️ **Rescoring Completed Successfully!** ⚡️" )
304+
278305 else :
279306 # Display error message
280307 st .error (
0 commit comments