pycompound 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

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.
@@ -12,6 +12,9 @@ parser = argparse.ArgumentParser()
12
12
 
13
13
  parser.add_argument('--query_data', type=str, metavar='\b', help='CSV file of query mass spectrum/spectra to be identified. Each row should correspond to a mass spectrum, the left-most column should contain an identifier, and each of the other columns should correspond to a single mass/charge ratio. Mandatory argument.')
14
14
  parser.add_argument('--reference_data', type=str, metavar='\b', help='CSV file of the reference mass spectra. Each row should correspond to a mass spectrum, the left-most column should contain in identifier (i.e. the CAS registry number or the compound name), and the remaining column should correspond to a single mass/charge ratio. Mandatory argument.')
15
+ parser.add_argument('--precursor_ion_mz_tolerance', type=str, metavar='\b', default=None, help='Precursor ion m/z tolerance (positive real number; only applicable to HRMS)). Default=None')
16
+ parser.add_argument('--ionization_mode', type=str, metavar='\b', default=None, help='Ionization mode (only applicable to HRMS). Options: \'Positive\', \'Negative\', or \'N/A\'.')
17
+ parser.add_argument('--adduct', type=str, metavar='\b', default='H', help='Adduct (only applicable to HRMS). Options: \'H\', \'NH3\', \'NH4\', \'OH\', \'Cl\', \'K\', \'Li\', \'Na\'. Default: \'H\'.')
15
18
  parser.add_argument('--likely_reference_ids', type=str, metavar='\b', help='CSV file with one column containing the IDs of a subset of all compounds in the reference_data to be used in spectral library matching. Each ID in this file must be an ID in the reference library. Default: none (i.e. default is to use entire reference library)')
16
19
  parser.add_argument('--similarity_measure', type=str, default='cosine', metavar='\b', help='Similarity measure: options are cosine, shannon, renyi, tsallis, mixture, jaccard, dice, 3w_jaccard, sokal_sneath, binary_cosine, mountford, mcconnaughey, driver_kroeber, simpson, braun_banquet, fager_mcgowan, kulczynski, intersection, hamming, or hellinger. Default: cosine.')
17
20
  parser.add_argument('--weights', type=json.loads, default={'Cosine':0.25,'Shannon':0.25,'Renyi':0.25,'Tsallis':0.25}, metavar='\b', help='dict of weights to give to each non-binary similarity measure (i.e. cosine, shannon, renyi, and tsallis) when the mixture similarity measure is specified. Default: 0.25 for each of the four non-binary similarity measures.')
@@ -39,9 +42,52 @@ args = parser.parse_args()
39
42
 
40
43
 
41
44
  if args.chromatography_platform == 'HRMS':
42
- run_spec_lib_matching_on_HRMS_data(query_data=args.query_data, reference_data=args.reference_data, likely_reference_ids=args.likely_reference_ids, similarity_measure=args.similarity_measure, weights=args.weights, spectrum_preprocessing_order=args.spectrum_preprocessing_order, high_quality_reference_library=args.high_quality_reference_library, mz_min=args.mz_min, mz_max=args.mz_max, int_min=args.int_min, int_max=args.int_max, window_size_centroiding=args.window_size_centroiding, window_size_matching=args.window_size_matching, noise_threshold=args.noise_threshold, wf_mz=args.wf_mz, wf_intensity=args.wf_intensity, LET_threshold=args.LET_threshold, entropy_dimension=args.entropy_dimension, n_top_matches_to_save=args.n_top_matches_to_save, print_id_results=args.print_id_results, output_identification=args.output_identification, output_similarity_scores=args.output_similarity_scores)
45
+ run_spec_lib_matching_on_HRMS_data(query_data=args.query_data,
46
+ reference_data=args.reference_data,
47
+ precursor_ion_mz_tolerance=args.precursor_ion_mz_tolerance,
48
+ ionization_mode=args.ionization_mode,
49
+ adduct=args.adduct,
50
+ likely_reference_ids=args.likely_reference_ids,
51
+ similarity_measure=args.similarity_measure,
52
+ weights=args.weights,
53
+ spectrum_preprocessing_order=args.spectrum_preprocessing_order,
54
+ high_quality_reference_library=args.high_quality_reference_library,
55
+ mz_min=args.mz_min,
56
+ mz_max=args.mz_max,
57
+ int_min=args.int_min,
58
+ int_max=args.int_max,
59
+ window_size_centroiding=args.window_size_centroiding,
60
+ window_size_matching=args.window_size_matching,
61
+ noise_threshold=args.noise_threshold,
62
+ wf_mz=args.wf_mz,
63
+ wf_intensity=args.wf_intensity,
64
+ LET_threshold=args.LET_threshold,
65
+ entropy_dimension=args.entropy_dimension,
66
+ n_top_matches_to_save=args.n_top_matches_to_save,
67
+ print_id_results=args.print_id_results,
68
+ output_identification=args.output_identification,
69
+ output_similarity_scores=args.output_similarity_scores)
43
70
 
