-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23b0a7d
commit f85bb32
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
from depiction.parallel_ops import ParallelConfig | ||
from depiction.persistence.types import GenericReadFile, GenericWriteFile | ||
from depiction.parallel_ops import ParallelConfig, WriteSpectraParallel | ||
from depiction.persistence.types import GenericReadFile, GenericWriteFile, GenericReader, GenericWriter | ||
from depiction.tools.process_spectra.config import ProcessSpectraConfig | ||
from depiction.tools.process_spectra.evaluators import get_combined_evaluator | ||
|
||
|
||
def process_spectra(read_file: GenericReadFile, write_file: GenericWriteFile, config: ProcessSpectraConfig) -> None: | ||
parallel_config = ParallelConfig(n_jobs=config.n_jobs) | ||
write_parallel = WriteSpectraParallel.from_config(parallel_config) | ||
write_parallel.map_chunked_to_file( | ||
read_file=read_file, write_file=write_file, operation=_process_chunk, bind_args={"config": config} | ||
) | ||
|
||
|
||
def _process_chunk( | ||
reader: GenericReader, spectra_indices: list[int], writer: GenericWriter, config: ProcessSpectraConfig | ||
) -> None: | ||
evaluator = get_combined_evaluator(config=config) | ||
for spectrum_index in spectra_indices: | ||
mz_arr, int_arr, coords = reader.get_spectrum_with_coords(spectrum_index) | ||
mz_arr, int_arr = evaluator.evaluate(mz_arr, int_arr) | ||
writer.add_spectrum(mz_arr, int_arr, coords) |