Spectral denoising: in bacth mode
The spectral_denoising_batch is just a simple wrapper function that performs spectral_denoising in batch mode, with parallelization implementaion.
The sample data can be found here.
Example usage:
import spectral_denoising as sd
from spectral_denoising.file_io import *
query_data = sd.read_msp('sample_data/noisy_spectra.msp')
query_spectra,query_smiles,query_adducts = query_data['peaks'],query_data['smiles'],query_data['adduct']
denoised_spectra = sd.spectral_denoising_batch(query_spectra,query_smiles,query_adducts)
The output ‘denoised_spectra’ will be a list of denoised spectra, with the same order as the input spectra.
References
- spectral_denoising.spectral_denoising_batch(msms_query, smiles_query, adduct_query, mass_tolerance=0.005)[source]
Perform batch spectral denoising on multiple sets of MS/MS spectra, SMILES strings, and adducts. Uses multiprocessing to parallelize the denoising process.
- Parameters:
msms_query (list): A list of MS/MS spectra data.
smiles_query (list): A list of SMILES strings corresponding to the MS/MS spectra.
adduct_query (list): A list of adducts corresponding to the MS/MS spectra.
mass_tolerance (float, optional): The allowed deviation for the denoising process. Default is 0.005.
- Returns:
list: A list of denoised MS/MS from the spectral denoising process.
- Notes:
The lengths of msms_query, smiles_query, and adduct_query must be the same. If not, the function will print an error message and return an empty tuple.
The function uses multiprocessing to parallelize the denoising process, utilizing 6 processes.
- spectral_denoising.file_io.read_msp(file_path)[source]
Reads the MSP files into the pandas dataframe, and sort/remove zero intensity ions in MS/MS spectra.
- Args:
file_path (str): target path path for the MSP file.
- Returns:
pd.DataFrame: DataFrame containing the MS/MS spectra information