|
OpenMS
2.6.0
|
Go to the documentation of this file.
80 template <
typename SpectrumType>
83 std::ifstream is(filename.c_str());
94 std::vector<String> strings(2);
102 getline(is, line,
'\n');
115 line.
split(delimiter, strings);
116 if (strings.size() != 2)
118 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\" (got " +
String(strings.size()) +
", expected 2 entries)", filename);
126 mh_mass = strings[0].toDouble();
127 charge = strings[1].toInt();
131 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\": not a float number.", filename);
139 precursor.
setMZ(mh_mass);
145 while (getline(is, line,
'\n'))
149 if (line.empty())
continue;
161 line.
split(delimiter, strings);
162 if (strings.size() != 2)
164 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\" (got " +
String(strings.size()) +
", expected 2 entries)", filename);
174 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, std::string(
"Bad data line (" +
String(line_number) +
"): \"") + line +
"\": not a float number.", filename);
176 spectrum.push_back(p);
191 template <
typename SpectrumType>
194 std::ofstream os(filename.c_str());
209 std::cerr <<
"Warning: The spectrum written to the DTA file '" << filename <<
"' has more than one precursor. The first precursor is used!" <<
"\n";
214 os << precursor.
getMZ();
222 os <<
" " << precursor.
getCharge() <<
"\n";
227 for (; it != spectrum.end(); ++it)
230 os << it->getPosition() <<
" " << it->getIntensity() <<
"\n";
Base class for TOPP applications.
Definition: TOPPBase.h:144
UInt default_ms_level_
Default MS level used when reading the file.
Definition: DTAFile.h:240
static String basename(const String &file)
Returns the basename of the file (without the path).
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:121
File adapter for MzML files.
Definition: MzMLFile.h:55
A more convenient string class.
Definition: String.h:59
Iterator begin()
Definition: MSExperiment.h:157
File not found exception.
Definition: Exception.h:523
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Invalid conversion exception.
Definition: Exception.h:362
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:112
const double PROTON_MASS_U
File adapter for DTA files.
Definition: DTAFile.h:60
Precursor meta information.
Definition: Precursor.h:57
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
Base::iterator iterator
Definition: MSExperiment.h:124
bool has(Byte byte) const
true if String contains the byte, false otherwise
Unable to create file exception.
Definition: Exception.h:636
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:115
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:151
Exception base class.
Definition: Exception.h:89
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
void clear(bool clear_meta_data)
Clears all data and meta data.
void setMSLevel(UInt ms_level)
Sets the MS level.
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:884
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
float IntensityType
Intensity type.
Definition: Peak1D.h:63
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
constexpr Int writtenDigits< double >(const double &)
Number of digits commonly used for writing a double (a.k.a. precision).
Definition: Types.h:219
Parse Error exception.
Definition: Exception.h:622
void load(const String &filename, SpectrumType &spectrum)
Loads a DTA file to a spectrum.
Definition: DTAFile.h:81
void setRTRange(const DRange< 1 > &range)
restricts the range of RT values for peaks to load
Iterator end()
Definition: MSExperiment.h:167
void setName(const String &name)
Sets the name.
Int getCharge() const
Non-mutable access to the charge.
void setCharge(Int charge)
Mutable access to the charge.
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSSpectrum.h:128
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
Int toInt() const
Conversion to int.
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
void store(const String &filename, const SpectrumType &spectrum) const
Stores a spectrum in a DTA file.
Definition: DTAFile.h:192