44
71
 
45
72
  if args.chromatography_platform == 'NRMS':
46
- run_spec_lib_matching_on_NRMS_data(query_data=args.query_data, reference_data=args.reference_data, likely_reference_ids=args.likely_reference_ids, similarity_measure=args.similarity_measure, weights=args.weights, spectrum_preprocessing_order=args.spectrum_preprocessing_order, high_quality_reference_library=args.high_quality_reference_library, mz_min=args.mz_min, mz_max=args.mz_max, int_min=args.int_min, int_max=args.int_max, noise_threshold=args.noise_threshold, wf_mz=args.wf_mz, wf_intensity=args.wf_intensity, LET_threshold=args.LET_threshold, entropy_dimension=args.entropy_dimension, n_top_matches_to_save=args.n_top_matches_to_save, print_id_results=args.print_id_results, output_identification=args.output_identification, output_similarity_scores=args.output_similarity_scores)
73
+ run_spec_lib_matching_on_NRMS_data(query_data=args.query_data,
74
+ reference_data=args.reference_data,
75
+ likely_reference_ids=args.likely_reference_ids,
76
+ similarity_measure=args.similarity_measure,
77
+ weights=args.weights,
78
+ spectrum_preprocessing_order=args.spectrum_preprocessing_order,
79
+ high_quality_reference_library=args.high_quality_reference_library,
80
+ mz_min=args.mz_min,
81
+ mz_max=args.mz_max,
82
+ int_min=args.int_min,
83
+ int_max=args.int_max,
84
+ noise_threshold=args.noise_threshold,
85
+ wf_mz=args.wf_mz,
86
+ wf_intensity=args.wf_intensity,
87
+ LET_threshold=args.LET_threshold,
88
+ entropy_dimension=args.entropy_dimension,
89
+ n_top_matches_to_save=args.n_top_matches_to_save,
90
+ print_id_results=args.print_id_results,
91
+ output_identification=args.output_identification,
92
+ output_similarity_scores=args.output_similarity_scores)
47
93
 
@@ -42,9 +42,7 @@ DEFAULT_PARAMS = {
42
42
  }
43
43
 
44
44
 
45
- # ---------- Utilities ----------
46
45
  def parse_bound(s: str) -> Tuple[str, Tuple[float, float]]:
47
- # "name=min:max" → (name, (min, max))
48
46
  if "=" not in s or ":" not in s:
49
47
  raise argparse.ArgumentTypeError(f"Bad --bound format '{s}'. Use name=min:max")
50
48
  name, rng = s.split("=", 1)
@@ -59,7 +57,6 @@ def parse_bound(s: str) -> Tuple[str, Tuple[float, float]]:
59
57
 
60
58
 
61
59
  def parse_default(s: str) -> Tuple[str, float]:
