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 
43 namespace pappso
44 {
45 
46 class Trace;
47 
48 class PMSPP_LIB_DECL Utils
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 
70  static std::string toUtf8StandardString(const QString &text);
71 
72  static bool writeToFile(const QString &text, const QString &file_name);
73  static bool appendToFile(const QString &text, const QString &file_name);
74  static std::size_t
75  extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id);
76 
77  static QString pointerToString(const void *const pointer);
78 
79  static bool almostEqual(double value1, double value2, int decimalPlaces = 10);
80 
81  static QString
82  chronoTimePointDebugString(const QString &msg,
83  std::chrono::system_clock::time_point chrono_time =
84  std::chrono::system_clock::now());
85 
86  static QString chronoIntervalDebugString(
87  const QString &msg,
88  std::chrono::system_clock::time_point chrono_start,
89  std::chrono::system_clock::time_point chrono_finish =
90  std::chrono::system_clock::now());
91 
92  static std::vector<double>
93  splitMzStringToDoubleVectorWithSpaces(const QString &text,
94  std::size_t &error_count);
95 
96  static std::vector<std::size_t>
97  splitSizetStringToSizetVectorWithSpaces(const QString &text,
98  std::size_t &error_count);
99 };
100 
101 } // namespace pappso
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:69
types.h
This header contains all the type re-definitions and all the global variables definitions used in the...
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
exportinmportconfig.h