Skip to content

Commit bef2ecd

Browse files
force garbage collection
1 parent 738cbc3 commit bef2ecd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

create_spectral_library.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717

1818
# version tracking
19-
__version = "1.4.14"
19+
__version = "1.4.15"
2020
__date = "2025-09-24"
2121

2222
# REQUIREMENTS
@@ -48,6 +48,7 @@
4848
######################
4949

5050
# import packages
51+
import gc
5152
import re
5253
import pandas as pd
5354
from tqdm import tqdm
@@ -362,20 +363,20 @@ def read_multiple_spectra(filenames: List[str]) -> Dict[str, Dict[int, Dict]]:
362363
result_dict[current_spectra_file] = read_spectra(filename)
363364
print(f"INFO: Read all spectra from file {filename}.")
364365
except Exception as e:
365-
print(f"Error while reading file: {filename}")
366+
print(f"ERROR: Error while reading file: {filename}")
366367
print("Error details:")
367368
print(e)
368369
errors.append(filename)
369370
print(f"INFO: Read {i + 1}/{len(filenames)} files...")
370371

371372
if len(errors) > 0:
372-
print("Found errors in the following file(s):")
373+
print("ERROR: Found errors in the following file(s):")
373374
for error in errors:
374375
print(error)
375-
print("Exiting spectral library creation...")
376+
print("ERROR: Exiting spectral library creation...")
376377
raise RuntimeError("Errors while reading spectra files!")
377378

378-
print("Read all spectra files successfully!")
379+
print("INFO: Read all spectra files successfully!")
379380
return result_dict
380381

381382
# read multiple spectra files - streamlit version
@@ -1349,6 +1350,8 @@ def main(spectra_file: Union[List[str], List[BinaryIO]] = SPECTRA_FILE,
13491350
for i, row in tqdm(csms.iterrows(), total=csms.shape[0], desc="INFO: Processing CSMs..."):
13501351
current_spectrum_file = ".".join(row["Spectrum File"].split(".")[:-1]).strip()
13511352
if current_spectrum_file not in spectra:
1353+
del spectra
1354+
gc.collect()
13521355
print("Found unseen spectrum file! Trying to read spectrum file...")
13531356
local_spectrum_file_name = __get_local_spectrum_file_name(current_spectrum_file, spectra_file)
13541357
spectra = read_multiple_spectra([local_spectrum_file_name])

0 commit comments

Comments
 (0)