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"
43
44
45namespace pappso
46{
47
48class Trace;
49
51{
52 public:
53 static QString getVersion();
54 static QRegularExpression unsignedDoubleNumberNoExponentialRegExp;
55 static QRegularExpression anythingButDigitDotDash;
56 static QRegularExpression signedDoubleNumberExponentialRegExp;
57
58 //! Regular expression matching <numerical value><non-numerical*><numerical
59 //! value>
60 static QRegularExpression xyMassDataFormatRegExp;
61
62 //! Regular expression matching <m/z value><non-numerical*>
63 static QRegularExpression mzListDataFormatRegExp;
64
65 //! Regular expression matching <size_t><non-numerical*>
66 static QRegularExpression sizetListDataFormatRegExp;
67
68 //! Regular expression that tracks the end of line in text files.
69 static QRegularExpression endOfLineRegExp;
70
71 static const QString getLexicalOrderedString(unsigned int num);
72 static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num);
73
74 static int zeroDecimalsInValue(pappso_double value);
75 static pappso_double roundToDecimals(pappso_double value, int decimal_places);
76 static long long int roundToDecimal32bitsAsLongLongInt(pappso_double input);
77
78 static std::string toUtf8StandardString(const QString &text);
79
80 static bool writeToFile(const QString &text, const QString &file_name);
81 static bool appendToFile(const QString &text, const QString &file_name);
82 static std::size_t 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 chronoTimePointDebugString(
91 const QString &msg,
92 std::chrono::system_clock::time_point chrono_time = std::chrono::system_clock::now());
93
94 static QString chronoIntervalDebugString(
95 const QString &msg,
96 std::chrono::system_clock::time_point chrono_start,
97 std::chrono::system_clock::time_point chrono_finish = std::chrono::system_clock::now());
98
99 static std::vector<double> splitMzStringToDoubleVectorWithSpaces(const QString &text,
100 std::size_t &error_count);
101
102 static std::vector<std::size_t> splitSizetStringToSizetVectorWithSpaces(const QString &text,
103 std::size_t &error_count);
104
105 /** @brief convenient function to transform a boolean to QString "TRUE" or
106 * "FALSE" QString returned is readable by R
107 * @return QString "TRUE" or "FALSE"
108 */
109 static QString booleanToString(bool value);
110
111 /** @brief Convenience function to return a string describing the MzFormat of
112 * a file
113 * @return QString like "brukerTims" for enum value MzFormat::brukerTims.
114 */
115 static QString msDataFormatAsString(Enums::MsDataFormat mz_format);
116 static QString fileReaderTypeAsString(Enums::FileReaderType file_reader_type);
117
118 /** @brief Convenience function to return a string describing the specglob
119 alingment type
120 * @return QString
121 */
122 static QString toString(specglob::SpectralAlignmentType type);
123
124 /** @brief Convenience function to return a string describing the specglob
125 * experimental spectrum data point
126 * @return QString
127 */
129
130
131 /** @brief Convenience function to return a string naming the precision
132 * @return QString
133 */
134 static QString toString(Enums::PrecisionUnit precision_unit);
135
136 /** @brief Convenience function to return a string describing the ion type
137 * @return QString
138 */
139 static QString toString(Enums::PeptideIon m_ionType);
140
141
142 static AaModificationP
144
145
146 static AaModificationP translateAaModificationFromUnimod(const QString &unimod_accession);
147};
148
149} // namespace pappso
A simple container of DataPoint instances.
Definition trace.h:148
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
Definition utils.cpp:258
static QString chronoTimePointDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_time=std::chrono::system_clock::now())
Definition utils.cpp:352
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
Definition utils.cpp:517
static QString pointerToString(const void *const pointer)
Definition utils.cpp:290
static QString msDataFormatAsString(Enums::MsDataFormat mz_format)
Convenience function to return a string describing the MzFormat of a file.
Definition utils.cpp:458
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition utils.cpp:140
static QRegularExpression anythingButDigitDotDash
Definition utils.h:55
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
Definition utils.cpp:299
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition utils.cpp:631
static std::vector< double > splitMzStringToDoubleVectorWithSpaces(const QString &text, std::size_t &error_count)
Definition utils.cpp:388
static double nearestGreater(double value)
Definition utils.cpp:345
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:162
static bool appendToFile(const QString &text, const QString &file_name)
Definition utils.cpp:235
static QString fileReaderTypeAsString(Enums::FileReaderType file_reader_type)
Definition utils.cpp:501
static QString booleanToString(bool value)
convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable ...
Definition utils.cpp:450
static AaModificationP translateAaModificationFromUnimod(const QString &unimod_accession)
Definition utils.cpp:707
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())
Definition utils.cpp:367
static long long int roundToDecimal32bitsAsLongLongInt(pappso_double input)
Definition utils.cpp:150
static bool writeToFile(const QString &text, const QString &file_name)
Definition utils.cpp:212
static std::vector< std::size_t > splitSizetStringToSizetVectorWithSpaces(const QString &text, std::size_t &error_count)
Definition utils.cpp:419
static QRegularExpression signedDoubleNumberExponentialRegExp
Definition utils.h:56
static QRegularExpression xyMassDataFormatRegExp
Definition utils.h:60
static QRegularExpression mzListDataFormatRegExp
Regular expression matching <m/z value><non-numerical*>
Definition utils.h:63
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
Definition utils.h:54
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72
static QRegularExpression sizetListDataFormatRegExp
Regular expression matching <size_t><non-numerical*>
Definition utils.h:66
static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num)
Definition utils.cpp:84
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
Definition utils.cpp:102
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
Definition utils.h:69
static QString getVersion()
Definition utils.cpp:623
#define PMSPP_LIB_DECL
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter)
Definition types.h:286
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
const AaModification * AaModificationP
double pappso_double
A type definition for doubles.
Definition types.h:61