Skip to content

Commit

Permalink
#296: make saving of libraries optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Aug 7, 2024
1 parent fbf1747 commit a8e196a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions alphadia/constants/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ search_output:
normalize_lfq: True
# can be either "parquet" or "tsv"
file_format: "tsv"
# whether to save the (MBR) library to the output directory
save_library: True
save_mbr_library: True

# configuration for the optimization manager
# initial parameters, will nbe optimized
Expand Down
10 changes: 5 additions & 5 deletions alphadia/outputtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ def build(
)
_ = self.build_stat_df(folder_list, psm_df=psm_df, save=True)
_ = self.build_lfq_tables(folder_list, psm_df=psm_df, save=True)
_ = self.build_library(base_spec_lib, psm_df=psm_df, save=True)
_ = self.build_library(
base_spec_lib,
psm_df=psm_df,
save=self.config["general"]["save_mbr_library"],
)

if self.config["transfer_library"]["enabled"]:
_ = self.build_transfer_library(folder_list, save=True)
Expand Down Expand Up @@ -804,14 +808,10 @@ def build_library(
precursor_number = len(mbr_spec_lib.precursor_df)
protein_number = mbr_spec_lib.precursor_df.proteins.nunique()

# use comma to separate thousands
logger.info(
f"MBR spectral library contains {precursor_number:,} precursors, {protein_number:,} proteins"
)

logger.info("Writing MBR spectral library to disk")
mbr_spec_lib.save_hdf(os.path.join(self.output_folder, "speclib.mbr.hdf"))

if save:
logger.info("Writing MBR spectral library to disk")
mbr_spec_lib.save_hdf(os.path.join(self.output_folder, "speclib.mbr.hdf"))
Expand Down
4 changes: 3 additions & 1 deletion alphadia/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,13 @@ def run(
except Exception as e:
_log_exception_event(e)
raise e
finally:
self.clean()

logger.progress("=================== Search Finished ===================")

def clean(self):
if not self.config["library_loading"]["save_hdf"]:
if not self.config["general"]["save_library"]:
os.remove(os.path.join(self.output_folder, "speclib.hdf"))


Expand Down

0 comments on commit a8e196a

Please sign in to comment.