62
- # "name=value" → (name, value)
63
60
  if "=" not in s:
64
61
  raise argparse.ArgumentTypeError(f"Bad --default format '{s}'. Use name=value")
65
62
  name, val = s.split("=", 1)
@@ -82,7 +79,7 @@ def objective_HRMS(X: np.ndarray, ctx: dict) -> float:
82
79
  p = _vector_to_full_params(X, ctx["default_params"], ctx["optimize_params"])
83
80
  acc = get_acc_HRMS(
84
81
  ctx["df_query"], ctx["df_reference"],
85
- ctx["uq"], ctx["ur"],
82
+ ctx["precursor_ion_mz_tolerance"], ctx["ionization_mode"], ctx["adduct"],
86
83
  ctx["similarity_measure"], ctx["weights"], ctx["spectrum_preprocessing_order"],
87
84
  ctx["mz_min"], ctx["mz_max"], ctx["int_min"], ctx["int_max"],
88
85
  p["window_size_centroiding"], p["window_size_matching"], p["noise_threshold"],
@@ -103,8 +100,7 @@ def objective_NRMS(X: np.ndarray, ctx: dict) -> float:
103
100
  ctx["similarity_measure"], ctx["weights"], ctx["spectrum_preprocessing_order"],
104
101
  ctx["mz_min"], ctx["mz_max"], ctx["int_min"], ctx["int_max"],
105
102
  p["noise_threshold"], p["wf_mz"], p["wf_int"], p["LET_threshold"], p["entropy_dimension"],
106
- ctx["high_quality_reference_library"],
107
- verbose=False
103
+ ctx["high_quality_reference_library"]
108
104
  )
109
105
  print(f"\n{ctx['optimize_params']} = {np.array(X)}\naccuracy: {acc*100}%")
110
106
  return 1.0 - acc
@@ -112,15 +108,16 @@ def objective_NRMS(X: np.ndarray, ctx: dict) -> float:
112
108
 
113
109
  # ---------- Main CLI ----------
114
110
  def main():
115
- p = argparse.ArgumentParser(
116
- description="Parameter tuning via Differential Evolution for HRMS/NRMS using pycompound."
117
- )
111
+ p = argparse.ArgumentParser(description="Parameter tuning via Differential Evolution for HRMS/NRMS using pycompound.")
118
112
  p.add_argument("--chromatography_platform", choices=["HRMS", "NRMS"], default="HRMS", help="Chromatography Platform.")
119
- p.add_argument("--query_data", required=True, help="Path to query CSV (must contain 'id' column).")
120
- p.add_argument("--reference_data", required=True, nargs="+", help="Path(s) to reference CSV(s) (must contain 'id').")
121
- p.add_argument("--similarity_measure", default="cosine", choices=["cosine", "renyi", "tsallis"], help="Similarity measure.")
113
+ p.add_argument("--query_data", required=True, help="Path to query TXT (must contain 'id' column).")
114
+ p.add_argument("--reference_data", required=True, nargs="+", help="Path(s) to reference TXT(s) (must contain 'id').")
115
+ p.add_argument("--precursor_ion_mz_tolerance", type=float, default=None, help='Precursor ion m/z tolerance (positive real number; only applicable to HRMS)). Default=None')
116
+ p.add_argument("--ionization_mode", choices=['Positive','Negative',None], default=None, help='Ionization mode (only applicable to HRMS). Options: \'Positive\', \'Negative\', or \'None\'. Default=None')
117
+ p.add_argument("--adduct", choices=['H','NH3','NH4','OH','K','Li','Na',None], default=None, help='Adduct (only applicable to HRMS). Options: \'H\', \'NH3\', \'NH4\', \'OH\', \'Cl\', \'K\', \'Li\', \'Na\'. Default: \'H\'.')
118
+ p.add_argument("--similarity_measure", default="cosine", choices=["cosine", "shannon", "renyi", "tsallis"], help="Similarity measure.")
122
119
  p.add_argument("--weights", default="", help="Weights spec; empty means None.")
