49 template <
typename MapType>
54 if (!File::exists(filename))
58 if (!File::readable(filename))
69 std::ifstream in(filename.c_str());
71 UInt spectrum_number = 0;
76 bool first_spec(
true);
81 while (getline(in, line,
'\n'))
85 StringUtils::trim(line);
86 if (line.empty())
continue;
100 spec.
setNativeID(std::string(
"index=") + (spectrum_number++));
108 StringUtils::simplify(line);
109 std::vector<std::string> split;
110 StringUtils::split(line,
' ', split);
111 if (split.size() != 4)
113 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"line (" + StringUtils::toStr(line_number) +
") '" + line +
"' should contain four values, got " + StringUtils::toStr(split.size()) +
"!",
"");
116 spec.
getPrecursors()[0].setMZ(StringUtils::toDouble(split[3]));
139 StringUtils::simplify(line);
140 std::vector<std::string> split;
141 StringUtils::split(line,
' ', split);
142 if (split.size() != 2)
144 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"line (" + StringUtils::toStr(line_number) +
") '" + line +
"' should contain two values, got " + StringUtils::toStr(split.size()) +
"!",
"");
154 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"ConversionError: line (" + StringUtils::toStr(line_number) +
") '" + line +
"' does not contain two numbers!",
"");
162 spec.
setNativeID(std::string(
"index=") + (spectrum_number++));
void setLoadedFileType(const std::string &file_name)
set the file_type according to the type of the file loaded from (see FileHandler::Type) preferably do...
void setLoadedFilePath(const std::string &file_name)
set the file_name_ according to absolute path of the file loaded from preferably done whilst loading
Invalid conversion exception.
Definition Exception.h:331
File not found exception.
Definition Exception.h:475
File not readable exception.
Definition Exception.h:501
Parse Error exception.
Definition Exception.h:593
~MS2File() override
constructor
void load(const std::string &filename, MapType &exp)
Definition MS2File.h:50
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
void reset()
Clear all internal data (spectra, chromatograms, ranges, metadata)
void updateRanges()
Updates the m/z, intensity, mobility, and retention time ranges of all spectra and chromatograms.
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
void setMSLevel(UInt ms_level)
Sets the MS level.
void clear(bool clear_meta_data)
Clears all data and meta data.
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition Peak1D.h:86
void setPosition(PositionType const &position)
Mutable access to the position.
Definition Peak1D.h:125
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
void setNativeID(const std::string &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19