@@ -20,7 +20,7 @@ def predict_ccs(
2020 model_name = "tims" ,
2121 calibrate_per_charge = True ,
2222 use_charge_state = 2 ,
23- use_single_model = False ,
23+ use_single_model = True ,
2424 n_jobs = None ,
2525 write_output = True ,
2626):
@@ -33,33 +33,40 @@ def predict_ccs(
3333
3434 path_model_list = list (path_model .glob ("*.hdf5" ))
3535 if use_single_model :
36- path_model_list = [path_model_list [0 ]]
36+ path_model_list = [path_model_list [1 ]]
3737
3838 dlc = DeepLC (path_model = path_model_list , n_jobs = n_jobs , predict_ccs = True )
3939 LOGGER .info ("Predicting CCS values..." )
4040 preds = dlc .make_preds (psm_list = psm_list_pred , calibrate = False )
4141 LOGGER .info ("CCS values predicted." )
4242 psm_list_pred_df = psm_list_pred .to_dataframe ()
4343 psm_list_pred_df ["predicted_ccs" ] = preds
44-
45- calibrated_psm_list_pred_df = linear_calibration (
46- psm_list_pred_df ,
47- calibration_dataset = psm_list_cal_df ,
48- reference_dataset = reference_dataset ,
49- per_charge = calibrate_per_charge ,
50- use_charge_state = use_charge_state ,
44+ psm_list_pred_df ["charge" ] = psm_list_pred_df ["peptidoform" ].apply (
45+ lambda x : x .precursor_charge
5146 )
47+
48+ if psm_list_cal_df is not None :
49+ psm_list_pred_df = linear_calibration (
50+ psm_list_pred_df ,
51+ calibration_dataset = psm_list_cal_df ,
52+ reference_dataset = reference_dataset ,
53+ per_charge = calibrate_per_charge ,
54+ use_charge_state = use_charge_state ,
55+ )
56+
57+ LOGGER .debug (psm_list_pred_df )
5258 if write_output :
5359 LOGGER .info ("Writing output file..." )
5460 output_file = open (output_file , "w" )
5561 output_file .write ("seq,modifications,charge,predicted CCS\n " )
5662 for peptidoform , charge , CCS in zip (
57- calibrated_psm_list_pred_df ["peptidoform" ],
58- calibrated_psm_list_pred_df ["charge" ],
59- calibrated_psm_list_pred_df [ "predicted_ccs_calibrated " ],
63+ psm_list_pred_df ["peptidoform" ],
64+ psm_list_pred_df ["charge" ],
65+ psm_list_pred_df [ "predicted_ccs " ],
6066 ):
6167 output_file .write (f"{ peptidoform } ,{ charge } ,{ CCS } \n " )
6268 output_file .close ()
6369
6470 LOGGER .info ("IM2Deep finished!" )
65- return calibrated_psm_list_pred_df ["predicted_ccs_calibrated" ]
71+
72+ return psm_list_pred_df ["predicted_ccs" ]
0 commit comments