libpappsomspp
Library for mass spectrometry
utils.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
3 *
4 * This file is part of the PAPPSOms++ library.
5 *
6 * PAPPSOms++ is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * PAPPSOms++ is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Contributors:
20 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
21 *implementation
22 ******************************************************************************/
23
24
25#pragma once
26
27
28/////////////////////// StdLib includes
29#include <chrono>
30
31/////////////////////// Qt includes
32#include <QString>
33#include <QByteArray>
34#include <QRegularExpression>
35#include <QTextStream>
36
37
38/////////////////////// Local includes
39#include "types.h"
40#include "exportinmportconfig.h"
41
42
43namespace pappso
44{
45
46class Trace;
47
49{
50 public:
51 //! Regular expression matching <numerical value><non-numerical*><numerical
52 //! value>
53 static QRegularExpression xyMassDataFormatRegExp;
54
55 //! Regular expression matching <m/z value><non-numerical*>
56 static QRegularExpression mzListDataFormatRegExp;
57
58 //! Regular expression matching <size_t><non-numerical*>
59 static QRegularExpression sizetListDataFormatRegExp;
60
61 //! Regular expression that tracks the end of line in text files.
62 static QRegularExpression endOfLineRegExp;
63
64 static const QString getLexicalOrderedString(unsigned int num);
65 static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num);
66
67 static int zeroDecimalsInValue(pappso_double value);
68 static pappso_double roundToDecimals(pappso_double value, int decimal_places);
69 static long long int
70 roundToDecimal32bitsAsLongLongInt(pappso::pappso_double input);
71
72 static std::string toUtf8StandardString(const QString &text);
73
74 static bool writeToFile(const QString &text, const QString &file_name);
75 static bool appendToFile(const QString &text, const QString &file_name);
76 static std::size_t
77 extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id);
78
79 static QString pointerToString(const void *const pointer);
80
81 static bool almostEqual(double value1, double value2, int decimalPlaces = 10);
82
83 static double nearestGreater(double value);
84
85 static QString
86 chronoTimePointDebugString(const QString &msg,
87 std::chrono::system_clock::time_point chrono_time =
88 std::chrono::system_clock::now());
89
90 static QString chronoIntervalDebugString(
91 const QString &msg,
92 std::chrono::system_clock::time_point chrono_start,
93 std::chrono::system_clock::time_point chrono_finish =
94 std::chrono::system_clock::now());
95
96 static std::vector<double>
97 splitMzStringToDoubleVectorWithSpaces(const QString &text,
98 std::size_t &error_count);
99
100 static std::vector<std::size_t>
101 splitSizetStringToSizetVectorWithSpaces(const QString &text,
102 std::size_t &error_count);
103
104 /** @brief convenient function to transform a boolean to QString "TRUE" or
105 * "FALSE" QString returned is readable by R
106 * @return QString "TRUE" or "FALSE"
107 */
108 static QString booleanToString(bool value);
109
110 /** @brief Convenience function to return a string describing the MzFormat of
111 * a file
112 * @return QString like "brukerTims" for enum value MzFormat::brukerTims.
113 */
114 static QString mzFormatAsString(MzFormat mz_format);
115};
116
117} // namespace pappso
static QRegularExpression xyMassDataFormatRegExp
Definition: utils.h:53
static QRegularExpression mzListDataFormatRegExp
Regular expression matching <m/z value><non-numerical*>
Definition: utils.h:56
static QRegularExpression sizetListDataFormatRegExp
Regular expression matching <size_t><non-numerical*>
Definition: utils.h:59
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
Definition: utils.h:62
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
MzFormat
Definition: types.h:108
double pappso_double
A type definition for doubles.
Definition: types.h:49
This header contains all the type re-definitions and all the global variables definitions used in the...