#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 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 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) |
|
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 233 of file utils.cpp.
247 double valueSum = std::abs(value1 + value2);
251 double valueDiff = std::abs(value1 - value2);
255 double epsilon = std::numeric_limits<double>::epsilon();
259 double scaleFactor = epsilon * valueSum * decimalPlaces;
267 bool res = valueDiff < scaleFactor
269 || valueDiff < std::numeric_limits<double>::min();
◆ appendToFile()
bool pappso::Utils::appendToFile |
( |
const QString & |
text, |
|
|
const QString & |
file_name |
|
) |
| |
|
static |
Definition at line 167 of file utils.cpp.
170 QFile file(file_name);
172 if(file.open(QFile::WriteOnly | QFile::Append))
175 QTextStream out(&file);
◆ 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 295 of file utils.cpp.
302 "%1 %2 min = %3 s = %4 ms = %5 "
305 .arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish -
308 .arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish -
311 .arg(std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish -
314 .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 279 of file utils.cpp.
285 tt = std::chrono::system_clock::to_time_t(chrono_time);
288 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 190 of file utils.cpp.
192 qDebug() <<
" " << spectrum_native_id;
193 QStringList native_id_list = spectrum_native_id.split(
"=");
194 if(native_id_list.size() < 2)
196 throw ExceptionNotFound(
197 QObject::tr(
"scan number not found in mzML native id %1")
198 .arg(spectrum_native_id));
216 return native_id_list.back().toULong();
◆ getLexicalOrderedString()
const QString pappso::Utils::getLexicalOrderedString |
( |
unsigned int |
num | ) |
|
|
static |
◆ pointerToString()
QString pappso::Utils::pointerToString |
( |
const void *const |
pointer | ) |
|
|
static |
◆ roundToDecimals()
◆ splitMzStringToDoubleVectorWithSpaces()
std::vector< double > pappso::Utils::splitMzStringToDoubleVectorWithSpaces |
( |
const QString & |
text, |
|
|
std::size_t & |
error_count |
|
) |
| |
|
static |
Definition at line 323 of file utils.cpp.
327 QStringList string_list =
328 text.split(QRegularExpression(
"[\\s]+"), QString::SkipEmptyParts);
332 std::vector<double> double_vector;
334 for(
int iter = 0; iter < string_list.size(); ++iter)
336 QString current_string = string_list.at(iter);
340 double current_double = current_string.toDouble(&ok);
342 if(!current_double && !ok)
348 double_vector.push_back(current_double);
351 return double_vector;
◆ splitSizetStringToSizetVectorWithSpaces()
std::vector< std::size_t > pappso::Utils::splitSizetStringToSizetVectorWithSpaces |
( |
const QString & |
text, |
|
|
std::size_t & |
error_count |
|
) |
| |
|
static |
Definition at line 356 of file utils.cpp.
361 QStringList string_list =
362 text.split(QRegularExpression(
"[\\s]+"), QString::SkipEmptyParts);
367 std::vector<std::size_t> sizet_vector;
369 for(
int iter = 0; iter < string_list.size(); ++iter)
371 QString current_string = string_list.at(iter);
375 std::size_t current_sizet = current_string.toUInt(&ok);
377 if(!current_sizet && !ok)
383 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 |
Definition at line 63 of file utils.cpp.
65 *p_out << (char)(log10(num) + 97) << num;
◆ writeToFile()
bool pappso::Utils::writeToFile |
( |
const QString & |
text, |
|
|
const QString & |
file_name |
|
) |
| |
|
static |
Definition at line 144 of file utils.cpp.
147 QFile file(file_name);
149 if(file.open(QFile::WriteOnly | QFile::Truncate))
152 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 81 of file utils.cpp.
83 int intPart =
static_cast<int>(value);
85 double decimalPart = value - intPart;
◆ 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: