From f1c8679b08ea274dbcff74e7676efd9f98ad7810 Mon Sep 17 00:00:00 2001 From: jalew188 Date: Thu, 20 Jun 2024 14:22:55 +0200 Subject: [PATCH 1/3] #53 put parameters docs into __init__ in class def --- alpharaw/ms_data_base.py | 15 ++++++------ alpharaw/thermo.py | 33 +++++++++++++------------- alpharaw/wrappers/alphatims_wrapper.py | 33 +++++++++++++------------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/alpharaw/ms_data_base.py b/alpharaw/ms_data_base.py index 142de52..915ec85 100644 --- a/alpharaw/ms_data_base.py +++ b/alpharaw/ms_data_base.py @@ -7,13 +7,6 @@ class MSData_Base: """ The base data structure for MS RAW Data, other MSData loaders inherit this class. - - Parameters - ---------- - centroided : bool, optional - If centroiding the peak data, by default True - save_as_hdf : bool, optional - If automatically save the data into HDF5 format, by default False """ column_dtypes = { @@ -76,6 +69,14 @@ class MSData_Base: """ def __init__(self, centroided: bool = True, save_as_hdf: bool = False, **kwargs): + """ + Parameters + ---------- + centroided : bool, optional + If centroiding the peak data, by default True + save_as_hdf : bool, optional + If automatically save the data into HDF5 format, by default False + """ # A spectrum contains peaks self.spectrum_df: pd.DataFrame = pd.DataFrame() # A peak contains mz, intensity, and ... diff --git a/alpharaw/thermo.py b/alpharaw/thermo.py index 0731570..242bed7 100644 --- a/alpharaw/thermo.py +++ b/alpharaw/thermo.py @@ -54,22 +54,6 @@ class ThermoRawData(MSData_Base): Loading Thermo Raw data as MSData_Base data structure. This class is registered "thermo" and "thermo_raw" in :obj:`alpharaw.ms_data_base.ms_reader_provider`. - - Parameters - ---------- - centroided : bool, optional - If peaks will be centroided after loading. By defaults True. - process_count : int, optional - Number of processes to load RAW data, by default 10. - mp_batch_size : int, optional - Number of spectra to load in each batch, by default 5000. - save_as_hdf : bool, optional - Automatically save hdf after load raw data, by default False. - dda : bool, optional - Is DDA data, by default False. - auxiliary_items : list, optional - Additional spectrum items, candidates are in :data:`auxiliary_item_dtypes`. - By default []. """ def __init__( @@ -82,6 +66,23 @@ def __init__( auxiliary_items: list = [], **kwargs, ): + """ + Parameters + ---------- + centroided : bool, optional + If peaks will be centroided after loading. By defaults True. + process_count : int, optional + Number of processes to load RAW data, by default 10. + mp_batch_size : int, optional + Number of spectra to load in each batch, by default 5000. + save_as_hdf : bool, optional + Automatically save hdf after load raw data, by default False. + dda : bool, optional + Is DDA data, by default False. + auxiliary_items : list, optional + Additional spectrum items, candidates are in :data:`auxiliary_item_dtypes`. + By default []. + """ super().__init__(centroided, save_as_hdf=save_as_hdf, **kwargs) self.file_type = "thermo" self.process_count = process_count diff --git a/alpharaw/wrappers/alphatims_wrapper.py b/alpharaw/wrappers/alphatims_wrapper.py index 4ea4dd9..b001925 100644 --- a/alpharaw/wrappers/alphatims_wrapper.py +++ b/alpharaw/wrappers/alphatims_wrapper.py @@ -45,25 +45,26 @@ def import_raw(self, burker_d_folder: str): class AlphaTimsWrapper(TimsTOF): """Create a AlphaTims object that contains all data in-memory (or memory mapping). - - Parameters - ---------- - msdata : MSData_Base - The AlphaRaw data object. - - dda : bool - If DDA, precursor indices will be equal to scan numbers. - If not DDA (i.e. DIA), precursor indices will be equal to the - scan number within a DIA cycle. - - slice_as_dataframe : bool - If True, slicing returns a pd.DataFrame by default. - If False, slicing provides a np.int64[:] with raw indices. - This value can also be modified after creation. - Default is True. """ def __init__(self, msdata: MSData_Base, dda: bool, slice_as_dataframe: bool = True): + """ + Parameters + ---------- + msdata : MSData_Base + The AlphaRaw data object. + + dda : bool + If DDA, precursor indices will be equal to scan numbers. + If not DDA (i.e. DIA), precursor indices will be equal to the + scan number within a DIA cycle. + + slice_as_dataframe : bool + If True, slicing returns a pd.DataFrame by default. + If False, slicing provides a np.int64[:] with raw indices. + This value can also be modified after creation. + Default is True. + """ self._use_calibrated_mz_values_as_default = False self._import_alpharaw_object(msdata, dda) self.thermo_raw_file_name = msdata.raw_file_path From a52aa1828b3b88ab7d6cb0f5c6a5fa427b151df8 Mon Sep 17 00:00:00 2001 From: jalew188 Date: Wed, 26 Jun 2024 11:13:09 +0200 Subject: [PATCH 2/3] #53 align centroiding description --- alpharaw/ms_data_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpharaw/ms_data_base.py b/alpharaw/ms_data_base.py index 915ec85..284730e 100644 --- a/alpharaw/ms_data_base.py +++ b/alpharaw/ms_data_base.py @@ -73,7 +73,7 @@ def __init__(self, centroided: bool = True, save_as_hdf: bool = False, **kwargs) Parameters ---------- centroided : bool, optional - If centroiding the peak data, by default True + If peaks will be centroided after loading, by default True save_as_hdf : bool, optional If automatically save the data into HDF5 format, by default False """ @@ -479,7 +479,7 @@ def get_reader( ms_file_type : str AlphaRaw supported MS file types. centroided : bool, optional - If centroiding the data, by default True. + If peaks will be centroided after loading, by default True. Returns ------- From 3e3cff0b7d334d520c5b43413ff1a4f03b76d02f Mon Sep 17 00:00:00 2001 From: jalew188 Date: Wed, 26 Jun 2024 13:02:01 +0200 Subject: [PATCH 3/3] FIX alphatims_wrapper docs --- alpharaw/wrappers/alphatims_wrapper.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/alpharaw/wrappers/alphatims_wrapper.py b/alpharaw/wrappers/alphatims_wrapper.py index b001925..c4d00d6 100644 --- a/alpharaw/wrappers/alphatims_wrapper.py +++ b/alpharaw/wrappers/alphatims_wrapper.py @@ -8,7 +8,7 @@ class AlphaTimsReader(MSData_Base): """ - > TimsTOF data are too large, do not use this class + TimsTOF data are too large, do not use this class """ def import_raw(self, burker_d_folder: str): @@ -43,8 +43,16 @@ def import_raw(self, burker_d_folder: str): class AlphaTimsWrapper(TimsTOF): - """Create a AlphaTims object that contains + """Create a AlphaTims object containing all data in-memory (or memory mapping). + + Attribute + --------- + slice_as_dataframe + Attribute from AlphaTims. + If True, AlphaTims slicing returns a pd.DataFrame by default. + If False, AlphaTims slicing provides a np.int64[:] with raw indices. + The value can be modified on-the-fly. """ def __init__(self, msdata: MSData_Base, dda: bool, slice_as_dataframe: bool = True): @@ -62,14 +70,15 @@ def __init__(self, msdata: MSData_Base, dda: bool, slice_as_dataframe: bool = Tr slice_as_dataframe : bool If True, slicing returns a pd.DataFrame by default. If False, slicing provides a np.int64[:] with raw indices. - This value can also be modified after creation. Default is True. """ self._use_calibrated_mz_values_as_default = False self._import_alpharaw_object(msdata, dda) self.thermo_raw_file_name = msdata.raw_file_path self.bruker_d_folder_name = self.thermo_raw_file_name - self.slice_as_dataframe = slice_as_dataframe + self.slice_as_dataframe = ( + slice_as_dataframe # This value can be modified after creation. + ) # Precompile self[0, "raw"]