35 #ifndef OPENMS_FORMAT_MSINSPECTFILE_H
36 #define OPENMS_FORMAT_MSINSPECTFILE_H
77 template <
typename FeatureMapType>
78 void load(
const String & filename, FeatureMapType & feature_map)
87 bool first_line =
true;
88 for (
Size i = 0; i < input.size(); ++i)
93 if (line.empty() || line[0] ==
'#')
continue;
103 std::vector<String> parts;
104 line.
split(
'\t', parts);
106 if (parts.size() < 18)
108 throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"",
String(
"Failed to convert line ") +
String(i + 1) +
". Not enough columns (expected 18 or more, got " +
String(parts.size()) +
")");
113 Size column_to_convert = 0;
116 column_to_convert = 1;
117 f.
setRT(parts[1].toDouble());
118 column_to_convert = 2;
119 f.
setMZ(parts[2].toDouble());
120 column_to_convert = 5;
122 column_to_convert = 6;
124 column_to_convert = 8;
127 column_to_convert = 3;
129 column_to_convert = 4;
131 column_to_convert = 7;
133 column_to_convert = 9;
135 column_to_convert = 10;
137 column_to_convert = 11;
139 column_to_convert = 12;
141 column_to_convert = 13;
143 column_to_convert = 14;
145 column_to_convert = 15;
147 column_to_convert = 16;
152 throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"",
String(
"Failed to convert value in column ") +
String(column_to_convert + 1) +
" into a number (line '" + (i + 1) +
")");
155 feature_map.push_back(f);
167 template <
typename SpectrumType>
168 void store(
const String & filename,
const SpectrumType & spectrum)
const
170 std::cerr <<
"Store() for MsInspectFile not implemented. Filename was: " << filename <<
", spec of size " << spectrum.size() <<
"\n";
177 #endif // OPENMS_FORMAT_MSINSPECTFILE_H
A more convenient string class.
Definition: String.h:56
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:197
void load(const String &filename, FeatureMapType &feature_map)
Loads a MsInspect file into a featureXML.
Definition: MsInspectFile.h:78
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:167
void store(const String &filename, const SpectrumType &spectrum) const
Stores a featureXML as a MsInspect file.
Definition: MsInspectFile.h:168
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:209
Exception base class.
Definition: Exception.h:90
An LC-MS feature.
Definition: Feature.h:66
void setOverallQuality(QualityType q)
Set the overall quality.
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
void setCharge(const ChargeType &ch)
Set charge state.
File adapter for MsInspect files.
Definition: MsInspectFile.h:61
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
Not implemented exception.
Definition: Exception.h:437
This class provides some basic file handling methods for text files.
Definition: TextFile.h:47
Parse Error exception.
Definition: Exception.h:608