99
1010from corems .mass_spectra .input .corems_hdf5 import ReadCoreMSHDFMassSpectra
1111from corems .mass_spectra .output .export import LipidomicsExport
12- from corems .molecular_id .search .database_interfaces import MetabRefLCInterface
1312
14- # from metaMS.lipid_metadata_prepper import get_lipid_library, _to_flashentropy
13+ from metaMS .lipid_metadata_prepper import get_lipid_library , _to_flashentropy
1514from metaMS .lcms_functions import (
1615 instantiate_lcms_obj ,
1716 set_params_on_lcms_obj ,
@@ -41,9 +40,8 @@ class LipidomicsWorkflowParameters:
4140 The directory where the output files will be stored
4241 corems_toml_path : str
4342 The path to the corems configuration file
44- db_location : str | None
43+ db_location : str
4544 The path to the local sqlite database used for searching lipid ms2 spectra
46- No longer used, only present for compatibility
4745 scan_translator_path : str
4846 The path to the scan translator file, optional
4947 cores : int
@@ -166,7 +164,7 @@ def run_lipid_sp_ms1(file_in, out_path, params_toml, scan_translator):
166164
167165 return mz_dict
168166
169- def prep_metadata (mz_dicts , out_dir ):
167+ def prep_metadata (mz_dicts , out_dir , db_location ):
170168 """Prepare metadata for ms2 spectral search
171169
172170 Parameters
@@ -175,6 +173,8 @@ def prep_metadata(mz_dicts, out_dir):
175173 List of dicts with keys "positive" and "negative" and values of lists of precursor mzs
176174 out_dir : Path
177175 Path to output directory
176+ db_location : str
177+ Path to lipid database
178178
179179 Returns
180180 -------
@@ -194,10 +194,10 @@ def prep_metadata(mz_dicts, out_dir):
194194 metadata ["mzs" ].update (d )
195195
196196 print ("Preparing negative lipid library" )
197- metabref = MetabRefLCInterface ()
198197
199198 if metadata ["mzs" ]["negative" ] is not None :
200- metabref_negative , lipidmetadata_negative = metabref .get_lipid_library (
199+ metabref_negative , lipidmetadata_negative = get_lipid_library (
200+ db_location = db_location ,
201201 mz_list = metadata ["mzs" ]["negative" ],
202202 polarity = "negative" ,
203203 mz_tol_ppm = 5 ,
@@ -211,8 +211,6 @@ def prep_metadata(mz_dicts, out_dir):
211211 "precursor_ions_removal_da" : None ,
212212 "noise_threshold" : 0 ,
213213 },
214- api_attempts = 50 ,
215- api_delay = 10
216214 )
217215 metadata ["fe" ]["negative" ] = metabref_negative
218216 metadata ["molecular_metadata" ].update (lipidmetadata_negative )
@@ -223,7 +221,8 @@ def prep_metadata(mz_dicts, out_dir):
223221
224222 print ("Preparing positive lipid library" )
225223 if metadata ["mzs" ]["positive" ] is not None :
226- metabref_positive , lipidmetadata_positive = metabref .get_lipid_library (
224+ metabref_positive , lipidmetadata_positive = get_lipid_library (
225+ db_location = db_location ,
227226 mz_list = metadata ["mzs" ]["positive" ],
228227 polarity = "positive" ,
229228 mz_tol_ppm = 5 ,
@@ -237,8 +236,6 @@ def prep_metadata(mz_dicts, out_dir):
237236 "precursor_ions_removal_da" : None ,
238237 "noise_threshold" : 0 ,
239238 },
240- api_attempts = 50 ,
241- api_delay = 10
242239 )
243240 metadata ["fe" ]["positive" ] = metabref_positive
244241 metadata ["molecular_metadata" ].update (lipidmetadata_positive )
@@ -318,11 +315,9 @@ def process_ms2(myLCMSobj, metadata, scan_translator):
318315 ]
319316 ms2_scans_oi_lr .extend (ms2_scans_oi_lri )
320317 # Perform search on low res scans
321- metabref = MetabRefLCInterface ()
322-
323318 if len (ms2_scans_oi_lr ) > 0 :
324319 # Recast the flashentropy search database to low resolution
325- fe_search_lr = metabref . _to_flashentropy (
320+ fe_search_lr = _to_flashentropy (
326321 metabref_lib = fe_search ,
327322 normalize = True ,
328323 fe_kwargs = {
@@ -385,9 +380,8 @@ def run_lcms_lipidomics_workflow(
385380 Path to output directory
386381 corems_toml_path : str
387382 Path to corems toml file
388- db_location : str or None
383+ db_location : str
389384 Path to lipid database
390- No longer used, only present for compatibility
391385 scan_translator_path : str
392386 Path to scan translator file
393387 cores : int
@@ -406,6 +400,7 @@ def run_lcms_lipidomics_workflow(
406400 lipid_workflow_params = LipidomicsWorkflowParameters (
407401 file_paths = file_paths .split ("," ),
408402 output_directory = output_directory ,
403+ db_location = db_location ,
409404 scan_translator_path = scan_translator_path ,
410405 corems_toml_path = corems_toml_path ,
411406 cores = cores ,
@@ -455,7 +450,7 @@ def run_lcms_lipidomics_workflow(
455450
456451 # Prepare metadata for searching
457452 click .echo ("Preparing metadata for ms2 spectral search" )
458- metadata = prep_metadata (mz_dicts , out_dir )
453+ metadata = prep_metadata (mz_dicts , out_dir , lipid_workflow_params . db_location )
459454 del mz_dicts
460455
461456 # Run ms2 spectral search and export final results
0 commit comments