CoreMS 4.0.0__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.
- corems/__init__.py +63 -0
- corems/chroma_peak/__init__.py +0 -0
- corems/chroma_peak/calc/ChromaPeakCalc.py +480 -0
- corems/chroma_peak/calc/__init__.py +0 -0
- corems/chroma_peak/calc/subset.py +196 -0
- corems/chroma_peak/factory/__init__.py +0 -0
- corems/chroma_peak/factory/chroma_peak_classes.py +1178 -0
- corems/encapsulation/__init__.py +0 -0
- corems/encapsulation/constant.py +1283 -0
- corems/encapsulation/factory/__init__.py +0 -0
- corems/encapsulation/factory/parameters.py +392 -0
- corems/encapsulation/factory/processingSetting.py +1244 -0
- corems/encapsulation/input/__init__.py +0 -0
- corems/encapsulation/input/parameter_from_json.py +579 -0
- corems/encapsulation/output/__init__.py +0 -0
- corems/encapsulation/output/parameter_to_dict.py +142 -0
- corems/encapsulation/output/parameter_to_json.py +332 -0
- corems/mass_spectra/__init__.py +0 -0
- corems/mass_spectra/calc/GC_Calc.py +84 -0
- corems/mass_spectra/calc/GC_Deconvolution.py +558 -0
- corems/mass_spectra/calc/GC_RI_Calibration.py +44 -0
- corems/mass_spectra/calc/MZSearch.py +249 -0
- corems/mass_spectra/calc/SignalProcessing.py +656 -0
- corems/mass_spectra/calc/__init__.py +0 -0
- corems/mass_spectra/calc/lc_calc.py +5790 -0
- corems/mass_spectra/calc/lc_calc_operations.py +1127 -0
- corems/mass_spectra/factory/GC_Class.py +791 -0
- corems/mass_spectra/factory/__init__.py +0 -0
- corems/mass_spectra/factory/chromat_data.py +51 -0
- corems/mass_spectra/factory/lc_class.py +2721 -0
- corems/mass_spectra/input/__init__.py +0 -0
- corems/mass_spectra/input/andiNetCDF.py +200 -0
- corems/mass_spectra/input/boosterHDF5.py +216 -0
- corems/mass_spectra/input/brukerSolarix.py +153 -0
- corems/mass_spectra/input/brukerSolarix_utils.py +73 -0
- corems/mass_spectra/input/corems_hdf5.py +1710 -0
- corems/mass_spectra/input/massList.py +133 -0
- corems/mass_spectra/input/mzml.py +668 -0
- corems/mass_spectra/input/parserbase.py +239 -0
- corems/mass_spectra/input/rawFileReader.py +1839 -0
- corems/mass_spectra/output/__init__.py +0 -0
- corems/mass_spectra/output/export.py +2800 -0
- corems/mass_spectrum/__init__.py +0 -0
- corems/mass_spectrum/calc/AutoRecalibration.py +237 -0
- corems/mass_spectrum/calc/Calibration.py +602 -0
- corems/mass_spectrum/calc/CalibrationCalc.py +253 -0
- corems/mass_spectrum/calc/KendrickGroup.py +239 -0
- corems/mass_spectrum/calc/MassErrorPrediction.py +436 -0
- corems/mass_spectrum/calc/MassSpectrumCalc.py +303 -0
- corems/mass_spectrum/calc/MeanResolvingPowerFilter.py +212 -0
- corems/mass_spectrum/calc/NoiseCalc.py +371 -0
- corems/mass_spectrum/calc/NoiseCalc_Bayes.py +93 -0
- corems/mass_spectrum/calc/PeakPicking.py +994 -0
- corems/mass_spectrum/calc/__init__.py +0 -0
- corems/mass_spectrum/factory/MassSpectrumClasses.py +1753 -0
- corems/mass_spectrum/factory/__init__.py +0 -0
- corems/mass_spectrum/input/__init__.py +0 -0
- corems/mass_spectrum/input/baseClass.py +531 -0
- corems/mass_spectrum/input/boosterHDF5.py +161 -0
- corems/mass_spectrum/input/coremsHDF5.py +475 -0
- corems/mass_spectrum/input/massList.py +402 -0
- corems/mass_spectrum/input/numpyArray.py +133 -0
- corems/mass_spectrum/output/__init__.py +0 -0
- corems/mass_spectrum/output/export.py +841 -0
- corems/molecular_formula/__init__.py +0 -0
- corems/molecular_formula/calc/MolecularFormulaCalc.py +885 -0
- corems/molecular_formula/calc/__init__.py +0 -0
- corems/molecular_formula/factory/MolecularFormulaFactory.py +895 -0
- corems/molecular_formula/factory/__init__.py +0 -0
- corems/molecular_formula/input/__init__.py +0 -0
- corems/molecular_formula/input/masslist_ref.py +355 -0
- corems/molecular_id/__init__.py +0 -0
- corems/molecular_id/calc/ClusterFilter.py +251 -0
- corems/molecular_id/calc/MolecularFilter.py +122 -0
- corems/molecular_id/calc/SpectralSimilarity.py +632 -0
- corems/molecular_id/calc/__init__.py +0 -0
- corems/molecular_id/calc/math_distance.py +1637 -0
- corems/molecular_id/data/FAMES_REF.msp +980 -0
- corems/molecular_id/data/PNNLMetV20191015.msp +157267 -0
- corems/molecular_id/factory/EI_SQL.py +650 -0
- corems/molecular_id/factory/MolecularLookupTable.py +914 -0
- corems/molecular_id/factory/__init__.py +0 -0
- corems/molecular_id/factory/classification.py +884 -0
- corems/molecular_id/factory/lipid_molecular_metadata.py +50 -0
- corems/molecular_id/factory/molecularSQL.py +827 -0
- corems/molecular_id/factory/spectrum_search_results.py +119 -0
- corems/molecular_id/input/__init__.py +0 -0
- corems/molecular_id/input/nistMSI.py +148 -0
- corems/molecular_id/search/__init__.py +0 -0
- corems/molecular_id/search/compoundSearch.py +214 -0
- corems/molecular_id/search/database_interfaces.py +1527 -0
- corems/molecular_id/search/findOxygenPeaks.py +330 -0
- corems/molecular_id/search/lcms_spectral_search.py +348 -0
- corems/molecular_id/search/molecularFormulaSearch.py +1117 -0
- corems/molecular_id/search/priorityAssignment.py +723 -0
- corems/ms_peak/__init__.py +0 -0
- corems/ms_peak/calc/MSPeakCalc.py +1010 -0
- corems/ms_peak/calc/__init__.py +0 -0
- corems/ms_peak/factory/MSPeakClasses.py +542 -0
- corems/ms_peak/factory/__init__.py +0 -0
- corems/transient/__init__.py +0 -0
- corems/transient/calc/TransientCalc.py +362 -0
- corems/transient/calc/__init__.py +0 -0
- corems/transient/factory/TransientClasses.py +457 -0
- corems/transient/factory/__init__.py +0 -0
- corems/transient/input/__init__.py +0 -0
- corems/transient/input/brukerSolarix.py +461 -0
- corems/transient/input/midasDatFile.py +172 -0
- corems-4.0.0.dist-info/METADATA +475 -0
- corems-4.0.0.dist-info/RECORD +171 -0
- corems-4.0.0.dist-info/WHEEL +5 -0
- corems-4.0.0.dist-info/licenses/LICENSE +22 -0
- corems-4.0.0.dist-info/top_level.txt +4 -0
- examples/archive/scripts/CoreMS_tutorial.py +94 -0
- examples/archive/scripts/DI HR-MS Halogens Bruker.py +196 -0
- examples/archive/scripts/DI HR-MS MassList.py +385 -0
- examples/archive/scripts/GC-MS MetabRef.py +213 -0
- examples/archive/scripts/GC-MS NetCDF.py +217 -0
- examples/archive/scripts/HR-MS Thermo Raw 21T.py +136 -0
- examples/archive/scripts/LC-ICPMS_metal_peaks.py +297 -0
- examples/archive/scripts/LCMS-Thermo.py +460 -0
- examples/archive/scripts/LCMS_isotopes.py +283 -0
- examples/archive/scripts/MSParams_example.py +21 -0
- examples/archive/scripts/Molecular Formula Data Aggreation.py +84 -0
- examples/archive/scripts/Single Mz Search.py +69 -0
- examples/test_notebooks.py +145 -0
- ext_lib/ChemstationMSFileReader.dll +0 -0
- ext_lib/ChemstationMSFileReader.xml +126 -0
- ext_lib/RawFileReaderLicense.doc +0 -0
- ext_lib/ThermoFisher.CommonCore.BackgroundSubtraction.dll +0 -0
- ext_lib/ThermoFisher.CommonCore.BackgroundSubtraction.xml +2307 -0
- ext_lib/ThermoFisher.CommonCore.Data.dll +0 -0
- ext_lib/ThermoFisher.CommonCore.Data.xml +28974 -0
- ext_lib/ThermoFisher.CommonCore.MassPrecisionEstimator.dll +0 -0
- ext_lib/ThermoFisher.CommonCore.MassPrecisionEstimator.xml +241 -0
- ext_lib/ThermoFisher.CommonCore.RawFileReader.dll +0 -0
- ext_lib/ThermoFisher.CommonCore.RawFileReader.xml +31174 -0
- ext_lib/__init__.py +0 -0
- ext_lib/dotnet/OpenMcdf.Extensions.dll +0 -0
- ext_lib/dotnet/OpenMcdf.dll +0 -0
- ext_lib/dotnet/OpenMcdf.xml +1154 -0
- ext_lib/dotnet/System.IO.FileSystem.AccessControl.dll +0 -0
- ext_lib/dotnet/System.IO.FileSystem.AccessControl.xml +506 -0
- ext_lib/dotnet/System.Security.AccessControl.dll +0 -0
- ext_lib/dotnet/System.Security.AccessControl.xml +2043 -0
- ext_lib/dotnet/System.Security.Principal.Windows.dll +0 -0
- ext_lib/dotnet/System.Security.Principal.Windows.xml +1011 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.BackgroundSubtraction.dll +0 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.BackgroundSubtraction.xml +2307 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.Data.dll +0 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.Data.xml +29148 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.MassPrecisionEstimator.dll +0 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.MassPrecisionEstimator.xml +241 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.RawFileReader.dll +0 -0
- ext_lib/dotnet/ThermoFisher.CommonCore.RawFileReader.xml +31492 -0
- ext_lib/version +18 -0
- support_code/atom_parsers/AtomsDescription.py +359 -0
- support_code/atom_parsers/CreateAtomsDescription.py +56 -0
- support_code/nmdc/filefinder.py +90 -0
- support_code/nmdc/lipidomics/lipidomics_workflow.py +748 -0
- support_code/nmdc/lipidomics/manifest_examples.py +49 -0
- support_code/nmdc/metabolomics/gcms_workflow.py +158 -0
- support_code/nmdc/metabolomics/lcms_metabolomics_targeted_search.py +59 -0
- support_code/nmdc/metabolomics/lcms_metabolomics_workflow.py +248 -0
- support_code/nmdc/metabolomics/metabolomics_collection.py +628 -0
- support_code/nmdc/metadata/dms_api.py +42 -0
- support_code/nmdc/nom/archived_scripts/nmdc_metadata_gen.py +288 -0
- support_code/nmdc/nom/archived_scripts/nom_grow_workflow.py +209 -0
- support_code/nmdc/nom/nom_workflow.py +312 -0
- support_code/windows_only_importers/BrukerCompassXtract.py +180 -0
- support_code/windows_only_importers/ThermoMSFileReader.py +405 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# This file contains functions for subsetting dataframes that contain mass feature data.
|
|
2
|
+
# This is based on the deimos package, found here: https://github.com/pnnl/deimos/blob/master/deimos/subset.py with some modifications.
|
|
3
|
+
|
|
4
|
+
import multiprocessing as mp
|
|
5
|
+
from functools import partial
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
class MultiSamplePartitions:
|
|
11
|
+
'''
|
|
12
|
+
Generator object that will lazily build and return each partition constructed
|
|
13
|
+
from multiple samples.
|
|
14
|
+
|
|
15
|
+
Attributes
|
|
16
|
+
----------
|
|
17
|
+
features : :obj:`~pandas.DataFrame`
|
|
18
|
+
Input feature coordinates and intensities.
|
|
19
|
+
split_on : str
|
|
20
|
+
Dimension to partition the data.
|
|
21
|
+
size : int
|
|
22
|
+
Target partition size.
|
|
23
|
+
tol : float
|
|
24
|
+
Largest allowed distance between unique `split_on` observations.
|
|
25
|
+
n_partitions : int
|
|
26
|
+
Number of partitions in the data.
|
|
27
|
+
|
|
28
|
+
'''
|
|
29
|
+
|
|
30
|
+
def __init__(self,
|
|
31
|
+
features,
|
|
32
|
+
split_on: str = 'mz',
|
|
33
|
+
size: int = 500,
|
|
34
|
+
tol: float = 25E-6,
|
|
35
|
+
relative: bool = False):
|
|
36
|
+
'''
|
|
37
|
+
Initialize :obj:`~deimos.subset.Partitions` instance.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
features : :obj:`~pandas.DataFrame`
|
|
42
|
+
Input feature coordinates and intensities.
|
|
43
|
+
split_on : str
|
|
44
|
+
Dimension to partition the data.
|
|
45
|
+
size : int
|
|
46
|
+
Target partition size.
|
|
47
|
+
tol : float
|
|
48
|
+
Largest allowed distance between unique `split_on` observations.
|
|
49
|
+
|
|
50
|
+
'''
|
|
51
|
+
if not isinstance(split_on, str):
|
|
52
|
+
raise TypeError(f"Expected 'split_on' to be a string, got {type(split_on).__name__}")
|
|
53
|
+
if not isinstance(size, int):
|
|
54
|
+
raise TypeError(f"Expected 'size' to be an integer, got {type(size).__name__}")
|
|
55
|
+
if not isinstance(tol, float):
|
|
56
|
+
raise TypeError(f"Expected 'tol' to be a float, got {type(tol).__name__}")
|
|
57
|
+
if not isinstance(relative, bool):
|
|
58
|
+
raise TypeError(f"Expected 'relative' to be a boolean, got {type(relative).__name__}")
|
|
59
|
+
|
|
60
|
+
self.features = features
|
|
61
|
+
self.split_on = split_on
|
|
62
|
+
self.size = size
|
|
63
|
+
self.tol = tol
|
|
64
|
+
self.relative = relative
|
|
65
|
+
|
|
66
|
+
self._compute_splits()
|
|
67
|
+
|
|
68
|
+
def _compute_splits(self):
|
|
69
|
+
'''
|
|
70
|
+
Determines data splits for partitioning.
|
|
71
|
+
|
|
72
|
+
'''
|
|
73
|
+
|
|
74
|
+
self.counter = 0
|
|
75
|
+
|
|
76
|
+
idx = self.features.groupby(by=self.split_on).size().sort_index()
|
|
77
|
+
|
|
78
|
+
counts = idx.values
|
|
79
|
+
idx = idx.index
|
|
80
|
+
|
|
81
|
+
if self.relative:
|
|
82
|
+
dxs = np.diff(idx) / idx[:-1]
|
|
83
|
+
else:
|
|
84
|
+
dxs = np.diff(idx)
|
|
85
|
+
|
|
86
|
+
# if relative, convert tol to absolute
|
|
87
|
+
bins = []
|
|
88
|
+
current_count = counts[0]
|
|
89
|
+
current_bin = [idx[0]]
|
|
90
|
+
self._counts = []
|
|
91
|
+
|
|
92
|
+
for i, dx in zip(range(1, len(idx)), dxs):
|
|
93
|
+
if (current_count + counts[i] <= self.size) or (dx <= self.tol):
|
|
94
|
+
current_bin.append(idx[i])
|
|
95
|
+
current_count += counts[i]
|
|
96
|
+
|
|
97
|
+
else:
|
|
98
|
+
bins.append(np.array(current_bin))
|
|
99
|
+
self._counts.append(current_count)
|
|
100
|
+
|
|
101
|
+
current_bin = [idx[i]]
|
|
102
|
+
current_count = counts[i]
|
|
103
|
+
|
|
104
|
+
# Add last unadded bin
|
|
105
|
+
bins.append(np.array(current_bin))
|
|
106
|
+
self._counts.append(current_count)
|
|
107
|
+
|
|
108
|
+
self.bounds = np.array([[x.min(), x.max()] for x in bins])
|
|
109
|
+
|
|
110
|
+
# Number of partitions in the data
|
|
111
|
+
self.n_partitions = len(bins)
|
|
112
|
+
|
|
113
|
+
def __iter__(self):
|
|
114
|
+
return self
|
|
115
|
+
|
|
116
|
+
def __next__(self):
|
|
117
|
+
if self.counter < len(self.bounds):
|
|
118
|
+
q = '({} >= {}) & ({} <= {})'.format(self.split_on,
|
|
119
|
+
self.bounds[self.counter][0],
|
|
120
|
+
self.split_on,
|
|
121
|
+
self.bounds[self.counter][1])
|
|
122
|
+
|
|
123
|
+
subset = self.features.query(q)
|
|
124
|
+
|
|
125
|
+
self.counter += 1
|
|
126
|
+
if len(subset.index) > 1:
|
|
127
|
+
return subset
|
|
128
|
+
else:
|
|
129
|
+
return None
|
|
130
|
+
|
|
131
|
+
raise StopIteration
|
|
132
|
+
|
|
133
|
+
def map(self, func, processes=1, **kwargs):
|
|
134
|
+
'''
|
|
135
|
+
Maps `func` to each partition, then returns the combined result.
|
|
136
|
+
|
|
137
|
+
Parameters
|
|
138
|
+
----------
|
|
139
|
+
func : function
|
|
140
|
+
Function to apply to partitions.
|
|
141
|
+
processes : int
|
|
142
|
+
Number of parallel processes. If less than 2, a serial mapping is
|
|
143
|
+
applied.
|
|
144
|
+
kwargs
|
|
145
|
+
Keyword arguments passed to `func`.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
:obj:`~pandas.DataFrame`
|
|
150
|
+
Combined result of `func` applied to partitions.
|
|
151
|
+
|
|
152
|
+
'''
|
|
153
|
+
|
|
154
|
+
# Serial
|
|
155
|
+
if processes < 2:
|
|
156
|
+
result = [func(x, **kwargs) for x in self]
|
|
157
|
+
|
|
158
|
+
# Parallel
|
|
159
|
+
else:
|
|
160
|
+
with mp.Pool(processes=processes) as p:
|
|
161
|
+
result = list(p.imap(partial(func, **kwargs), self))
|
|
162
|
+
|
|
163
|
+
# Add partition index
|
|
164
|
+
for i in range(len(result)):
|
|
165
|
+
if result[i] is not None:
|
|
166
|
+
result[i]['partition_idx'] = i
|
|
167
|
+
|
|
168
|
+
# Combine partitions
|
|
169
|
+
return pd.concat(result, ignore_index=True)
|
|
170
|
+
|
|
171
|
+
def multi_sample_partition(features, split_on='mz', size=500, tol=25E-6, relative=True):
|
|
172
|
+
'''
|
|
173
|
+
Partitions data along a given dimension. For use with features across
|
|
174
|
+
multiple samples, e.g. in alignment.
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
features : :obj:`~pandas.DataFrame`
|
|
179
|
+
Input feature coordinates and intensities.
|
|
180
|
+
split_on : str
|
|
181
|
+
Dimension to partition the data.
|
|
182
|
+
size : int
|
|
183
|
+
Target partition size.
|
|
184
|
+
tol : float
|
|
185
|
+
Largest allowed distance between unique `split_on` observations.
|
|
186
|
+
relative : bool
|
|
187
|
+
If `True`, the `tol` parameter is interpreted as a relative tolerance.
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
-------
|
|
191
|
+
:obj:`~deimos.subset.Partitions`
|
|
192
|
+
A generator object that will lazily build and return each partition.
|
|
193
|
+
|
|
194
|
+
'''
|
|
195
|
+
|
|
196
|
+
return MultiSamplePartitions(features, split_on, size, tol, relative)
|
|
File without changes
|