#include <utils.h>
|
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 More...
|
|
static pappso_double | roundToDecimals (pappso_double value, int decimal_places) |
|
static long long int | roundToDecimal32bitsAsLongLongInt (pappso::pappso_double input) |
|
static std::string | toUtf8StandardString (const QString &text) |
|
static bool | writeToFile (const QString &text, const QString &file_name) |
|
static bool | appendToFile (const QString &text, const QString &file_name) |
|
static std::size_t | extractScanNumberFromMzmlNativeId (const QString &spectrum_native_id) |
|
static QString | pointerToString (const void *const pointer) |
|
static bool | almostEqual (double value1, double value2, int decimalPlaces=10) |
|
static double | nearestGreater (double value) |
|
static QString | chronoTimePointDebugString (const QString &msg, std::chrono::system_clock::time_point chrono_time=std::chrono::system_clock::now()) |
|
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 std::vector< double > | splitMzStringToDoubleVectorWithSpaces (const QString &text, std::size_t &error_count) |
|
static std::vector< std::size_t > | splitSizetStringToSizetVectorWithSpaces (const QString &text, std::size_t &error_count) |
|
static QString | booleanToString (bool value) |
| convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable by R More...
|
|
static QString | mzFormatAsString (MzFormat mz_format) |
| Convenience function to return a string describing the MzFormat of a file. More...
|
|
Definition at line 48 of file utils.h.
◆ almostEqual()
bool pappso::Utils::almostEqual |
( |
double |
value1, |
|
|
double |
value2, |
|
|
int |
decimalPlaces = 10 |
|
) |
| |
|
static |
Tell if both double values, are equal within the double representation capabilities of the platform.
Definition at line 261 of file utils.cpp.
275 double valueSum = std::abs(value1 + value2);
279 double valueDiff = std::abs(value1 - value2);
283 double epsilon = std::numeric_limits<double>::epsilon();
287 double scaleFactor = epsilon * valueSum * decimalPlaces;
295 bool res = valueDiff < scaleFactor
297 || valueDiff < std::numeric_limits<double>::min();
References pappso::res.
◆ appendToFile()
bool pappso::Utils::appendToFile |
( |
const QString & |
text, |
|
|
const QString & |
file_name |
|
) |
| |
|
static |
Definition at line 195 of file utils.cpp.
198 QFile file(file_name);
200 if(file.open(QFile::WriteOnly | QFile::Append))
203 QTextStream out(&file);
◆ booleanToString()
QString pappso::Utils::booleanToString |
( |
bool |
value | ) |
|
|
static |
convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable by R
- Returns
- QString "TRUE" or "FALSE"
Definition at line 424 of file utils.cpp.
◆ chronoIntervalDebugString()
QString pappso::Utils::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 |
Definition at line 330 of file utils.cpp.
337 "%1 %2 min = %3 s = %4 ms = %5 "
340 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish -
343 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish -
346 .arg(std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish -
349 .arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish -
◆ chronoTimePointDebugString()
QString pappso::Utils::chronoTimePointDebugString |
( |
const QString & |
msg, |
|
|
std::chrono::system_clock::time_point |
chrono_time = std::chrono::system_clock::now() |
|
) |
| |
|
static |
Definition at line 314 of file utils.cpp.
320 tt = std::chrono::system_clock::to_time_t(chrono_time);
323 QString(
"%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
◆ extractScanNumberFromMzmlNativeId()
std::size_t pappso::Utils::extractScanNumberFromMzmlNativeId |
( |
const QString & |
spectrum_native_id | ) |
|
|
static |
TODO activate this in a future release to ensure scan number for(auto i = 0; i < native_id_list.size(); i += 2) { if(native_id_list[i] == "scan") { return native_id_list[i + 1].toULong(); } }
throw ExceptionNotFound( QObject::tr("scan number not found in mzML native id %1") .arg(spectrum_native_id));
Definition at line 218 of file utils.cpp.
220 qDebug() <<
" " << spectrum_native_id;
221 QStringList native_id_list = spectrum_native_id.split(
"=");
222 if(native_id_list.size() < 2)
224 throw ExceptionNotFound(
225 QObject::tr(
"scan number not found in mzML native id %1")
226 .arg(spectrum_native_id));
244 return native_id_list.back().toULong();
◆ getLexicalOrderedString()
const QString pappso::Utils::getLexicalOrderedString |
( |
unsigned int |
num | ) |
|
|
static |
◆ mzFormatAsString()
QString pappso::Utils::mzFormatAsString |
( |
MzFormat |
mz_format | ) |
|
|
static |
Convenience function to return a string describing the MzFormat of a file.
- Returns
- QString like "brukerTims" for enum value MzFormat::brukerTims.
Definition at line 432 of file utils.cpp.
450 return "abSciexWiff";
454 return "agilentMassHunter";
References pappso::abSciexT2D, pappso::abSciexWiff, pappso::agilentMassHunter, pappso::brukerBaf, pappso::brukerFid, pappso::brukerTims, pappso::brukerYep, pappso::MGF, pappso::msn, pappso::mz5, pappso::mzML, pappso::mzXML, pappso::SQLite3, pappso::thermoRaw, pappso::watersRaw, and pappso::xy.
◆ nearestGreater()
double pappso::Utils::nearestGreater |
( |
double |
value | ) |
|
|
static |
Definition at line 307 of file utils.cpp.
309 return std::nextafter(value, value + 1);
◆ pointerToString()
QString pappso::Utils::pointerToString |
( |
const void *const |
pointer | ) |
|
|
static |
◆ roundToDecimal32bitsAsLongLongInt()
Definition at line 131 of file utils.cpp.
134 if(
sizeof(
int *) == 4)
136 test_decimal = 100000000;
138 return (floor(input * test_decimal));
double pappso_double
A type definition for doubles.
◆ roundToDecimals()
◆ splitMzStringToDoubleVectorWithSpaces()
std::vector< double > pappso::Utils::splitMzStringToDoubleVectorWithSpaces |
( |
const QString & |
text, |
|
|
std::size_t & |
error_count |
|
) |
| |
|
static |
Definition at line 358 of file utils.cpp.
362 QStringList string_list =
363 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
367 std::vector<double> double_vector;
369 for(
int iter = 0; iter < string_list.size(); ++iter)
371 QString current_string = string_list.at(iter);
375 double current_double = current_string.toDouble(&ok);
377 if(!current_double && !ok)
383 double_vector.push_back(current_double);
386 return double_vector;
◆ splitSizetStringToSizetVectorWithSpaces()
std::vector< std::size_t > pappso::Utils::splitSizetStringToSizetVectorWithSpaces |
( |
const QString & |
text, |
|
|
std::size_t & |
error_count |
|
) |
| |
|
static |
Definition at line 391 of file utils.cpp.
396 QStringList string_list =
397 text.split(QRegularExpression(
"[\\s]+"), Qt::SkipEmptyParts);
402 std::vector<std::size_t> sizet_vector;
404 for(
int iter = 0; iter < string_list.size(); ++iter)
406 QString current_string = string_list.at(iter);
410 std::size_t current_sizet = current_string.toUInt(&ok);
412 if(!current_sizet && !ok)
418 sizet_vector.push_back(current_sizet);
◆ toUtf8StandardString()
std::string pappso::Utils::toUtf8StandardString |
( |
const QString & |
text | ) |
|
|
static |
◆ writeLexicalOrderedString()
void pappso::Utils::writeLexicalOrderedString |
( |
QTextStream * |
p_out, |
|
|
unsigned int |
num |
|
) |
| |
|
static |
◆ writeToFile()
bool pappso::Utils::writeToFile |
( |
const QString & |
text, |
|
|
const QString & |
file_name |
|
) |
| |
|
static |
Definition at line 172 of file utils.cpp.
175 QFile file(file_name);
177 if(file.open(QFile::WriteOnly | QFile::Truncate))
180 QTextStream out(&file);
◆ zeroDecimalsInValue()
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
Determine the number of zero decimals between the decimal point and the first non-zero decimal.
- Parameters
-
value | the value to be analyzed |
- Returns
- the number of '0' decimals between the decimal separator '.' and the first non-0 decimal
Definition at line 82 of file utils.cpp.
86 int intPart =
static_cast<int>(value);
90 double decimalPart = value - intPart;
96 while(decimalPart > 0)
Referenced by pappso::MzIntegrationParams::createArbitraryBins().
◆ endOfLineRegExp
QRegularExpression pappso::Utils::endOfLineRegExp = QRegularExpression("^\\s+$") |
|
static |
◆ mzListDataFormatRegExp
QRegularExpression pappso::Utils::mzListDataFormatRegExp |
|
static |
Regular expression matching <m/z value><non-numerical*>
Definition at line 56 of file utils.h.
◆ sizetListDataFormatRegExp
QRegularExpression pappso::Utils::sizetListDataFormatRegExp |
|
static |
Regular expression matching <size_t><non-numerical*>
Definition at line 59 of file utils.h.
◆ xyMassDataFormatRegExp
QRegularExpression pappso::Utils::xyMassDataFormatRegExp |
|
static |
The documentation for this class was generated from the following files: