51 if(!file.open(QFile::ReadOnly | QFile::Text))
53 qDebug() <<
"Failed to open file" <<
m_fileName;
62 QString regexp_pattern =
66 regexp_pattern += QString(
",([+-])");
68 regexp_pattern += QString(
",(ESI|MALDI)");
71 regexp_pattern += QString(
",ms(\\d)");
74 regexp_pattern += QString(
",(-)");
77 regexp_pattern += QString(
",(profile|line)");
81 regexp_pattern += QString(
",(%1-%2)")
87 regexp_pattern += QString(
",(\\d+)");
89 regexp_pattern += QString(
"(.*$)");
93 QRegularExpression line_regexp(regexp_pattern);
95 QRegularExpressionMatch regexp_match;
98 bool file_reading_failed =
false;
107 std::size_t iter = 0;
111 line = file.readLine().trimmed();
124 regexp_match = line_regexp.match(
line);
126 if(regexp_match.hasMatch())
130 regexp_match.captured(1).toDouble(&ok);
133 qDebug() <<
"Failed to extract the retention time of the mass spectrum.";
135 file_reading_failed =
true;
140 QString ionization_mode = regexp_match.captured(2);
141 QString source_type = regexp_match.captured(3);
143 regexp_match.captured(4).toInt(&ok);
146 qDebug() <<
"Failed to extract the MS level of the mass spectrum.";
148 file_reading_failed =
true;
153 QString peak_shape_type = regexp_match.captured(6);
155 QString mz_range = regexp_match.captured(7);
157 mz_range.left(mz_range.indexOf(
"-")).toDouble(&ok);
160 qDebug() <<
"Failed to extract the start of the m/z range.";
162 file_reading_failed =
true;
167 mz_range.right(mz_range.indexOf(
"-") + 1).toDouble(&ok);
170 qDebug() <<
"Failed to extract the end of the m/z range.";
172 file_reading_failed =
true;
181 int peak_count = regexp_match.captured(8).toInt(&ok);
184 qDebug() <<
"Failed to extract the number of peaks in the mass "
187 file_reading_failed =
true;
192 QString peaks = regexp_match.captured(9);
193 QStringList peaks_stringlist = peaks.split(
",", Qt::SkipEmptyParts);
198 if(peaks_stringlist.size() != peak_count)
204 file_reading_failed =
true;
228 qDebug() <<
"The match failed.";
229 file_reading_failed =
true;
239 if(!file_reading_failed && line_count >= 1)