123
- p.add_argument("--spectrum-order", default="CNMWL", help="Spectrum preprocessing order string.")
120
+ p.add_argument("--spectrum_preprocessing_order", default="CNMWL", help="Spectrum preprocessing order string.")
124
121
  p.add_argument("--mz-min", type=float, default=0.0)
125
122
  p.add_argument("--mz-max", type=float, default=999_999_999.0)
126
123
  p.add_argument("--int-min", type=float, default=0.0)
@@ -143,19 +140,19 @@ def main():
143
140
 
144
141
  qpath = Path(args.query_data)
145
142
  if not qpath.exists():
146
- sys.exit(f"Query CSV not found: {qpath}")
143
+ sys.exit(f"Query TXT not found: {qpath}")
147
144
 
148
- df_query = pd.read_csv(qpath)
145
+ df_query = pd.read_csv(qpath,sep='\t')
149
146
  if "id" not in df_query.columns:
150
- sys.exit("Query CSV must contain an 'id' column.")
147
+ sys.exit("Query TXT must contain an 'id' column.")
151
148
 
152
149
  ref_paths = [Path(pth) for pth in args.reference_data]
153
150
  for r in ref_paths:
154
151
  if not r.exists():
155
- sys.exit(f"Reference CSV not found: {r}")
156
- df_reference = pd.concat([pd.read_csv(r) for r in ref_paths], axis=0, ignore_index=True)
152
+ sys.exit(f"Reference TXT not found: {r}")
153
+ df_reference = pd.concat([pd.read_csv(r,sep='\t') for r in ref_paths], axis=0, ignore_index=True)
157
154
  if "id" not in df_reference.columns:
158
- sys.exit("Reference CSV must contain an 'id' column.")
155
+ sys.exit("Reference TXT must contain an 'id' column.")
159
156
 
160
157
  uq = df_query["id"].unique().tolist()
161
158
  ur = df_reference["id"].unique().tolist()
@@ -177,11 +174,13 @@ def main():
177
174
  ctx = dict(
178
175
  df_query=df_query,
179
176
  df_reference=df_reference,
180
- uq=uq,
181
- ur=ur,
177
+ precursor_ion_mz_tolerance=args.precursor_ion_mz_tolerance,
178
+ ionization_mode=args.ionization_mode,
179
+ uq=uq, ur=ur,
180
+ adduct=args.adduct,
182
181
  similarity_measure=args.similarity_measure,
183
182
  weights=(None if args.weights.strip() == "" else args.weights),
184
- spectrum_preprocessing_order=args.spectrum_order,
183
+ spectrum_preprocessing_order=args.spectrum_preprocessing_order,
185
184
  mz_min=float(args.mz_min),
186
185
  mz_max=float(args.mz_max),
187
186
  int_min=float(args.int_min),
@@ -211,6 +210,7 @@ def main():
211
210
  seed=int(args.seed),
212
211
  workers=int(args.workers),
213
212
  callback=_cb,
213
+ updating='deferred' if int(args.workers)!=1 else 'immediate'
214
214
  )
215
215
 
216
216
  best_params = _vector_to_full_params(result.x, default_params, args.opt)
@@ -10,11 +10,14 @@ parser = argparse.ArgumentParser()
10
10
 
11
11
  parser.add_argument('--query_data', type=str, metavar='\b', help='CSV file of query mass spectrum/spectra to be identified. Each row should correspond to a mass spectrum, the left-most column should contain an identifier, and each of the other columns should correspond to a single mass/charge ratio. Mandatory argument.')
12
12
  parser.add_argument('--reference_data', type=str, metavar='\b', help='CSV file of the reference mass spectra. Each row should correspond to a mass spectrum, the left-most column should contain in identifier (i.e. the CAS registry number or the compound name), and the remaining column should correspond to a single mass/charge ratio. Mandatory argument.')
13
+ parser.add_argument('--precursor_ion_mz_tolerance', type=str, metavar='\b', default=None, help='Precursor ion m/z tolerance (positive real number; only applicable to HRMS)). Default=None')
14
+ parser.add_argument('--ionization_mode', type=str, metavar='\b', default=None, help='Ionization mode (only applicable to HRMS). Options: \'Positive\', \'Negative\', or \'N/A\'.')
15
+ parser.add_argument('--adduct', type=str, metavar='\b', default='H', help='Adduct (only applicable to HRMS). Options: \'H\', \'NH3\', \'NH4\', \'OH\', \'Cl\', \'K\', \'Li\', \'Na\'. Default: \'H\'.')
13
16
  parser.add_argument('--likely_reference_ids', type=str, metavar='\b', help='CSV file with one column containing the IDs of a subset of all compounds in the reference_data to be used in spectral library matching. Each ID in this file must be an ID in the reference library. Default: none (i.e. default is to use entire reference library)')
14
17
  parser.add_argument('--similarity_measure', type=str, default='cosine', metavar='\b', help='Similarity measure: options are cosine, shannon, renyi, tsallis, mixture, jaccard, dice, 3w_jaccard, sokal_sneath, binary_cosine, mountford, mcconnaughey, driver_kroeber, simpson, braun_banquet, fager_mcgowan, kulczynski, intersection, hamming, or hellinger. Default: cosine.')
15
18
  parser.add_argument('--weights', type=json.loads, default={'Cosine':0.25,'Shannon':0.25,'Renyi':0.25,'Tsallis':0.25}, metavar='\b', help='dict of weights to give to each non-binary similarity measure (i.e. cosine, shannon, renyi, and tsallis) when the mixture similarity measure is specified. Default: 0.25 for each of the four non-binary similarity measures.')
16
19
  parser.add_argument('--chromatography_platform', type=str, metavar='\b', help='Chromatography platform: options are \'HRMS\' and \'NRMS\'. Mandatory argument.')
17
- parser.add_argument('--spectrum_preprocessing_order', type=str, metavar='\b', help='The LC-MS/MS spectrum preprocessing transformations and the order in which they are to be applied. Note that these transformations are applied prior to computing similarity scores. Format must be a string with 2-6 characters chosen from C, F, M, N, L, W representing centroiding, filtering based on mass/charge and intensity values, matching, noise removal, low-entropy trannsformation, and weight-factor-transformation, respectively. For example, if \'WCM\' is passed, then each spectrum will undergo a weight factor transformation, then centroiding, and then matching. Note that if an argument is passed, then \'M\' must be contained in the argument, since matching is a required preprocessing step in spectral library matching of LC-MS/MS data. Furthermore, \'C\' must be performed before matching since centroiding can change the number of ion fragments in a given spectrum. Default: FCNMWL for HRMS, FNLW for NRMS')
20
+ parser.add_argument('--spectrum_preprocessing_order', type=str, metavar='\b', default=None, help='The LC-MS/MS spectrum preprocessing transformations and the order in which they are to be applied. Note that these transformations are applied prior to computing similarity scores. Format must be a string with 2-6 characters chosen from C, F, M, N, L, W representing centroiding, filtering based on mass/charge and intensity values, matching, noise removal, low-entropy trannsformation, and weight-factor-transformation, respectively. For example, if \'WCM\' is passed, then each spectrum will undergo a weight factor transformation, then centroiding, and then matching. Note that if an argument is passed, then \'M\' must be contained in the argument, since matching is a required preprocessing step in spectral library matching of LC-MS/MS data. Furthermore, \'C\' must be performed before matching since centroiding can change the number of ion fragments in a given spectrum. Default: FCNMWL for HRMS, FNLW for NRMS')
18
21
  parser.add_argument('--high_quality_reference_library', type=str, default='False', metavar='\b', help='True/False flag indicating whether the reference library is considered to be of high quality. If True, then the spectrum preprocessing transformations of filtering and noise removal are performed only on the query spectrum/spectra. If False, all spectrum preprocessing transformations specified will be applied to both the query and reference spectra. Default: False')
