|
OpenMS
2.5.0
|
Go to the documentation of this file.
94 template <
typename MapType>
97 startProgress(0, 0,
"loading DTA2D file");
100 std::ifstream is(filename.c_str());
113 std::vector<String> strings(3);
126 bool time_in_minutes =
false;
135 Size line_number = 0;
137 while (getline(is, line,
'\n'))
142 if (line.empty())
continue;
158 line.
split(delimiter, strings);
163 bool int_set =
false;
166 for (
Size i = 0; i < 3; ++i)
168 if (strings[i] ==
"RT" || strings[i] ==
"RETENTION_TIME" || strings[i] ==
"MASS-TO-CHARGE" || strings[i] ==
"IT" || strings[i] ==
"INTENSITY")
170 std::cerr <<
"Warning: This file contains the deprecated keyword '" << strings[i] <<
"'." <<
"\n";
171 std::cerr <<
" Please use only the new keywords SEC/MIN, MZ, INT." <<
"\n";
173 if ((strings[i] ==
"SEC" || strings[i] ==
"RT" || strings[i] ==
"RETENTION_TIME") && rt_set ==
false)
178 else if ((strings[i] ==
"MIN") && rt_set ==
false)
182 time_in_minutes =
true;
184 else if ((strings[i] ==
"MZ" || strings[i] ==
"MASS-TO-CHARGE") && mz_set ==
false)
189 else if ((strings[i] ==
"INT" || strings[i] ==
"IT" || strings[i] ==
"INTENSITY") && int_set ==
false)
196 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Misformatted header line!", filename);
204 line.
split(delimiter, strings);
205 if (strings.size() != 3)
207 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\" (got " +
String(strings.size()) +
", expected 3 entries)", filename);
210 p.
setMZ(strings[mz_dim].toDouble());
211 rt = (strings[rt_dim].toDouble()) * (time_in_minutes ? 60.0 : 1.0);
216 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\"", filename);
220 if (fabs(rt - spec.
getRT()) > 0.0001)
268 template <
typename MapType>
271 startProgress(0, map.
size(),
"storing DTA2D file");
273 std::ofstream os(filename.c_str());
280 os <<
"#SEC\tMZ\tINT\n";
287 setProgress(count++);
307 template <
typename MapType>
310 startProgress(0, map.
size(),
"storing DTA2D file");
312 std::ofstream os(filename.c_str());
319 os <<
"#SEC\tMZ\tINT\n";
bool has(Byte byte) const
true if String contains the byte, false otherwise
void setLoadedFileType(const String &file_name)
set the file_type according to the type of the file loaded from (see FileHandler::Type) preferably do...
void storeTIC(const String &filename, const MapType &map) const
Stores the TIC of a map in a DTA2D file.
Definition: DTA2DFile.h:308
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
void store(const String &filename, const MapType &map) const
Stores a map in a DTA2D file.
Definition: DTA2DFile.h:269
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:121
bool hasIntensityRange() const
returns true if an intensity range has been set
const MSChromatogram getTIC(float rt_bin_size=0) const
Compute Total Ion Count per MS1 spectrum and applies the resampling algorithm, if a bin size in RT se...
bool hasMZRange() const
returns true if an MZ range has been set
void load(const String &filename, MapType &map)
Loads a map from a DTA2D file.
Definition: DTA2DFile.h:95
Size size() const
Definition: MSExperiment.h:127
void reset()
Resets all internal values.
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:112
const PrecisionWrapper< FloatingPointType > precisionWrapper(const FloatingPointType rhs)
Wrapper function that sets the appropriate precision for output temporarily. The original precision i...
Definition: PrecisionWrapper.h:95
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
Base::const_iterator const_iterator
Definition: MSExperiment.h:125
Iterator begin()
Definition: MSExperiment.h:157
Unable to create file exception.
Definition: Exception.h:636
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
const DRange< 1 > & getRTRange() const
returns the RT range
IntensityType getIntensity() const
Definition: Peak1D.h:110
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:115
Iterator end()
Definition: MSExperiment.h:167
void setLoadedFilePath(const String &file_name)
set the file_name_ according to absolute path of the file loaded from preferably done whilst loading
The representation of a chromatogram.
Definition: MSChromatogram.h:54
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
PeakFileOptions options_
Definition: DTA2DFile.h:67
const DRange< 1 > & getMZRange() const
returns the MZ range
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
DTA2D File adapter.
Definition: DTA2DFile.h:63
Exception base class.
Definition: Exception.h:89
const DRange< 1 > & getIntensityRange() const
returns the intensity range
A more convenient string class.
Definition: String.h:58
bool encloses(const PositionType &position) const
Checks whether this range contains a certain point.
Definition: DRange.h:174
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
void clear(bool clear_meta_data)
Clears all data and meta data.
bool hasRTRange() const
returns true if an RT range has been set
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
File not found exception.
Definition: Exception.h:523
Parse Error exception.
Definition: Exception.h:622
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
void setRT(double rt)
Sets the absolute retention time (in seconds)
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.