def expr_list(pyms_datadir): with tempfile.TemporaryDirectory() as tmpdir: outputdir = pathlib.Path(tmpdir) # Create experiment files for jcamp_file in eley_codes: im = build_intensity_matrix_i( JCAMP_reader(pyms_datadir / f"{jcamp_file}.JDX")) # Intensity matrix size (scans, masses) n_scan, n_mz = im.size # noise filter and baseline correct for ii in range(n_mz): ic = im.get_ic_at_index(ii) ic_smooth = savitzky_golay(ic) ic_bc = tophat(ic_smooth, struct="1.5m") im.set_ic_at_index(ii, ic_bc) peak_list = BillerBiemann(im, points=9, scans=2) print('#') apl = rel_threshold(peak_list, 2) new_peak_list = num_ions_threshold(apl, 3, 3000) print('#') # ignore TMS ions and set mass range for peak in new_peak_list: peak.crop_mass(50, 400) peak.null_mass(73) peak.null_mass(147) # find area area = peak_sum_area(im, peak) peak.area = area area_dict = peak_top_ion_areas(im, peak) peak.ion_areas = area_dict expr = Experiment(jcamp_file, new_peak_list) # set time range for all experiments expr.sele_rt_range(["6.5m", "21m"]) print('#') expr.dump(outputdir / f"{jcamp_file}.expr") print('#') # Load experiments expr_list = [] for expr_code in eley_codes: expr = load_expr(outputdir / f"{expr_code}.expr") assert isinstance(expr, Experiment) expr_list.append(expr) yield expr_list
for peak in peak_list: peak.crop_mass(51, 540) peak.null_mass(73) peak.null_mass(147) area = peak_sum_area(im, peak) peak.area = area # Create an |Experiment|. # In[8]: from pyms.Experiment import Experiment expr = Experiment("a0806_077", peak_list) # Set the time range for all Experiments # In[9]: expr.sele_rt_range(["6.5m", "21m"]) # Save the experiment to disk. # In[10]: expr.dump(output_directory / "experiments" / "a0806_077.expr") #
# ignore TMS ions and use same mass range for all experiments for peak in peak_list: peak.crop_mass(50, 540) peak.null_mass(73) peak.null_mass(147) # find peak areas area = peak_sum_area(im, peak) peak.area = area area_dict = peak_top_ion_areas(im, peak) peak.ion_areas = area_dict # create an experiment expr = Experiment(expr_code, peak_list) # use same retention time range for all experiments lo_rt_limit = "6.5m" hi_rt_limit = "21m" print( f"\t -> Selecting retention time range between '{lo_rt_limit}' and '{hi_rt_limit}'" ) expr.sele_rt_range([lo_rt_limit, hi_rt_limit]) # store processed data as experiment object output_file = "output/" + expr_code + ".expr" print(f"\t -> Saving the result as '{output_file}'") expr.dump(output_file)