48 QRegularExpression(
"\\d*\\.?\\d+");
53 QRegularExpression(
"[^\\d^\\.^-]+");
58 QRegularExpression(
"-?\\d*\\.?\\d*[e-]?\\d*");
64 QString(
"^(%1)(%2)(%3)")
75 int size =
log10(num);
77 QLatin1Char latin1_char(size);
78 QString base(latin1_char);
79 base.append(QString().setNum(num));
87 *p_out << (char)(
log10(num) + 97) << num;
107 int intPart =
static_cast<int>(value);
111 double decimalPart = value - intPart;
117 while(decimalPart > 0)
143 if(decimal_places < 0)
146 return ceil((value * pow(10, decimal_places)) - 0.49) /
147 pow(10, decimal_places);
155 if(
sizeof(
int *) == 4)
157 test_decimal = 100000000;
159 return (floor(input * test_decimal));
166 std::string env_backup = setlocale(LC_ALL,
"");
174 setlocale(LC_ALL,
"C");
177 QByteArray byte_array = text.toUtf8();
178 std::string stdText =
"";
180 for(
char c : byte_array)
186 setlocale(LC_ALL, env_backup.c_str());
196 QFile file(file_name);
198 if(file.open(QFile::WriteOnly | QFile::Truncate))
201 QTextStream out(&file);
219 QFile file(file_name);
221 if(file.open(QFile::WriteOnly | QFile::Append))
224 QTextStream out(&file);
241 qDebug() <<
" " << spectrum_native_id;
242 QStringList native_id_list = spectrum_native_id.split(
"=");
243 if(native_id_list.size() < 2)
246 QObject::tr(
"scan number not found in mzML native id %1")
247 .arg(spectrum_native_id));
265 return native_id_list.back().toULong();
274 return QString(
"%1").arg(
275 (quintptr)pointer, QT_POINTER_SIZE * 2, 16, QChar(
'0'));
296 double valueSum = std::abs(value1 + value2);
300 double valueDiff = std::abs(value1 - value2);
304 double epsilon = std::numeric_limits<double>::epsilon();
308 double scaleFactor = epsilon * valueSum * decimalPlaces;
316 bool res = valueDiff < scaleFactor
318 || valueDiff < std::numeric_limits<double>::min();
330 return std::nextafter(value, value + 1);
336 const QString &msg, std::chrono::system_clock::time_point chrono_time)
341 tt = std::chrono::system_clock::to_time_t(chrono_time);
344 QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
353 std::chrono::system_clock::time_point chrono_start,
354 std::chrono::system_clock::time_point chrono_finish)
358 "%1 %2 min = %3 s = %4 ms = %5 "
361 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish -
364 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish -
367 .arg(std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish -
370 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish -
380 std::size_t &error_count)
383 QStringList string_list =
384 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
388 std::vector<double> double_vector;
390 for(
int iter = 0; iter < string_list.size(); ++iter)
392 QString current_string = string_list.at(iter);
396 double current_double = current_string.toDouble(&ok);
398 if(!current_double && !ok)
404 double_vector.push_back(current_double);
407 return double_vector;
411std::vector<std::size_t>
413 std::size_t &error_count)
417 QStringList string_list =
418 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
423 std::vector<std::size_t> sizet_vector;
425 for(
int iter = 0; iter < string_list.size(); ++iter)
427 QString current_string = string_list.at(iter);
431 std::size_t current_sizet = current_string.toUInt(&ok);
433 if(!current_sizet && !ok)
439 sizet_vector.push_back(current_sizet);
471 return "abSciexWiff";
475 return "agilentMassHunter";
489 return "brukerBafAscii";
506 return "tims_frames";
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
static QString chronoTimePointDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_time=std::chrono::system_clock::now())
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
static QString pointerToString(const void *const pointer)
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
static QRegularExpression anythingButDigitDotDash
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
static QString msDataFormatAsString(MsDataFormat mz_format)
Convenience function to return a string describing the MzFormat of a file.
static std::vector< double > splitMzStringToDoubleVectorWithSpaces(const QString &text, std::size_t &error_count)
static double nearestGreater(double value)
static std::string toUtf8StandardString(const QString &text)
static bool appendToFile(const QString &text, const QString &file_name)
static QString booleanToString(bool value)
convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable ...
static QString chronoIntervalDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_start, std::chrono::system_clock::time_point chrono_finish=std::chrono::system_clock::now())
static bool writeToFile(const QString &text, const QString &file_name)
static std::vector< std::size_t > splitSizetStringToSizetVectorWithSpaces(const QString &text, std::size_t &error_count)
static QRegularExpression signedDoubleNumberExponentialRegExp
static QRegularExpression xyMassDataFormatRegExp
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
static const QString getLexicalOrderedString(unsigned int num)
static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num)
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
static QString fileReaderTypeAsString(FileReaderType file_reader_type)
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
static long long int roundToDecimal32bitsAsLongLongInt(pappso::pappso_double input)
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)
@ reAlign
Re Alignment (1 - RE)
@ align
Alignment (2 - AL)
ExperimentalSpectrumDataPointType
@ both
both, the ion and the complement exists in the original spectrum
@ symmetric
new peak : computed symmetric mass from a corresponding native peak
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
double pappso_double
A type definition for doubles.
This header contains all the type re-definitions and all the global variables definitions used in the...