71 template <
typename MapType>
74 startProgress(0, 0,
"loading DTA2D file");
77 std::ifstream is(filename.c_str());
80 if (!File::exists(filename))
84 else if (!File::readable(filename))
101 std::vector<std::string> strings(3);
114 bool time_in_minutes =
false;
123 Size line_number = 0;
125 while (getline(is, line,
'\n'))
128 StringUtils::trim(line);
130 if (line.empty())
continue;
133 if (StringUtils::has(line,
'\t'))
143 if (StringUtils::hasPrefix(line,
"#"))
145 line = StringUtils::trimmed(line.substr(1));
146 StringUtils::toUpper(line);
147 StringUtils::split(line, delimiter, strings);
152 bool int_set =
false;
155 for (
Size i = 0; i < 3; ++i)
157 if (strings[i] ==
"RT" || strings[i] ==
"RETENTION_TIME" || strings[i] ==
"MASS-TO-CHARGE" || strings[i] ==
"IT" || strings[i] ==
"INTENSITY")
159 std::cerr <<
"Warning: This file contains the deprecated keyword '" << strings[i] <<
"'." <<
"\n";
160 std::cerr <<
" Please use only the new keywords SEC/MIN, MZ, INT." <<
"\n";
162 if ((strings[i] ==
"SEC" || strings[i] ==
"RT" || strings[i] ==
"RETENTION_TIME") && rt_set ==
false)
167 else if ((strings[i] ==
"MIN") && rt_set ==
false)
171 time_in_minutes =
true;
173 else if ((strings[i] ==
"MZ" || strings[i] ==
"MASS-TO-CHARGE") && mz_set ==
false)
178 else if ((strings[i] ==
"INT" || strings[i] ==
"IT" || strings[i] ==
"INTENSITY") && int_set ==
false)
185 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Misformatted header line!", filename);
193 StringUtils::split(line, delimiter, strings);
194 if (strings.size() != 3)
196 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" + StringUtils::toStr(line_number) +
"): \"") + line +
"\" (got " + StringUtils::toStr(strings.size()) +
", expected 3 entries)", filename);
199 p.
setMZ(StringUtils::toDouble(strings[mz_dim]));
200 rt = (StringUtils::toDouble(strings[rt_dim])) * (time_in_minutes ? 60.0 : 1.0);
205 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" + StringUtils::toStr(line_number) +
"): \"") + line +
"\"", filename);
209 if (fabs(rt - spec.
getRT()) > 0.0001)
220 spec.
setNativeID(std::string(
"index=") + native_id);
258 template <
typename MapType>
261 startProgress(0, map.
size(),
"storing DTA2D file");
263 std::ofstream os(filename.c_str());
270 os <<
"#SEC\tMZ\tINT\n";
277 setProgress(count++);
297 template <
typename MapType>
300 startProgress(0, map.
size(),
"storing DTA2D file");
302 std::ofstream os(filename.c_str());
309 os <<
"#SEC\tMZ\tINT\n";
Representation of a coordinate in D-dimensional space.
Definition DPosition.h:32
bool encloses(const PositionType &position) const
Checks whether this range (half open interval!) contains a certain point.
Definition DRange.h:152
DTA2D File adapter.
Definition DTA2DFile.h:42
void load(const std::string &filename, MapType &map)
Loads a map from a DTA2D file.
Definition DTA2DFile.h:72
~DTA2DFile() override
Destructor.
DTA2DFile()
Default constructor.
const PeakFileOptions & getOptions() const
Non-mutable access to the options for loading/storing.
PeakFileOptions options_
Definition DTA2DFile.h:44
void storeTIC(const std::string &filename, const MapType &map) const
Stores the TIC of a map in a DTA2D file.
Definition DTA2DFile.h:298
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
void store(const std::string &filename, const MapType &map) const
Stores a map in a DTA2D file.
Definition DTA2DFile.h:259
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
Exception base class.
Definition Exception.h:63
File not found exception.
Definition Exception.h:475
File not readable exception.
Definition Exception.h:501
General IOException.
Definition Exception.h:541
Parse Error exception.
Definition Exception.h:593
Unable to create file exception.
Definition Exception.h:606
The representation of a chromatogram.
Definition MSChromatogram.h:30
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
Iterator begin() noexcept
Size size() const noexcept
The number of spectra.
const MSChromatogram calculateTIC(float rt_bin_size=0, UInt ms_level=1) const
Computes the total ion chromatogram (TIC) for a given MS level (use ms_level = 0 for all levels).
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.
Base::const_iterator const_iterator
Definition MSExperiment.h:98
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition MSExperiment.h:86
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
void clear(bool clear_meta_data)
Clears all data and meta data.
void setRT(double rt)
Sets the absolute retention time (in seconds)
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition Peak1D.h:89
IntensityType getIntensity() const
Definition Peak1D.h:84
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition Peak1D.h:86
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition Peak1D.h:95
Options for loading files containing peak data.
Definition PeakFileOptions.h:22
bool hasRTRange() const
returns true if an RT range has been set
const DRange< 1 > & getIntensityRange() const
returns the intensity range
bool hasMZRange() const
returns true if an MZ range has been set
bool hasIntensityRange() const
returns true if an intensity range has been set
const DRange< 1 > & getMZRange() const
returns the MZ range
const DRange< 1 > & getRTRange() const
returns the RT range
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
void setNativeID(const std::string &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
Total Ion Current (TIC) as a QC metric.
Definition TIC.h:33
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
const PrecisionWrapper< FloatingPointType > precisionWrapper(const FloatingPointType rhs)
Wrapper function that sets the appropriate precision for output temporarily. The original precision i...
Definition PrecisionWrapper.h:69