19
22
  parser.add_argument('--mz_min', type=str, default='0', metavar='\b', help='Remove all peaks with mass/charge less than mz_min in each spectrum. Default: 0')
20
23
  parser.add_argument('--mz_max', type=str, default='999999999999', metavar='\b', help='Remove all peaks with mass/charge greater than mz_max in each spectrum. Default: 999999999999')
@@ -31,9 +34,9 @@ parser.add_argument('--output_path', type=str, default=f'{Path.cwd()}/output_tun
31
34
 
32
35
  args = parser.parse_args()
33
36
 
34
- if args.chromatography_platform == 'HRMS':
37
+ if args.chromatography_platform == 'HRMS' and args.spectrum_preprocessing_order == None:
35
38
  spectrum_preprocessing_order = 'FCNMWL'
36
- elif args.chromatography_platform == 'NRMS':
39
+ elif args.chromatography_platform == 'NRMS' and args.spectrum_preprocessing_order == None:
37
40
  spectrum_preprocessing_order = 'FNLW'
38
41
  else:
39
42
  print('Error: chromatography_platform must be either \'HRMS\' or \'NRMS\'')
@@ -59,11 +62,24 @@ grid['wf_int'] = [float(x) for x in grid['wf_int']]
59
62
  grid['LET_threshold'] = [float(x) for x in grid['LET_threshold']]
60
63
  grid['entropy_dimension'] = [float(x) for x in grid['entropy_dimension']]
61
64
 
65
+ if args.precursor_ion_mz_tolerance == None:
66
+ precursor_ion_mz_tolerance_tmp = None
67
+ else:
68
+ precursor_ion_mz_tolerance_tmp = float(args.precursor_ion_mz_tolerance)
69
+
62
70
 
63
71
  if args.chromatography_platform == 'HRMS':
64
- tune_params_on_HRMS_data_grid(query_data=args.query_data, reference_data=args.reference_data, grid=grid, output_path=args.output_path)
72
+ tune_params_on_HRMS_data_grid(query_data=args.query_data,
73
+ reference_data=args.reference_data,
74
+ precursor_ion_mz_tolerance=precursor_ion_mz_tolerance_tmp,
75
+ ionization_mode=args.ionization_mode,
76
+ adduct=args.adduct,
77
+ grid=grid,
78
+ output_path=args.output_path)
65
79
 
66
80
  if args.chromatography_platform == 'NRMS':
67
- tune_params_on_NRMS_data_grid(query_data=args.query_data, reference_data=args.reference_data, grid=grid, output_path=args.output_path)
68
-
81
+ tune_params_on_NRMS_data_grid(query_data=args.query_data,
82
+ reference_data=args.reference_data,
83
+ grid=grid,
84
+ output_path=args.output_path)
69
85
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycompound
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Python package to perform compound identification in mass spectrometry via spectral library matching.
5
5
  Author-email: Hunter Dlugas <fy7392@wayne.edu>
6
6
  License-Expression: MIT
@@ -0,0 +1,15 @@
1
+ app.py,sha256=aQwsxwwUSCFewRkgTNr_r32GERF8Cl7h5CsnUU9DPwk,183520
2
+ pycompound/build_library.py,sha256=4S8hT8FSrS_13daCdsva5UCEU-1qy9pD7kaaG-vaxvE,6815
3
+ pycompound/plot_spectra.py,sha256=PDkJCNCK4XZ5TY5XbVMV6vO0YjkRcvFrNrrV3w73FFU,40633
4
+ pycompound/plot_spectra_CLI.py,sha256=ObaLad5Z5DmfQB-j0HSCg1mLORbYj2BM3hb5Yd0ZdDI,8395
5
+ pycompound/processing.py,sha256=NsLI994MRlDq7M13LE-1RkfAfgVjHLrLLPbu2SvArKg,10684
6
+ pycompound/similarity_measures.py,sha256=NbeVIy9DE_KWlDMXXylekjKuYVrtzbeEXbTutKFxmfU,10460
7
+ pycompound/spec_lib_matching.py,sha256=PmZNFvYIuQzL30uYyVOPKZVyVHUc8naNa6CpE94u8Do,53243
8
+ pycompound/spec_lib_matching_CLI.py,sha256=L1D1j3MDdIe7th5n47z4uyvR5tL_8lN_22kbc-J7CF8,12053
9
+ pycompound/tuning_CLI_DE.py,sha256=VRxoPLvuvE1gTRMC_lrOOK8TjINinMV_f4q69uDK2oE,9916
10
+ pycompound/tuning_CLI_grid.py,sha256=lavROwKfJSi7xLaUX0zEaphlq7sJ-1FVY3hY3tWwoV4,9735
11
+ pycompound-0.1.7.dist-info/licenses/LICENSE,sha256=fPFFlkSGg60VQWyWqTSv8yoJnpLzppzdihVWY5NKom8,1064
12
+ pycompound-0.1.7.dist-info/METADATA,sha256=CiYWK0Khu1uLQTbh9b2IwggWCoMN_CRd5klJSBGUOuA,1732
13
+ pycompound-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ pycompound-0.1.7.dist-info/top_level.txt,sha256=wFBLVrqpC07HghIU8tsEdgdvgkdOE3GN_1Gfjk-uEUc,15
15
+ pycompound-0.1.7.dist-info/RECORD,,
@@ -1,3 +1,2 @@
1
1
  app
2
- app2
3
2
  pycompound
app2.py DELETED
@@ -1,101 +0,0 @@
1
-
2
-
3
- # app.py
4
- from shiny import App, ui, render, reactive
5
- import pandas as pd
6
-
7
- # Parameters to choose from + suggested default ranges
8
- PARAMS = {
9
- "window_size_centroiding": (0.0, 0.5),
10
- "window_size_matching": (0.0, 0.5),
11
- "noise_threshold": (0.0, 0.25),
12
- "wf_mz": (0.0, 5.0),
13
- "wf_int": (0.0, 5.0),
14
- "LET_threshold": (0.0, 5.0),
15
- "entropy_dimension": (1.0, 3.0),
16
- }
17
-
18
- app_ui = ui.page_fillable(
19
- ui.layout_sidebar(
20
- ui.sidebar(
21
- ui.h3("Select parameters"),
22
- ui.input_checkbox_group(
23
- id="params",
24
- label=None,
25
- choices=list(PARAMS.keys()),
26
- selected=["window_size_centroiding", "noise_threshold"],
27
- ),
28
- ui.hr(),
29
- ui.h4("Bounds for selected parameters"),
30
- ui.output_ui("bounds_inputs"),
31
- width=360,
32
- ),
33
- )
34
- )
35
-
36
- def server(input, output, session):
37
- @output
38
- @render.ui
39
- def bounds_inputs():
40
- selected = input.params()
41
- if not selected:
42
- return ui.div(ui.em("Select one or more parameters above."))
43
-
44
- blocks = []
45
- for name in selected:
46
- lo, hi = PARAMS.get(name, (0.0, 1.0))
47
- blocks.append(
48
- ui.card(
49
- ui.card_header(name),
50
- ui.layout_columns(
51
- ui.input_numeric(f"min_{name}", "Lower", lo, step=0.001),
52
- ui.input_numeric(f"max_{name}", "Upper", hi, step=0.001),
53
- )
54
- )
55
- )
56
- return ui.div(*blocks)
57
-
58
- def _read_bounds_dict():
59
- selected = input.params()
60
- out = {}
61
- for name in selected:
62
- lo_default, hi_default = PARAMS.get(name, (0.0, 1.0))
63
- lo_id = f"min_{name}"
64
- hi_id = f"max_{name}"
65
-
66
- # Use input[...]() and guard with "in input"
67
- lo_val = input[lo_id]() if lo_id in input else lo_default
68
- hi_val = input[hi_id]() if hi_id in input else hi_default
69
-
70
- out[name] = (float(lo_val), float(hi_val))
71
- return out
72
-
73
-
74
-
75
- # Table of current bounds
76
- @output
77
- @render.data_frame
78
- def bounds_table():
79
- b = _read_bounds_dict()
80
- if not b:
81
- return pd.DataFrame(columns=["parameter", "lower", "upper"])
82
- rows = [{"parameter": k, "lower": v[0], "upper": v[1]} for k, v in b.items()]
83
- return pd.DataFrame(rows)
84
-
85
- # JSON-ish view (string) you can parse/use elsewhere
86
- @output
87
- @render.text
88
- def bounds_json():
89
- b = _read_bounds_dict()
90
- if not b:
91
- return "{}"
92
- # Pretty-print as Python dict literal for quick copy/paste
93
- lines = ["{"]
94
- for k, (lo, hi) in b.items():
95
- lines.append(f" '{k}': ({lo}, {hi}),")
96
- lines.append("}")
97
- return "\n".join(lines)
98
-
99
- app = App(app_ui, server)
100
-
101
-
@@ -1,16 +0,0 @@
1
- app.py,sha256=GdKSi0aRstcIeQulLMxANTwhScVJDNR4HlHC4bkUhXg,62350
2
- app2.py,sha256=ZTmShHRlv27_HhSzCj8JOVAPv5LLsjtgEkxt1c-7r6I,2950
3
- pycompound/build_library.py,sha256=sXG5MTJnPE7Gr8YMlLWjfMS7JQrW32lCeCGDw-DFe38,4826
4
- pycompound/plot_spectra.py,sha256=_yeHooNoJHYlTajaZ9hgUudisdWVlw1Zw1wJfV3tpqc,40632
5
- pycompound/plot_spectra_CLI.py,sha256=ObaLad5Z5DmfQB-j0HSCg1mLORbYj2BM3hb5Yd0ZdDI,8395
6
- pycompound/processing.py,sha256=q629rcDaMQMgef-4SbeV9cJnuiLXg97VT2F5AIsyqgI,10654
7
- pycompound/similarity_measures.py,sha256=NbeVIy9DE_KWlDMXXylekjKuYVrtzbeEXbTutKFxmfU,10460
8
- pycompound/spec_lib_matching.py,sha256=-4WNGUPqkAZwfrrmhdi7S3PcV-6d3O6nCe-efAtTzZA,73346
9
- pycompound/spec_lib_matching_CLI.py,sha256=qiekC52FP6ET_3NYvxUDN7km7y1OLUsd9FB4SHfne_Y,9690
10
- pycompound/tuning_CLI_DE.py,sha256=PXy95LD_jmVeWdgiMlMwEZU_KqPGqDao1skwe5U4Sfc,9147
11
- pycompound/tuning_CLI_grid.py,sha256=0XU-4ShZiZ2MQy5d0zydH0hphqXvqGtf4etl-ePNarU,8560
12
- pycompound-0.1.5.dist-info/licenses/LICENSE,sha256=fPFFlkSGg60VQWyWqTSv8yoJnpLzppzdihVWY5NKom8,1064
13
- pycompound-0.1.5.dist-info/METADATA,sha256=DIz-j3Hh4tXJMjXS-Epg_fy0auOcwYx2UUUWk3MyGN4,1732
14
- pycompound-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- pycompound-0.1.5.dist-info/top_level.txt,sha256=cd0cQe1lhTXW9uwTTM5kZgjscKvRQV8XQ41qOwedgHU,20
16
- pycompound-0.1.5.dist-info/RECORD,,