49 QRegularExpression(
"\\d*\\.?\\d+");
54 QRegularExpression(
"[^\\d^\\.^-]+");
59 QRegularExpression(
"-?\\d*\\.?\\d*[e-]?\\d*");
65 QString(
"^(%1)(%2)(%3)")
76 int size =
log10(num);
78 QLatin1Char latin1_char(size);
79 QString base(latin1_char);
80 base.append(QString().setNum(num));
88 *p_out << (char)(
log10(num) + 97) << num;
108 int intPart =
static_cast<int>(value);
112 double decimalPart = value - intPart;
118 while(decimalPart > 0)
144 if(decimal_places < 0)
147 return ceil((value * pow(10, decimal_places)) - 0.49) /
148 pow(10, decimal_places);
156 if(
sizeof(
int *) == 4)
158 test_decimal = 100000000;
160 return (floor(input * test_decimal));
167 std::string env_backup;
172 env_backup = std::setlocale(LC_ALL,
nullptr);
173 std::setlocale(LC_ALL,
"C");
175 std::locale::global(std::locale(
"C"));
178 catch(std::exception &error)
181 QObject::tr(
"Error trying to set local to C : %1").arg(error.what()));
184 QByteArray byte_array = text.toUtf8();
185 std::string stdText =
"";
187 for(
char c : byte_array)
196 std::setlocale(LC_ALL, env_backup.c_str());
202 catch(std::exception &error)
206 QObject::tr(
"Error trying to set local to original system one %1 : %2")
207 .arg(env_backup.c_str())
219 QFile file(file_name);
221 if(file.open(QFile::WriteOnly | QFile::Truncate))
224 QTextStream out(&file);
242 QFile file(file_name);
244 if(file.open(QFile::WriteOnly | QFile::Append))
247 QTextStream out(&file);
264 qDebug() <<
" " << spectrum_native_id;
265 QStringList native_id_list = spectrum_native_id.split(
"=");
266 if(native_id_list.size() < 2)
269 QObject::tr(
"scan number not found in mzML native id %1")
270 .arg(spectrum_native_id));
288 return native_id_list.back().toULong();
297 return QString(
"%1").arg(
298 (quintptr)pointer, QT_POINTER_SIZE * 2, 16, QChar(
'0'));
319 double valueSum = std::abs(value1 + value2);
323 double valueDiff = std::abs(value1 - value2);
327 double epsilon = std::numeric_limits<double>::epsilon();
331 double scaleFactor = epsilon * valueSum * decimalPlaces;
339 bool res = valueDiff < scaleFactor
341 || valueDiff < std::numeric_limits<double>::min();
353 return std::nextafter(value, value + 1);
359 const QString &msg, std::chrono::system_clock::time_point chrono_time)
364 tt = std::chrono::system_clock::to_time_t(chrono_time);
367 QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
376 std::chrono::system_clock::time_point chrono_start,
377 std::chrono::system_clock::time_point chrono_finish)
381 "%1 %2 min = %3 s = %4 ms = %5 "
384 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish -
387 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish -
390 .arg(std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish -
393 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish -
403 std::size_t &error_count)
406 QStringList string_list =
407 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
411 std::vector<double> double_vector;
413 for(
int iter = 0; iter < string_list.size(); ++iter)
415 QString current_string = string_list.at(iter);
419 double current_double = current_string.toDouble(&ok);
421 if(!current_double && !ok)
427 double_vector.push_back(current_double);
430 return double_vector;
434std::vector<std::size_t>
436 std::size_t &error_count)
440 QStringList string_list =
441 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
446 std::vector<std::size_t> sizet_vector;
448 for(
int iter = 0; iter < string_list.size(); ++iter)
450 QString current_string = string_list.at(iter);
454 std::size_t current_sizet = current_string.toUInt(&ok);
456 if(!current_sizet && !ok)
462 sizet_vector.push_back(current_sizet);
494 return "abSciexWiff";
498 return "agilentMassHunter";
512 return "brukerBafAscii";
529 return "tims_frames";
575 QString version(PAPPSOMSPP_VERSION);
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)
static QString getVersion()
@ 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.
@ tims
TimsMsRunReader : each scan is returned as a mass spectrum.
This header contains all the type re-definitions and all the global variables definitions used in the...