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,460 @@
|
|
|
1
|
+
__author__ = "Yuri E. Corilo"
|
|
2
|
+
__date__ = "Jun 09, 20201"
|
|
3
|
+
|
|
4
|
+
import clr
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
import sys
|
|
7
|
+
import site
|
|
8
|
+
|
|
9
|
+
from matplotlib import pyplot as plt
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class ScanDependentDetail:
|
|
13
|
+
scanIndex: int
|
|
14
|
+
filterString: int
|
|
15
|
+
precursorMass: float
|
|
16
|
+
isolationWidth: float
|
|
17
|
+
activation: str
|
|
18
|
+
collision_energy: float
|
|
19
|
+
tic: float
|
|
20
|
+
rt: float
|
|
21
|
+
mz: list
|
|
22
|
+
abundance: list
|
|
23
|
+
|
|
24
|
+
controllerType = {-1: 'No device',
|
|
25
|
+
0: 'MS',
|
|
26
|
+
1: 'Analog',
|
|
27
|
+
2: 'A/D card',
|
|
28
|
+
3: 'PDA',
|
|
29
|
+
4: 'UV',
|
|
30
|
+
'No device': -1,
|
|
31
|
+
'MS': 0,
|
|
32
|
+
'Analog': 1,
|
|
33
|
+
'A/D card': 2,
|
|
34
|
+
'PDA': 3,
|
|
35
|
+
'UV': 4}
|
|
36
|
+
|
|
37
|
+
massAnalyzerType = {'ITMS': 0,
|
|
38
|
+
'TQMS': 1,
|
|
39
|
+
'SQMS': 2,
|
|
40
|
+
'TOFMS': 3,
|
|
41
|
+
'FTMS': 4,
|
|
42
|
+
'Sector': 5,
|
|
43
|
+
0: 'ITMS',
|
|
44
|
+
1: 'TQMS',
|
|
45
|
+
2: 'SQMS',
|
|
46
|
+
3: 'TOFMS',
|
|
47
|
+
4: 'FTMS',
|
|
48
|
+
5: 'Sector'}
|
|
49
|
+
|
|
50
|
+
activationType = {'CID': 0,
|
|
51
|
+
'MPD': 1,
|
|
52
|
+
'ECD': 2,
|
|
53
|
+
'PQD': 3,
|
|
54
|
+
'ETD': 4,
|
|
55
|
+
'HCD': 5,
|
|
56
|
+
'Any activation type': 6,
|
|
57
|
+
'SA': 7,
|
|
58
|
+
'PTR': 8,
|
|
59
|
+
'NETD': 9,
|
|
60
|
+
'NPTR': 10,
|
|
61
|
+
0: 'CID',
|
|
62
|
+
1: 'MPD',
|
|
63
|
+
2: 'ECD',
|
|
64
|
+
3: 'PQD',
|
|
65
|
+
4: 'ETD',
|
|
66
|
+
5: 'HCD',
|
|
67
|
+
6: 'Any activation type',
|
|
68
|
+
7: 'SA',
|
|
69
|
+
8: 'PTR',
|
|
70
|
+
9: 'NETD',
|
|
71
|
+
10: 'NPTR'}
|
|
72
|
+
|
|
73
|
+
detectorType = {'CID': 0,
|
|
74
|
+
'PQD': 1,
|
|
75
|
+
'ETD': 2,
|
|
76
|
+
'HCD': 3,
|
|
77
|
+
0: 'CID',
|
|
78
|
+
1: 'PQD',
|
|
79
|
+
2: 'ETD',
|
|
80
|
+
3: 'HCD'}
|
|
81
|
+
|
|
82
|
+
scanType = {'ScanTypeFull': 0,
|
|
83
|
+
'ScanTypeSIM': 1,
|
|
84
|
+
'ScanTypeZoom': 2,
|
|
85
|
+
'ScanTypeSRM': 3,
|
|
86
|
+
0: 'ScanTypeFull',
|
|
87
|
+
1: 'ScanTypeSIM',
|
|
88
|
+
2: 'ScanTypeZoom',
|
|
89
|
+
3: 'ScanTypeSRM'}
|
|
90
|
+
|
|
91
|
+
scanType = {'ScanTypeFull': 0,
|
|
92
|
+
'ScanTypeSIM': 1,
|
|
93
|
+
'ScanTypeZoom': 2,
|
|
94
|
+
'ScanTypeSRM': 3,
|
|
95
|
+
0: 'ScanTypeFull',
|
|
96
|
+
1: 'ScanTypeSIM',
|
|
97
|
+
2: 'ScanTypeZoom',
|
|
98
|
+
3: 'ScanTypeSRM'}
|
|
99
|
+
|
|
100
|
+
controllerType = {-1: 'No device',
|
|
101
|
+
0: 'MS',
|
|
102
|
+
1: 'Analog',
|
|
103
|
+
2: 'A/D card',
|
|
104
|
+
3: 'PDA',
|
|
105
|
+
4: 'UV',
|
|
106
|
+
'No device': -1,
|
|
107
|
+
'MS': 0,
|
|
108
|
+
'Analog': 1,
|
|
109
|
+
'A/D card': 2,
|
|
110
|
+
'PDA': 3,
|
|
111
|
+
'UV': 4}
|
|
112
|
+
|
|
113
|
+
sys.path.append(site.getsitepackages()[0] + "/ext_lib")
|
|
114
|
+
sys.path.append("ext_lib")
|
|
115
|
+
|
|
116
|
+
clr.AddReference("ThermoFisher.CommonCore.RawFileReader")
|
|
117
|
+
clr.AddReference("ThermoFisher.CommonCore.Data")
|
|
118
|
+
clr.AddReference("ThermoFisher.CommonCore.MassPrecisionEstimator")
|
|
119
|
+
|
|
120
|
+
clr.AddReference("ThermoFisher.CommonCore.RawFileReader")
|
|
121
|
+
|
|
122
|
+
from ThermoFisher.CommonCore.RawFileReader import RawFileReaderAdapter
|
|
123
|
+
from ThermoFisher.CommonCore.Data.FilterEnums import MSOrderType
|
|
124
|
+
from ThermoFisher.CommonCore.Data.Business import ChromatogramTraceSettings, TraceType, MassOptions
|
|
125
|
+
from ThermoFisher.CommonCore.Data.Business import ChromatogramSignal, Range
|
|
126
|
+
from ThermoFisher.CommonCore.Data.Interfaces import IChromatogramSettings
|
|
127
|
+
from ThermoFisher.CommonCore.Data import ToleranceUnits, Extensions
|
|
128
|
+
|
|
129
|
+
dirpath = "C:\\Users\\eber373\\Desktop\\Data\\LCMS\\RAW Files\\HILIC"
|
|
130
|
+
filepath = "\\NEG\\LCMS_5191_CapDev_HILIC_Mix1_NEG_30Apr2021.raw"
|
|
131
|
+
iRawDataPlus = RawFileReaderAdapter.FileFactory(dirpath + filepath)
|
|
132
|
+
|
|
133
|
+
print("FileName", iRawDataPlus.FileName)
|
|
134
|
+
|
|
135
|
+
print("InstrumentCount", iRawDataPlus.InstrumentCount)
|
|
136
|
+
|
|
137
|
+
device = iRawDataPlus.GetInstrumentType(0)
|
|
138
|
+
|
|
139
|
+
print("device", controllerType.get(device))
|
|
140
|
+
|
|
141
|
+
print()
|
|
142
|
+
|
|
143
|
+
controler = (iRawDataPlus.SelectInstrument(controllerType.get('MS'), 1))
|
|
144
|
+
|
|
145
|
+
fileHeader = iRawDataPlus.FileHeader
|
|
146
|
+
|
|
147
|
+
print("CreationDate", fileHeader.CreationDate)
|
|
148
|
+
|
|
149
|
+
print("WhoCreatedId", fileHeader.WhoCreatedId)
|
|
150
|
+
|
|
151
|
+
print("Revision", fileHeader.Revision)
|
|
152
|
+
|
|
153
|
+
print()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
instrumentData = iRawDataPlus.GetInstrumentData()
|
|
157
|
+
|
|
158
|
+
print("Model", instrumentData.Model)
|
|
159
|
+
|
|
160
|
+
print("Name", instrumentData.Name)
|
|
161
|
+
|
|
162
|
+
print("SerialNumber", instrumentData.SerialNumber)
|
|
163
|
+
|
|
164
|
+
print("SoftwareVersion", instrumentData.SoftwareVersion)
|
|
165
|
+
|
|
166
|
+
print("Flags", instrumentData.Flags)
|
|
167
|
+
|
|
168
|
+
print("AxisLabelX", instrumentData.AxisLabelX)
|
|
169
|
+
|
|
170
|
+
print("AxisLabelY", instrumentData.AxisLabelY)
|
|
171
|
+
|
|
172
|
+
print()
|
|
173
|
+
|
|
174
|
+
iRunHeader = iRawDataPlus.RunHeaderEx
|
|
175
|
+
|
|
176
|
+
print("SpectraCount", iRunHeader.SpectraCount)
|
|
177
|
+
|
|
178
|
+
print("FirstSpectrum", iRunHeader.FirstSpectrum)
|
|
179
|
+
|
|
180
|
+
print("LastSpectrum", iRunHeader.LastSpectrum)
|
|
181
|
+
|
|
182
|
+
print("StartTime", iRunHeader.StartTime)
|
|
183
|
+
|
|
184
|
+
print("EndTime", iRunHeader.EndTime)
|
|
185
|
+
|
|
186
|
+
print("LowMass", iRunHeader.LowMass)
|
|
187
|
+
|
|
188
|
+
print("HighMass", iRunHeader.HighMass)
|
|
189
|
+
|
|
190
|
+
print("MassResolution", iRunHeader.MassResolution)
|
|
191
|
+
|
|
192
|
+
print(iRunHeader.FirstSpectrum, iRunHeader.LastSpectrum)
|
|
193
|
+
|
|
194
|
+
def plot_chroma(x, y, ax=None, c='g'):
|
|
195
|
+
|
|
196
|
+
if ax is None:
|
|
197
|
+
ax = plt.gca()
|
|
198
|
+
|
|
199
|
+
ax.plot(x, y, color=c)
|
|
200
|
+
|
|
201
|
+
ax.set_xlabel("$\t{RT}$", fontsize=12)
|
|
202
|
+
ax.set_ylabel('TIC', fontsize=12)
|
|
203
|
+
ax.tick_params(axis='both', which='major', labelsize=12)
|
|
204
|
+
|
|
205
|
+
ax.axes.spines['top'].set_visible(False)
|
|
206
|
+
ax.axes.spines['right'].set_visible(False)
|
|
207
|
+
|
|
208
|
+
# ax.get_yaxis().set_visible(False)
|
|
209
|
+
# ax.spines['left'].set_visible(False)
|
|
210
|
+
return ax
|
|
211
|
+
|
|
212
|
+
def get_centroid(scan, iRawDataPlus):
|
|
213
|
+
|
|
214
|
+
centroidStream = iRawDataPlus.GetCentroidStream(scan, False)
|
|
215
|
+
|
|
216
|
+
noises = list(centroidStream.Noises)
|
|
217
|
+
baselines = centroidStream.Baselines
|
|
218
|
+
|
|
219
|
+
resolutions = list(centroidStream.Resolutions)
|
|
220
|
+
|
|
221
|
+
coefficientsCount = centroidStream.CoefficientsCount
|
|
222
|
+
coefficients = centroidStream.Coefficients
|
|
223
|
+
|
|
224
|
+
abundance = list(centroidStream.Intensities)
|
|
225
|
+
mz = list(centroidStream.Masses)
|
|
226
|
+
|
|
227
|
+
return mz, abundance
|
|
228
|
+
|
|
229
|
+
def get_profile(scan, iRawDataPlus, scanStatistics):
|
|
230
|
+
|
|
231
|
+
segmentedStream = iRawDataPlus.GetSegmentedScanFromScanNumber(scan, scanStatistics)
|
|
232
|
+
|
|
233
|
+
segmentCount = (segmentedStream.SegmentCount)
|
|
234
|
+
|
|
235
|
+
ms_length = segmentedStream.SegmentLengths[0]
|
|
236
|
+
|
|
237
|
+
abundance = list(segmentedStream.Intensities)
|
|
238
|
+
|
|
239
|
+
mz = (list(segmentedStream.Positions))
|
|
240
|
+
|
|
241
|
+
flags = segmentedStream.Flags
|
|
242
|
+
|
|
243
|
+
massRanges = segmentedStream.MassRanges
|
|
244
|
+
|
|
245
|
+
# print([i.High for i in massRanges])
|
|
246
|
+
return mz, abundance
|
|
247
|
+
|
|
248
|
+
def plot_ms(x, y, ax=None, c='g', is_centroid=True):
|
|
249
|
+
|
|
250
|
+
if ax is None:
|
|
251
|
+
ax = plt.gca()
|
|
252
|
+
|
|
253
|
+
if is_centroid:
|
|
254
|
+
markerline_a, stemlines_a, baseline_a = ax.stem(x, y, linefmt='-', markerfmt=" ")
|
|
255
|
+
plt.setp(markerline_a, 'color', c, 'linewidth', 2)
|
|
256
|
+
plt.setp(stemlines_a, 'color', c, 'linewidth', 2)
|
|
257
|
+
plt.setp(baseline_a, 'color', c, 'linewidth', 2)
|
|
258
|
+
else:
|
|
259
|
+
ax.plot(x, y)
|
|
260
|
+
|
|
261
|
+
ax.set_xlabel("$\t{m/z}$", fontsize=12)
|
|
262
|
+
ax.set_ylabel('Abundance', fontsize=12)
|
|
263
|
+
ax.tick_params(axis='both', which='major', labelsize=12)
|
|
264
|
+
|
|
265
|
+
ax.axes.spines['top'].set_visible(False)
|
|
266
|
+
ax.axes.spines['right'].set_visible(False)
|
|
267
|
+
|
|
268
|
+
ax.get_yaxis().set_visible(False)
|
|
269
|
+
ax.spines['left'].set_visible(False)
|
|
270
|
+
|
|
271
|
+
return ax
|
|
272
|
+
|
|
273
|
+
def get_ei_chromatogram(IRawDataPlus, target_mz, ppm_tolerance=1000, start_scan=-1, end_scan=-1, ms_type='MS'):
|
|
274
|
+
|
|
275
|
+
'''ms_type: str ('MS', MS2')
|
|
276
|
+
start_scan: int default -1 will select the lowest available
|
|
277
|
+
end_scan: int default -1 will select the highest available
|
|
278
|
+
'''
|
|
279
|
+
|
|
280
|
+
options = MassOptions()
|
|
281
|
+
options.ToleranceUnits = ToleranceUnits.ppm
|
|
282
|
+
options.Tolerance = ppm_tolerance
|
|
283
|
+
|
|
284
|
+
settings = ChromatogramTraceSettings(TraceType.MassRange)
|
|
285
|
+
settings.Filter = ms_type
|
|
286
|
+
settings.MassRanges = [Range(target_mz, target_mz)]
|
|
287
|
+
|
|
288
|
+
chroma_settings = IChromatogramSettings(settings)
|
|
289
|
+
|
|
290
|
+
settings2 = ChromatogramTraceSettings(TraceType.MassRange)
|
|
291
|
+
settings2.Filter = ms_type
|
|
292
|
+
settings2.MassRanges = [Range(target_mz, target_mz)]
|
|
293
|
+
settings2.MassRanges = [Range(404.5, 404.5)]
|
|
294
|
+
chroma_settings2 = IChromatogramSettings(settings2)
|
|
295
|
+
# chroma_settings2 = IChromatogramSettings(settings)
|
|
296
|
+
# print(chroma_settings.FragmentMass)
|
|
297
|
+
# print(chroma_settings.FragmentMass)
|
|
298
|
+
# print(chroma_settings)
|
|
299
|
+
# print(chroma_settings)
|
|
300
|
+
|
|
301
|
+
data = IRawDataPlus.GetChromatogramData([chroma_settings, chroma_settings2], start_scan, end_scan, options)
|
|
302
|
+
|
|
303
|
+
trace = ChromatogramSignal.FromChromatogramData(data)
|
|
304
|
+
|
|
305
|
+
if trace[1].Length > 0:
|
|
306
|
+
|
|
307
|
+
print("Base Peak chromatogram ({} points)".format(trace[0].Length))
|
|
308
|
+
rt = []
|
|
309
|
+
tic = []
|
|
310
|
+
scan = []
|
|
311
|
+
for i in range(trace[1].Length):
|
|
312
|
+
# print(trace[0].HasBasePeakData,trace[0].EndTime )
|
|
313
|
+
|
|
314
|
+
# print(" {} - {}, {}".format( i, trace[0].Times[i], trace[0].Intensities[i] ))
|
|
315
|
+
rt.append(trace[1].Times[i])
|
|
316
|
+
tic.append(trace[1].Intensities[i])
|
|
317
|
+
scan.append(trace[1].Scans[i])
|
|
318
|
+
|
|
319
|
+
plot_chroma(rt, tic)
|
|
320
|
+
plt.show()
|
|
321
|
+
|
|
322
|
+
if trace[0].Length > 0:
|
|
323
|
+
|
|
324
|
+
print("Base Peak chromatogram ({} points)".format(trace[0].Length))
|
|
325
|
+
|
|
326
|
+
rt = []
|
|
327
|
+
tic = []
|
|
328
|
+
for i in range(trace[0].Length):
|
|
329
|
+
# print(trace[0].HasBasePeakData,trace[0].EndTime )
|
|
330
|
+
|
|
331
|
+
# print(" {} - {}, {}".format( i, trace[0].Times[i], trace[0].Intensities[i] ))
|
|
332
|
+
rt.append(trace[0].Times[i])
|
|
333
|
+
tic.append(trace[0].Intensities[i])
|
|
334
|
+
plot_chroma(rt, tic)
|
|
335
|
+
plt.show()
|
|
336
|
+
|
|
337
|
+
def parse_scan_dependent(iRawDataPlus, iScanDependentDetailArray) -> [ScanDependentDetail]:
|
|
338
|
+
|
|
339
|
+
data = []
|
|
340
|
+
|
|
341
|
+
for scan_dependent_detail in iScanDependentDetailArray:
|
|
342
|
+
|
|
343
|
+
dscan = scan_dependent_detail.ScanIndex
|
|
344
|
+
|
|
345
|
+
scan_filter = iRawDataPlus.GetFilterForScanNumber(scan_dependent_detail.ScanIndex)
|
|
346
|
+
|
|
347
|
+
scanStatistics = iRawDataPlus.GetScanStatsForScanNumber(dscan)
|
|
348
|
+
|
|
349
|
+
tic = scanStatistics.TIC
|
|
350
|
+
|
|
351
|
+
rt = iRawDataPlus.RetentionTimeFromScanNumber(dscan)
|
|
352
|
+
|
|
353
|
+
reaction = scan_filter.GetReaction(0)
|
|
354
|
+
|
|
355
|
+
activation = activationType.get(reaction.ActivationType)
|
|
356
|
+
|
|
357
|
+
mz, abun = get_centroid(dscan, iRawDataPlus)
|
|
358
|
+
|
|
359
|
+
scanDependentDetail = ScanDependentDetail(scan_dependent_detail.ScanIndex,
|
|
360
|
+
scan_dependent_detail.FilterString,
|
|
361
|
+
scan_dependent_detail.PrecursorMassArray[0],
|
|
362
|
+
scan_dependent_detail.IsolationWidthArray[0],
|
|
363
|
+
activation,
|
|
364
|
+
reaction.CollisionEnergy,
|
|
365
|
+
tic,
|
|
366
|
+
rt,
|
|
367
|
+
mz,
|
|
368
|
+
abun
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
data.append(scanDependentDetail)
|
|
372
|
+
# print(scanDependentDetail)
|
|
373
|
+
|
|
374
|
+
return data
|
|
375
|
+
|
|
376
|
+
def get_data():
|
|
377
|
+
ms1_rt = []
|
|
378
|
+
ms2_rt = []
|
|
379
|
+
ms1_tic = []
|
|
380
|
+
ms2_tic = []
|
|
381
|
+
|
|
382
|
+
for scan in range(iRunHeader.FirstSpectrum, iRunHeader.LastSpectrum):
|
|
383
|
+
|
|
384
|
+
scan_filter = iRawDataPlus.GetFilterForScanNumber(scan)
|
|
385
|
+
|
|
386
|
+
ionizationMode = scan_filter.IonizationMode
|
|
387
|
+
|
|
388
|
+
MSOrder = scan_filter.MSOrder
|
|
389
|
+
|
|
390
|
+
massAnalyzer = massAnalyzerType.get(scan_filter.MassAnalyzer)
|
|
391
|
+
|
|
392
|
+
scanMode = scanType.get(scan_filter.ScanMode)
|
|
393
|
+
|
|
394
|
+
# print("scanMode", scan_filter.ScanMode)
|
|
395
|
+
|
|
396
|
+
rt = iRawDataPlus.RetentionTimeFromScanNumber(scan)
|
|
397
|
+
|
|
398
|
+
scanStatistics = iRawDataPlus.GetScanStatsForScanNumber(scan)
|
|
399
|
+
|
|
400
|
+
isCentroid = scanStatistics.IsCentroidScan
|
|
401
|
+
|
|
402
|
+
tic = scanStatistics.TIC
|
|
403
|
+
|
|
404
|
+
scanEvent = iRawDataPlus.GetScanEventForScanNumber(scan)
|
|
405
|
+
time = iRawDataPlus.RetentionTimeFromScanNumber(scan)
|
|
406
|
+
|
|
407
|
+
if MSOrder == MSOrderType.Ms2:
|
|
408
|
+
pass
|
|
409
|
+
# ms2_rt.append(rt)
|
|
410
|
+
# ms2_tic.append(tic)
|
|
411
|
+
|
|
412
|
+
if MSOrder == MSOrderType.Ms:
|
|
413
|
+
|
|
414
|
+
ms1_rt.append(rt)
|
|
415
|
+
ms1_tic.append(tic)
|
|
416
|
+
scanDependents = iRawDataPlus.GetScanDependents(scan, 5)
|
|
417
|
+
|
|
418
|
+
print("Scan number {} @ time {} - Instrument type={}, Number dependent scans={}".format(
|
|
419
|
+
scan, time, scanDependents.RawFileInstrumentType, scanDependents.ScanDependentDetailArray.Length))
|
|
420
|
+
|
|
421
|
+
dependent_list = parse_scan_dependent(iRawDataPlus, scanDependents.ScanDependentDetailArray)
|
|
422
|
+
|
|
423
|
+
total_tic = 0
|
|
424
|
+
|
|
425
|
+
for dependent in dependent_list:
|
|
426
|
+
|
|
427
|
+
# print(dependent.precursorMass)
|
|
428
|
+
total_tic = total_tic + dependent.tic
|
|
429
|
+
# print(dependent)
|
|
430
|
+
# trailerData = iRawDataPlus.GetTrailerExtraInformation(dscan)
|
|
431
|
+
|
|
432
|
+
# for i, label in enumerate(trailerData.Labels):
|
|
433
|
+
# print(label, trailerData.Values[i])
|
|
434
|
+
|
|
435
|
+
ms2_rt.append(rt)
|
|
436
|
+
ms2_tic.append(total_tic)
|
|
437
|
+
|
|
438
|
+
mz, abun = get_profile(scan, iRawDataPlus, scanStatistics)
|
|
439
|
+
|
|
440
|
+
# mz, abun = get_centroid(scan, iRawDataPlus)
|
|
441
|
+
# plot_ms(mz, abun, is_centroid=False)
|
|
442
|
+
# plt.show()
|
|
443
|
+
# print(dependent_list)
|
|
444
|
+
# parse_scan_dependent()
|
|
445
|
+
|
|
446
|
+
# print(scanEvent)
|
|
447
|
+
|
|
448
|
+
# scan_label = (iRawDataPlus.GetScanEventStringForScanNumber(scan))
|
|
449
|
+
|
|
450
|
+
# print(scan_label)
|
|
451
|
+
|
|
452
|
+
# get centroid data
|
|
453
|
+
# get profile data
|
|
454
|
+
|
|
455
|
+
ax = plot_chroma(ms1_rt, ms1_tic)
|
|
456
|
+
plot_chroma(ms2_rt, ms2_tic, ax=ax, c='red')
|
|
457
|
+
plt.show()
|
|
458
|
+
|
|
459
|
+
# get_data()
|
|
460
|
+
get_ei_chromatogram(iRawDataPlus, 335.35)
|