OpenMS
Loading...
Searching...
No Matches
SwathWindowLoader Class Reference

#include <OpenMS/ANALYSIS/OPENSWATH/SwathWindowLoader.h>

Static Public Member Functions

static void annotateSwathMapsFromFile (const std::string &filename, std::vector< OpenSwath::SwathMap > &swath_maps, bool do_sort, bool force)
 Overwrite the lower/upper precursor boundaries of swath_maps with the windows read from filename.
 
static void readSwathWindows (const std::string &filename, std::vector< double > &swath_prec_lower, std::vector< double > &swath_prec_upper)
 

Detailed Description

@brief Reads a SWATH-window definition file and annotates SwathMaps with it.

The file format is tab- or space-delimited with two columns per row:
window_lower window_upper
400 425
425 450
...
The first line is treated as a header only if its first token cannot
be parsed as a number; otherwise the first line is read as data. The
reader does not require any specific header text and accepts files
without a header row.

@ingroup FileIO

Member Function Documentation

◆ annotateSwathMapsFromFile()

static void annotateSwathMapsFromFile ( const std::string &  filename,
std::vector< OpenSwath::SwathMap > &  swath_maps,
bool  do_sort,
bool  force 
)
static

Overwrite the lower/upper precursor boundaries of swath_maps with the windows read from filename.

Walks swath_maps in order, skipping entries whose ms1 flag is set, and replaces each remaining entry's lower and upper with the corresponding row of the SWATH-window file. The number of non-MS1 entries in swath_maps must equal the number of rows in filename.

Note
The non-MS1 entries in swath_maps and the rows of the file are matched by position, so both must be in the same order (usually low-to-high m/z). When do_sort is true, swath_maps is sorted by its upper field before matching.
Parameters
[in]filenamePath of the SWATH-window file.
[in,out]swath_mapsSWATH maps to annotate; their lower / upper fields are overwritten in place (and the vector may be reordered when do_sort is true).
[in]do_sortIf true, sort swath_maps by ascending upper before matching against the file.
[in]forceIf true, a file window that extends beyond the corresponding map's data boundaries is logged as an error and applied anyway; if false the same situation throws.
Exceptions
Exception::IllegalArgumentif the number of non-MS1 entries in swath_maps does not equal the number of rows in filename, or if a file window extends beyond the corresponding map's lower / upper and force is false.
Exception::InvalidValuepropagated from readSwathWindows when a row has lower >= upper.

◆ readSwathWindows()

static void readSwathWindows ( const std::string &  filename,
std::vector< double > &  swath_prec_lower,
std::vector< double > &  swath_prec_upper 
)
static
  @brief Read a SWATH-window definition file into two parallel vectors.

  The file format is two whitespace-separated columns
  (@c window_lower @c window_upper) per row:
window_lower window_upper
400 425
425 450
...
  A header row is detected automatically by trying to parse the first
  token of the first line as a number; if parsing fails, the line is
  treated as a header and skipped, otherwise the first line is read as
  data. No specific header text is required.

  @param[in]  filename         Path of the SWATH-window file. A
                               missing or unreadable file is not
                               reported as an exception; the output
                               vectors are left empty.
  @param[out] swath_prec_lower Lower boundary of each window, in file
                               order.
  @param[out] swath_prec_upper Upper boundary of each window, in file
                               order; same length as
                               @p swath_prec_lower.

  @throws Exception::InvalidValue if a row has @c lower >= @c upper.