88from pathlib import Path
99
1010from corems .encapsulation .constant import Labels
11- from corems .encapsulation .factory .parameters import MSParameters
11+ from corems .encapsulation .factory .parameters import MSParameters , reset_ms_parameters
1212from corems .mass_spectra .input import rawFileReader
1313from corems .mass_spectra .input .andiNetCDF import ReadAndiNetCDF
1414from corems .mass_spectra .input .boosterHDF5 import ReadHDF_BoosterMassSpectra
2121from corems .mass_spectrum .input .massList import ReadCoremsMasslist , ReadMassList
2222from corems .mass_spectrum .input .numpyArray import ms_from_array_profile
2323
24-
2524def test_andi_netcdf_gcms ():
2625 file_path = (
2726 Path .cwd () / "tests/tests_data/gcms/" / "GCMS_FAMES_01_GCMS-01_20191023.cdf"
@@ -93,6 +92,8 @@ def test_import_lcms_from_transient():
9392 assert len (lcms .tic ) > 0
9493 assert len (lcms ) > 0
9594
95+ # Return the MSParameters to the default values
96+ reset_ms_parameters ()
9697
9798def test_import_transient (mass_spectrum_ftms ):
9899 # This test is using the fixture mass_spectrum_ftms
@@ -131,7 +132,6 @@ def test_import_corems_mass_list():
131132 Path .cwd () / "tests/tests_data/ftms/ESI_NEG_SRFA_COREMS_withdupes.csv"
132133 )
133134
134- # TODO KRH: We should be able to remove these parameters after MR https://code.emsl.pnl.gov/mass-spectrometry/corems/-/merge_requests/122
135135 MSParameters .mass_spectrum .noise_threshold_method = "relative_abundance"
136136 MSParameters .mass_spectrum .noise_threshold_min_relative_abundance = 0.1
137137
@@ -158,6 +158,9 @@ def test_import_corems_mass_list():
158158 assert mass_spectra [0 ].to_dataframe ().shape [0 ] > 0
159159 assert round (mass_spectra [0 ][0 ].mz_exp , 0 ) == 227
160160
161+ # Return the MSParameters to the default values
162+ reset_ms_parameters ()
163+
161164
162165def test_import_thermo_profile_mass_list ():
163166 file_location = (
@@ -181,7 +184,6 @@ def test_import_thermo_profile_mass_list():
181184
182185
183186def test_import_numpy_array_profile (mass_spectrum_ftms ):
184- #TODO KRH: This test is failing to create a replicated mass spectrum as the original one
185187 mass_spectrum_new = ms_from_array_profile (
186188 mz = mass_spectrum_ftms .mz_exp_profile ,
187189 abundance = mass_spectrum_ftms .abundance_profile ,
@@ -207,7 +209,6 @@ def test_import_maglab_pks():
207209
208210 polarity = - 1
209211
210- # TODO KRH: We should be able to remove these parameters after MR https://code.emsl.pnl.gov/mass-spectrometry/corems/-/merge_requests/122
211212 MSParameters .mass_spectrum .noise_threshold_method = "relative_abundance"
212213 MSParameters .mass_spectrum .noise_threshold_min_relative_abundance = 0.1
213214
@@ -216,6 +217,9 @@ def test_import_maglab_pks():
216217 assert mass_spectrum .to_dataframe ().shape [0 ] > 0
217218 assert round (mass_spectrum [0 ].mz_exp , 0 ) == 131
218219
220+ # Return the MSParameters to the default values
221+ reset_ms_parameters ()
222+
219223
220224def test_import_xml_mass_list ():
221225
@@ -232,6 +236,9 @@ def test_import_xml_mass_list():
232236 assert len (mass_spectrum )> 30_000
233237 # check the 100th peak is as expected
234238 assert round (mass_spectrum .mz_exp [100 ],3 ) == 118.049
239+
240+ # Return the MSParameters to the default values
241+ reset_ms_parameters ()
235242
236243
237244def test_import_xml_mass_list ():
@@ -250,6 +257,9 @@ def test_import_xml_mass_list():
250257 # check the 100th peak is as expected
251258 assert round (mass_spectrum .mz_exp [100 ],3 ) == 118.049
252259
260+ # Return the MSParameters to the default values
261+ reset_ms_parameters ()
262+
253263
254264def test_import_mass_list ():
255265 file_location = Path .cwd () / "tests/tests_data/ftms/" / "NEG_ESI_SRFA_CoreMS.xlsx"
@@ -286,7 +296,6 @@ def test_import_mass_list():
286296
287297
288298def test_import_thermo_average ():
289- #TODO KRH: Revisit this test to check that assertions are implemented at each step
290299 file_location = Path .cwd () / "tests/tests_data/ftms/" / "SRFA_NEG_ESI_ORB.raw"
291300
292301 # creates the parser obj
@@ -299,6 +308,7 @@ def test_import_thermo_average():
299308 mass_spectrum .parameters .mass_spectrum .noise_threshold_method = "relative_abundance"
300309 mass_spectrum .parameters .mass_spectrum .noise_threshold_min_relative_abundance = 1
301310 mass_spectrum .process_mass_spec ()
311+ assert len (mass_spectrum ) == 762
302312
303313 # sums scans in selected range
304314 parser .chromatogram_settings .scans = (1 , 1 )
@@ -307,6 +317,7 @@ def test_import_thermo_average():
307317 mass_spectrum .parameters .mass_spectrum .noise_threshold_method = "relative_abundance"
308318 mass_spectrum .parameters .mass_spectrum .noise_threshold_min_relative_abundance = 1
309319 mass_spectrum .process_mass_spec ()
320+ assert len (mass_spectrum ) == 953
310321
311322 parser .chromatogram_settings .scans = [1 ]
312323
@@ -316,5 +327,5 @@ def test_import_thermo_average():
316327 mass_spectrum .plot_mz_domain_profile ()
317328 mass_spectrum .plot_profile_and_noise_threshold ()
318329
319- assert mass_spectrum .to_dataframe ().shape [0 ] > 0
320- assert round (mass_spectrum [0 ].mz_exp , 0 ) == 101
330+ assert mass_spectrum .to_dataframe ().shape [0 ] == 1518
331+ assert round (mass_spectrum [0 ].mz_exp , 0 ) == 100
0 commit comments