MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / countScansInSwath_

Method countScansInSwath_

src/openms/source/FORMAT/SwathFile.cpp:308–385  ·  view source on GitHub ↗

Counts the number of scans in a full Swath file (e.g. concatenated non-split file)

Source from the content-addressed store, hash-verified

306 }
307 /// Counts the number of scans in a full Swath file (e.g. concatenated non-split file)
308 void SwathFile::countScansInSwath_(const std::vector<MSSpectrum>& exp,
309 std::vector<int>& swath_counter, int& nr_ms1_spectra,
310 std::vector<OpenSwath::SwathMap>& known_window_boundaries)
311 {
312 int ms1_counter = 0;
313 for (Size i = 0; i < exp.size(); i++)
314 {
315 const MSSpectrum& s = exp[i];
316 {
317 if (s.getMSLevel() == 1)
318 {
319 ms1_counter++;
320 }
321 else
322 {
323 if (s.getPrecursors().empty())
324 {
325 throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
326 "Found SWATH scan (MS level 2 scan) without a precursor. Cannot determine SWATH window.");
327 }
328 const std::vector<Precursor> prec = s.getPrecursors();
329 double center = prec[0].getMZ();
330
331
332 // check if ion mobility is present
333 double lowerIm = -1;
334 double upperIm = -1; // these initial values assume ion mobility is not present
335
336 if (s.metaValueExists("ion mobility lower limit"))
337 {
338 lowerIm = s.getMetaValue("ion mobility lower limit"); // want this to be -1 if no ion mobility
339 upperIm = s.getMetaValue("ion mobility upper limit");
340
341 }
342
343 bool found = false;
344
345 for (Size j = 0; j < known_window_boundaries.size(); j++)
346 {
347 // We group by the precursor mz (center of the window) since this
348 // should be present
349 // for ion mobility, since the center value is not present in the raw data (it is computed) we use the imLower and upper bounds
350 if ((std::fabs(center - known_window_boundaries[j].center) < 1e-6) && (std::fabs(lowerIm - known_window_boundaries[j].imLower) < 1e-6) && (std::fabs(upperIm - known_window_boundaries[j].imUpper < 1e-6)))
351 {
352 found = true;
353 swath_counter[j]++;
354 }
355 }
356 if (!found)
357 {
358 // we found a new SWATH scan
359 swath_counter.push_back(1);
360 double lower = prec[0].getMZ() - prec[0].getIsolationWindowLowerOffset();
361 double upper = prec[0].getMZ() + prec[0].getIsolationWindowUpperOffset();
362
363 OpenSwath::SwathMap boundary;
364 boundary.lower = lower;
365 boundary.upper = upper;

Callers

nothing calls this directly

Calls 10

getMSLevelMethod · 0.80
getPrecursorsMethod · 0.80
metaValueExistsMethod · 0.80
getMetaValueMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
getMZMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected