libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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"
41#include "exportinmportconfig.h"
42
43
44namespace pappso
45{
46
47class Trace;
48
50{
51 public:
52 static QRegularExpression unsignedDoubleNumberNoExponentialRegExp;
53 static QRegularExpression anythingButDigitDotDash;
54 static QRegularExpression signedDoubleNumberExponentialRegExp;
55
56 //! Regular expression matching <numerical value><non-numerical*><numerical
57 //! value>
58 static QRegularExpression xyMassDataFormatRegExp;
59
60 //! Regular expression matching <m/z value><non-numerical*>
61 static QRegularExpression mzListDataFormatRegExp;
62
63 //! Regular expression matching <size_t><non-numerical*>
64 static QRegularExpression sizetListDataFormatRegExp;
65
66 //! Regular expression that tracks the end of line in text files.
67 static QRegularExpression endOfLineRegExp;
68
69 static const QString getLexicalOrderedString(unsigned int num);
70 static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num);
71
72 static int zeroDecimalsInValue(pappso_double value);
73 static pappso_double roundToDecimals(pappso_double value, int decimal_places);
74 static long long int
75 roundToDecimal32bitsAsLongLongInt(pappso::pappso_double input);
76
77 static std::string toUtf8StandardString(const QString &text);
78
79 static bool writeToFile(const QString &text, const QString &file_name);
80 static bool appendToFile(const QString &text, const QString &file_name);
81 static std::size_t
82 extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id);
83
84 static QString pointerToString(const void *const pointer);
85
86 static bool almostEqual(double value1, double value2, int decimalPlaces = 10);
87
88 static double nearestGreater(double value);
89
90 static QString
91 chronoTimePointDebugString(const QString &msg,
92 std::chrono::system_clock::time_point chrono_time =
93 std::chrono::system_clock::now());
94
95 static QString chronoIntervalDebugString(
96 const QString &msg,
97 std::chrono::system_clock::time_point chrono_start,
98 std::chrono::system_clock::time_point chrono_finish =
99 std::chrono::system_clock::now());
100
101 static std::vector<double>
102 splitMzStringToDoubleVectorWithSpaces(const QString &text,
103 std::size_t &error_count);
104
105 static std::vector<std::size_t>
106 splitSizetStringToSizetVectorWithSpaces(const QString &text,
107 std::size_t &error_count);
108
109 /** @brief convenient function to transform a boolean to QString "TRUE" or
110 * "FALSE" QString returned is readable by R
111 * @return QString "TRUE" or "FALSE"
112 */
113 static QString booleanToString(bool value);
114
115 /** @brief Convenience function to return a string describing the MzFormat of
116 * a file
117 * @return QString like "brukerTims" for enum value MzFormat::brukerTims.
118 */
119 static QString msDataFormatAsString(MsDataFormat mz_format);
120 static QString fileReaderTypeAsString(FileReaderType file_reader_type);
121
122 /** @brief Convenience function to return a string describing the specglob
123 alingment type
124 * @return QString
125 */
126 static QString toString(specglob::SpectralAlignmentType type);
127
128 /** @brief Convenience function to return a string describing the specglob
129 * experimental spectrum data point
130 * @return QString
131 */
132 static QString toString(specglob::ExperimentalSpectrumDataPointType type);
133};
134
135} // namespace pappso
static QRegularExpression anythingButDigitDotDash
Definition utils.h:53
static QRegularExpression signedDoubleNumberExponentialRegExp
Definition utils.h:54
static QRegularExpression xyMassDataFormatRegExp
Definition utils.h:58
static QRegularExpression mzListDataFormatRegExp
Regular expression matching <m/z value><non-numerical*>
Definition utils.h:61
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
Definition utils.h:52
static QRegularExpression sizetListDataFormatRegExp
Regular expression matching <size_t><non-numerical*>
Definition utils.h:64
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
Definition utils.h:67
#define PMSPP_LIB_DECL
ExperimentalSpectrumDataPointType
Definition types.h:78
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
MsDataFormat
Definition types.h:120
double pappso_double
A type definition for doubles.
Definition types.h:50
FileReaderType
Definition types.h:147
SpecGlobTool types definition.
This header contains all the type re-definitions and all the global variables definitions used in the...