35 #ifndef OPENMS_METADATA_SPECTRUMLOOKUP_H 36 #define OPENMS_METADATA_SPECTRUMLOOKUP_H 41 #include <boost/regex.hpp> 103 template <
typename SpectrumContainer>
105 const String& scan_regexp = default_scan_regexp)
110 n_spectra_ = spectra.size();
111 setScanRegExp_(scan_regexp);
112 for (
Size i = 0; i < n_spectra_; ++i)
117 if (!scan_regexp.empty())
119 scan_no = extractScanNumber(native_id, scan_regexp_,
true);
122 LOG_WARN <<
"Warning: Could not extract scan number from spectrum native ID '" + native_id +
"' using regular expression '" + scan_regexp +
"'. Look-up by scan number may not work properly." << std::endl;
125 addEntry_(i, spectrum.
getRT(), scan_no, native_id);
140 Size findByRT(
double rt)
const;
151 Size findByNativeID(
const String& native_id)
const;
163 Size findByIndex(
Size index,
bool count_from_one =
false)
const;
174 Size findByScanNumber(
Size scan_number)
const;
188 Size findByReference(
const String& spectrum_ref)
const;
199 void addReferenceFormat(
const String& regexp);
212 static Int extractScanNumber(
const String& native_id,
213 const boost::regex& scan_regexp,
214 bool no_error =
false);
239 void addEntry_(
Size index,
double rt,
Int scan_number,
254 const boost::smatch& match)
const;
261 void setScanRegExp_(
const String& scan_regexp);
275 #endif // OPENMS_METADATA_SPECTRUMLOOKUP_H static const String & regexp_names_
Named groups recognized in regular expression.
Definition: SpectrumLookup.h:219
Helper class for looking up spectra based on different attributes.
Definition: SpectrumLookup.h:68
A more convenient string class.
Definition: String.h:57
static const String & default_scan_regexp
Default regular expression for extracting scan numbers from spectrum native IDs.
Definition: SpectrumLookup.h:73
void readSpectra(const SpectrumContainer &spectra, const String &scan_regexp=default_scan_regexp)
Read and index spectra for later look-up.
Definition: SpectrumLookup.h:104
std::vector< boost::regex > reference_formats
Possible formats of spectrum references, defined as regular expressions.
Definition: SpectrumLookup.h:76
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
boost::regex scan_regexp_
Regular expression to extract scan numbers.
Definition: SpectrumLookup.h:223
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:451
std::map< Size, Size > scans_
Mapping: scan number -> spectrum index.
Definition: SpectrumLookup.h:229
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
std::map< String, Size > ids_
Mapping: native ID -> spectrum index.
Definition: SpectrumLookup.h:228
std::vector< String > regexp_name_list_
Named groups in vector format.
Definition: SpectrumLookup.h:225
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
std::map< double, Size > rts_
Mapping: RT -> spectrum index.
Definition: SpectrumLookup.h:227
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software. ...
Size n_spectra_
Number of spectra.
Definition: SpectrumLookup.h:221
int Int
Signed integer type.
Definition: Types.h:103
double rt_tolerance
Tolerance for look-up by retention time.
Definition: SpectrumLookup.h:79