alphabase 1.2.2__tar.gz → 1.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. {alphabase-1.2.2/alphabase.egg-info → alphabase-1.2.3}/PKG-INFO +1 -1
  2. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/__init__.py +1 -1
  3. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/__pycache__/__init__.cpython-39.pyc +0 -0
  4. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/peptide/fragment.py +6 -6
  5. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/peptide/precursor.py +5 -5
  6. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/config_dict_loader.py +21 -15
  7. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/quant_reader_manager.py +3 -0
  8. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/base.py +6 -5
  9. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/flat.py +25 -7
  10. {alphabase-1.2.2 → alphabase-1.2.3/alphabase.egg-info}/PKG-INFO +1 -1
  11. {alphabase-1.2.2 → alphabase-1.2.3}/LICENSE +0 -0
  12. {alphabase-1.2.2 → alphabase-1.2.3}/LICENSE.txt +0 -0
  13. {alphabase-1.2.2 → alphabase-1.2.3}/MANIFEST.in +0 -0
  14. {alphabase-1.2.2 → alphabase-1.2.3}/README.md +0 -0
  15. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/_modidx.py +0 -0
  16. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/cli.py +0 -0
  17. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/__init__.py +0 -0
  18. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/_const.py +0 -0
  19. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/aa.py +0 -0
  20. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/atom.py +0 -0
  21. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/__emass_element.yaml +0 -0
  22. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/__used_mod.yaml +0 -0
  23. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/amino_acid.yaml +0 -0
  24. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/common_constants.yaml +0 -0
  25. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/contaminants.fasta +0 -0
  26. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/modification.tsv +0 -0
  27. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/nist_element.yaml +0 -0
  28. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/protease.yaml +0 -0
  29. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/psm_reader.yaml +0 -0
  30. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/const_files/quant_reader_config.yaml +0 -0
  31. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/element.py +0 -0
  32. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/isotope.py +0 -0
  33. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/constants/modification.py +0 -0
  34. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/gui.py +0 -0
  35. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/__init__.py +0 -0
  36. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/hdf.py +0 -0
  37. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/__init__.py +0 -0
  38. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/alphapept_reader.py +0 -0
  39. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/dia_psm_reader.py +0 -0
  40. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/dia_search_reader.py +0 -0
  41. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/maxquant_reader.py +0 -0
  42. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/msfragger_reader.py +0 -0
  43. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/pfind_reader.py +0 -0
  44. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/psm_reader/psm_reader.py +0 -0
  45. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/io/tempmmap.py +0 -0
  46. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/peptide/__init__.py +0 -0
  47. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/peptide/mass_calc.py +0 -0
  48. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/peptide/mobility.py +0 -0
  49. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/protein/__init__.py +0 -0
  50. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/protein/fasta.py +0 -0
  51. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/protein/inference.py +0 -0
  52. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/protein/lcp_digest.py +0 -0
  53. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/protein/protein_level_decoy.py +0 -0
  54. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/__init__.py +0 -0
  55. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/alphapept_reader.py +0 -0
  56. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/dia_psm_reader.py +0 -0
  57. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/maxquant_reader.py +0 -0
  58. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/msfragger_reader.py +0 -0
  59. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/pfind_reader.py +0 -0
  60. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/psm_reader.py +0 -0
  61. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/psm_reader/sage_reader.py +0 -0
  62. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/longformat_reader.py +0 -0
  63. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/plexdia_reformatter.py +0 -0
  64. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/quantreader_utils.py +0 -0
  65. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/table_reformatter.py +0 -0
  66. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/quantification/quant_reader/wideformat_reader.py +0 -0
  67. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/scoring/__init__.py +0 -0
  68. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/scoring/fdr.py +0 -0
  69. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/scoring/feature_extraction_base.py +0 -0
  70. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/scoring/ml_scoring.py +0 -0
  71. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/__init__.py +0 -0
  72. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/decoy.py +0 -0
  73. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/reader.py +0 -0
  74. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/translate.py +0 -0
  75. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/spectral_library/validate.py +0 -0
  76. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/statistics/__init__.py +0 -0
  77. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/statistics/regression.py +0 -0
  78. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/utils.py +0 -0
  79. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase/yaml_utils.py +0 -0
  80. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase.egg-info/SOURCES.txt +0 -0
  81. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase.egg-info/dependency_links.txt +0 -0
  82. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase.egg-info/entry_points.txt +0 -0
  83. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase.egg-info/requires.txt +0 -0
  84. {alphabase-1.2.2 → alphabase-1.2.3}/alphabase.egg-info/top_level.txt +0 -0
  85. {alphabase-1.2.2 → alphabase-1.2.3}/setup.cfg +0 -0
  86. {alphabase-1.2.2 → alphabase-1.2.3}/setup.py +0 -0
  87. {alphabase-1.2.2 → alphabase-1.2.3}/tests/test_cli.py +0 -0
  88. {alphabase-1.2.2 → alphabase-1.2.3}/tests/test_gui.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: alphabase
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: An infrastructure Python package of the AlphaX ecosystem
5
5
  Home-page: https://github.com/MannLabs/alphabase
6
6
  Author: Mann Labs
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  __project__ = "alphabase"
5
- __version__ = "1.2.2"
5
+ __version__ = "1.2.3"
6
6
  __license__ = "Apache"
7
7
  __description__ = "An infrastructure Python package of the AlphaX ecosystem"
8
8
  __author__ = "Mann Labs"
@@ -261,7 +261,7 @@ def init_fragment_by_precursor_dataframe(
261
261
 
262
262
  def update_sliced_fragment_dataframe(
263
263
  fragment_df: pd.DataFrame,
264
- fragment_mzs: np.ndarray,
264
+ fragment_df_vals: np.ndarray,
265
265
  values: np.ndarray,
266
266
  frag_start_end_list: List[Tuple[int,int]],
267
267
  charged_frag_types: List[str]=None,
@@ -275,8 +275,8 @@ def update_sliced_fragment_dataframe(
275
275
  fragment_df : pd.DataFrame
276
276
  fragment dataframe to set the values
277
277
 
278
- fragment_mzs : np.ndarray
279
- The copy np.ndarry of fragment_df
278
+ fragment_df_vals : np.ndarray
279
+ The `fragment_df.to_numpy(copy=True)`, to prevent readonly assignment.
280
280
 
281
281
  values : np.ndarray
282
282
  values to set
@@ -294,13 +294,13 @@ def update_sliced_fragment_dataframe(
294
294
  frag_slice_list = [slice(start,end) for start,end in frag_start_end_list]
295
295
  frag_slices = np.r_[tuple(frag_slice_list)]
296
296
  if charged_frag_types is None or len(charged_frag_types)==0:
297
- fragment_mzs[frag_slices, :] = values.astype(fragment_mzs.dtype)
297
+ fragment_df_vals[frag_slices, :] = values.astype(fragment_df_vals.dtype)
298
298
  else:
299
299
  charged_frag_idxes = [fragment_df.columns.get_loc(c) for c in charged_frag_types]
300
300
  fragment_df.iloc[
301
301
  frag_slices, charged_frag_idxes
302
- ] = values.astype(fragment_mzs.dtype)
303
- fragment_mzs[frag_slices] = fragment_df.values[frag_slices]
302
+ ] = values.astype(fragment_df_vals.dtype)
303
+ fragment_df_vals[frag_slices] = fragment_df.values[frag_slices]
304
304
 
305
305
  def get_sliced_fragment_dataframe(
306
306
  fragment_df: pd.DataFrame,
@@ -485,13 +485,13 @@ def _count_batchify_df(df_group, mp_batch_size):
485
485
  count += 1
486
486
  return count
487
487
 
488
- # `process_bar` should be replaced by more advanced tqdm wrappers created by Sander
488
+ # `progress_bar` should be replaced by more advanced tqdm wrappers created by Sander
489
489
  # I will leave it to alphabase.utils
490
490
  def calc_precursor_isotope_info_mp(
491
491
  precursor_df:pd.DataFrame,
492
492
  processes:int=8,
493
493
  mp_batch_size:int=10000,
494
- process_bar=None,
494
+ progress_bar=None,
495
495
  min_right_most_intensity:float=0.2,
496
496
  min_precursor_num_to_run_mp:int=10000,
497
497
  )->pd.DataFrame:
@@ -510,7 +510,7 @@ def calc_precursor_isotope_info_mp(
510
510
  mp_batch_size : int
511
511
  Multiprocessing batch size. Optional, by default 100000.
512
512
 
513
- process_bar : Callable
513
+ progress_bar : Callable
514
514
  The tqdm-based callback function
515
515
  to check multiprocessing. Defaults to None.
516
516
 
@@ -538,8 +538,8 @@ def calc_precursor_isotope_info_mp(
538
538
  min_right_most_intensity=min_right_most_intensity
539
539
  ), _batchify_df(df_group, mp_batch_size)
540
540
  )
541
- if process_bar:
542
- processing = process_bar(
541
+ if progress_bar:
542
+ processing = progress_bar(
543
543
  processing, _count_batchify_df(
544
544
  df_group, mp_batch_size
545
545
  )
@@ -9,24 +9,15 @@ import re
9
9
  INTABLE_CONFIG = os.path.join(pathlib.Path(__file__).parent.absolute(), "../../../alphabase/constants/const_files/quant_reader_config.yaml") #the yaml config is located one directory below the python library files
10
10
 
11
11
  def get_input_type_and_config_dict(input_file, input_type_to_use = None):
12
- config_dict = _load_config(INTABLE_CONFIG)
13
- type2relevant_columns = _get_type2relevant_cols(config_dict)
12
+ all_config_dicts = _load_config(INTABLE_CONFIG)
13
+ type2relevant_columns = _get_type2relevant_cols(all_config_dicts)
14
14
 
15
15
  if "aq_reformat.tsv" in input_file:
16
16
  input_file = _get_original_file_from_aq_reformat(input_file)
17
17
 
18
- filename = str(input_file)
19
- if '.csv' in filename:
20
- sep=','
21
- if '.tsv' in filename:
22
- sep='\t'
23
- if '.txt' in filename:
24
- sep='\t'
25
-
26
- if 'sep' not in locals():
27
- raise TypeError(f"neither of the file extensions (.tsv, .csv, .txt) detected for file {input_file}! Your filename has to contain one of these extensions. Please modify your file name accordingly.")
18
+ sep = _get_seperator(input_file)
28
19
 
29
- uploaded_data_columns = set(pd.read_csv(input_file, sep=sep, nrows=1, encoding ='latin1').columns)
20
+ uploaded_data_columns = set(pd.read_csv(input_file, sep=sep, nrows=1).columns)
30
21
 
31
22
  for input_type in type2relevant_columns.keys():
32
23
  if (input_type_to_use is not None) and (input_type!=input_type_to_use):
@@ -34,14 +25,29 @@ def get_input_type_and_config_dict(input_file, input_type_to_use = None):
34
25
  relevant_columns = type2relevant_columns.get(input_type)
35
26
  relevant_columns = [x for x in relevant_columns if x] #filter None values
36
27
  if set(relevant_columns).issubset(uploaded_data_columns):
37
- config_dict_type = config_dict.get(input_type)
38
- return input_type, config_dict_type, sep
28
+ config_dict = all_config_dicts.get(input_type)
29
+ return input_type, config_dict, sep
30
+
39
31
  raise TypeError("format not specified in intable_config.yaml!")
40
32
 
41
33
  def _get_original_file_from_aq_reformat(input_file):
42
34
  matched = re.match("(.*)(\..*\.)(aq_reformat\.tsv)",input_file)
43
35
  return matched.group(1)
44
36
 
37
+ def _get_seperator(input_file):
38
+ filename = str(input_file)
39
+ if '.csv' in filename:
40
+ sep=','
41
+ if '.tsv' in filename:
42
+ sep='\t'
43
+ if '.txt' in filename:
44
+ sep='\t'
45
+
46
+ if 'sep' not in locals():
47
+ raise TypeError(f"neither of the file extensions (.tsv, .csv, .txt) detected for file {input_file}! Your filename has to contain one of these extensions. Please modify your file name accordingly.")
48
+ return sep
49
+
50
+
45
51
 
46
52
  def _load_config(config_yaml):
47
53
  with open(config_yaml, 'r') as stream:
@@ -44,5 +44,8 @@ def reformat_and_save_input_file(input_file, input_type_to_use = None, use_alpha
44
44
  raise Exception('Format not recognized!')
45
45
  return outfile_name
46
46
 
47
+ def set_quanttable_config_location(quanttable_config_file):
48
+ config_dict_loader.INTABLE_CONFIG = quanttable_config_file
49
+
47
50
 
48
51
 
@@ -4,6 +4,7 @@ import typing
4
4
  import logging
5
5
  import copy
6
6
  import warnings
7
+ import re
7
8
 
8
9
  import alphabase.peptide.fragment as fragment
9
10
  import alphabase.peptide.precursor as precursor
@@ -135,9 +136,9 @@ class SpecLibBase(object):
135
136
  return self._fragment_intensity_df
136
137
 
137
138
 
138
- def available_fragment_dfs(self)->list:
139
+ def available_dense_fragment_dfs(self)->list:
139
140
  """
140
- Return the available fragment dataframes
141
+ Return the available dense fragment dataframes
141
142
  By dynamically checking the attributes of the object.
142
143
  a fragment dataframe is matched with the pattern '_fragment_[attribute_name]_df'
143
144
 
@@ -148,7 +149,7 @@ class SpecLibBase(object):
148
149
  """
149
150
  return [
150
151
  attr for attr in dir(self)
151
- if attr.startswith('_fragment') and attr.endswith('_df')
152
+ if re.match(r'_fragment_.*_df', attr)
152
153
  ]
153
154
 
154
155
  def copy(self):
@@ -197,7 +198,7 @@ class SpecLibBase(object):
197
198
 
198
199
  """
199
200
  if remove_unused_dfs:
200
- current_frag_dfs = self.available_fragment_dfs()
201
+ current_frag_dfs = self.available_dense_fragment_dfs()
201
202
  for attr in current_frag_dfs:
202
203
  if attr not in dfs_to_append:
203
204
  delattr(self, attr)
@@ -500,7 +501,7 @@ class SpecLibBase(object):
500
501
  Fragment dataframes are updated inplace and overwritten.
501
502
  """
502
503
 
503
- available_fragments_df = self.available_fragment_dfs()
504
+ available_fragments_df = self.available_dense_fragment_dfs()
504
505
  non_zero_dfs = [
505
506
  df for df in available_fragments_df
506
507
  if len(getattr(self, df)) > 0
@@ -1,5 +1,7 @@
1
1
  import pandas as pd
2
2
  import numpy as np
3
+ import warnings
4
+
3
5
  from alphabase.spectral_library.base import (
4
6
  SpecLibBase
5
7
  )
@@ -77,10 +79,22 @@ class SpecLibFlat(SpecLibBase):
77
79
  def protein_df(self)->pd.DataFrame:
78
80
  """ Protein dataframe """
79
81
  return self._protein_df
80
-
82
+
83
+ def available_dense_fragment_dfs(self):
84
+ """Return the available dense fragment dataframes.
85
+ This method is inherited from :class:`SpecLibBase` and will return an empty list for a flat library.
86
+ """
87
+ return []
88
+
89
+ def remove_unused_fragments(self):
90
+ """Remove unused fragments from fragment_df.
91
+ This method is inherited from :class:`SpecLibBase` and has not been implemented for a flat library.
92
+ """
93
+ raise NotImplementedError("remove_unused_fragments is not implemented for a flat library")
94
+
81
95
  def parse_base_library(self,
82
96
  library:SpecLibBase,
83
- keep_original_frag_dfs:bool=True,
97
+ keep_original_frag_dfs:bool=False,
84
98
  copy_precursor_df:bool=False,
85
99
  **kwargs
86
100
  ):
@@ -121,12 +135,16 @@ class SpecLibFlat(SpecLibBase):
121
135
  self._protein_df = pd.DataFrame()
122
136
 
123
137
  if keep_original_frag_dfs:
138
+
124
139
  self.charged_frag_types = library.fragment_mz_df.columns.values
125
- self._fragment_mz_df = library.fragment_mz_df
126
- self._fragment_intensity_df = library.fragment_intensity_df
127
- else:
128
- self._fragment_mz_df = pd.DataFrame()
129
- self._fragment_intensity_df = pd.DataFrame()
140
+ for dense_frag_df in library.available_dense_fragment_dfs():
141
+ setattr(self, dense_frag_df, getattr(library, dense_frag_df))
142
+
143
+ warnings.warn(
144
+ "The SpecLibFlat object will have a strictly flat representation in the future. keep_original_frag_dfs=True will be deprecated.",
145
+ DeprecationWarning
146
+ )
147
+
130
148
 
131
149
  def save_hdf(self, hdf_file:str):
132
150
  """Save library dataframes into hdf_file.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: alphabase
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: An infrastructure Python package of the AlphaX ecosystem
5
5
  Home-page: https://github.com/MannLabs/alphabase
6
6
  Author: Mann Labs
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes