Skip to content

Commit

Permalink
Fix output when no output path is supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
rodvrees committed Feb 1, 2024
1 parent e7ad434 commit cdaba0d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions im2deep/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def run(
n_jobs=None,
):
"""Run IM2Deep."""
LOGGER.info("IM2Deep started.")
reference_dataset = pd.read_csv(REFERENCE_DATASET_PATH)

with open(file_pred) as f:
Expand Down Expand Up @@ -198,7 +199,7 @@ def run(
calibrated_psm_list_pred_df = linear_calibration(
psm_list_pred_df,
calibration_dataset=psm_list_cal_df,
reference_dataset=REFERENCE_DATASET,
reference_dataset=reference_dataset,
per_charge=calibrate_per_charge,
use_charge_state=use_charge_state,
)
Expand All @@ -217,19 +218,20 @@ def run(
file_pred_out.write(f"{seq},{mod},{charge},{CCS}\n")
file_pred_out.close()
else:
file_pred_out_path = Path(file_pred)
file_pred_out_path.with_stem(file_pred_out_path.stem + "_predictions")
file_pred_out = open(file_pred_out_path, "w")
file_pred_out.write("seq,modifications,charge,predicted CCS\n")
#Get path of psm file
output_file = Path(file_pred).parent / (Path(file_pred).stem + "_IM2Deep-predictions.csv")
LOGGER.info("Writing output file to %s", output_file)
output_file = open(output_file, "w")
output_file.write("seq,modifications,charge,predicted CCS\n")
for seq, mod, charge, ident, CCS in zip(
df_pred["seq"],
df_pred["modifications"],
df_pred["charge"],
df_pred.index,
calibrated_psm_list_pred_df["predicted_ccs_calibrated"],
):
file_pred_out.write(f"{seq},{mod},{charge},{CCS}\n")
file_pred_out.close()
output_file.write(f"{seq},{mod},{charge},{CCS}\n")
output_file.close()

LOGGER.info("IM2Deep finished!")

Expand Down

0 comments on commit cdaba0d

Please sign in to comment.