Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#pragma once
/////////////////////// StdLib includes
#include <chrono>
/////////////////////// Qt includes
#include <QString>
#include <QByteArray>
#include <QRegularExpression>
#include <QTextStream>
/////////////////////// Local includes
#include "pappsomspp/core/types.h"
#include "pappsomspp/core/processing/specglob/types.h"
#include "pappsomspp/export-import-config.h"
#include "pappsomspp/core/amino_acid/aamodification.h"
namespace pappso
{
class Trace;
class PMSPP_LIB_DECL Utils
{
public:
static QString getVersion();
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp;
static QRegularExpression anythingButDigitDotDash;
static QRegularExpression signedDoubleNumberExponentialRegExp;
//! Regular expression matching <numerical value><non-numerical*><numerical
//! value>
static QRegularExpression xyMassDataFormatRegExp;
//! Regular expression matching <m/z value><non-numerical*>
static QRegularExpression mzListDataFormatRegExp;
//! Regular expression matching <size_t><non-numerical*>
static QRegularExpression sizetListDataFormatRegExp;
//! Regular expression that tracks the end of line in text files.
static QRegularExpression endOfLineRegExp;
static const QString getLexicalOrderedString(unsigned int num);
static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num);
static int zeroDecimalsInValue(pappso_double value);
static pappso_double roundToDecimals(pappso_double value, int decimal_places);
static long long int roundToDecimal32bitsAsLongLongInt(pappso_double input);
static std::string toUtf8StandardString(const QString &text);
static bool writeToFile(const QString &text, const QString &file_name);
static bool writeToFile(const std::vector<double> &data, int decimals, 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 double roundValueToDecimalPlaces(double value, int decimal_places, bool round_up = true);
static double nearestGreater(double value);
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);
/** @brief convenient function to transform a boolean to QString "TRUE" or
* "FALSE" QString returned is readable by R
* @return QString "TRUE" or "FALSE"
*/
static QString booleanToString(bool value);
/** @brief Convenience function to return a string describing the MzFormat of
* a file
* @return QString like "brukerTims" for enum value MzFormat::brukerTims.
*/
static QString msDataFormatAsString(Enums::MsDataFormat mz_format);
static QString fileReaderTypeAsString(Enums::FileReaderType file_reader_type);
/** @brief Convenience function to return a string describing the specglob
alingment type
* @return QString
*/
static QString toString(specglob::SpectralAlignmentType type);
/** @brief Convenience function to return a string describing the specglob
* experimental spectrum data point
* @return QString
*/
static QString toString(specglob::ExperimentalSpectrumDataPointType type);
/** @brief Convenience function to return a string naming the precision
* @return QString
*/
static QString toString(Enums::PrecisionUnit precision_unit);
/** @brief Convenience function to return a string describing the ion type
* @return QString
*/
static QString toString(Enums::PeptideIon m_ionType);
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa,
pappso_double mass);
static AaModificationP translateAaModificationFromUnimod(const QString &unimod_accession);
/** @brief convert vector of double into json array
*/
static QJsonArray toJson(const std::vector<double> &myVec);
};
} // namespace pappso
aamodification.h
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:152
pappso::Utils
Definition utils.h:51
pappso::Utils::extractScanNumberFromMzmlNativeId
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
Definition utils.cpp:285
pappso::Utils::chronoTimePointDebugString
static QString chronoTimePointDebugString(const QString &msg, std::chrono::system_clock::time_point chrono_time=std::chrono::system_clock::now())
Definition utils.cpp:398
pappso::Utils::toString
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
Definition utils.cpp:563
pappso::Utils::pointerToString
static QString pointerToString(const void *const pointer)
Definition utils.cpp:317
pappso::Utils::msDataFormatAsString
static QString msDataFormatAsString(Enums::MsDataFormat mz_format)
Convenience function to return a string describing the MzFormat of a file.
Definition utils.cpp:504
pappso::Utils::roundToDecimals
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition utils.cpp:140
pappso::Utils::anythingButDigitDotDash
static QRegularExpression anythingButDigitDotDash
Definition utils.h:55
pappso::Utils::almostEqual
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
Tell if both double values, are equal within the double representation capabilities of the platform.
Definition utils.cpp:326
pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition utils.cpp:677
pappso::Utils::splitMzStringToDoubleVectorWithSpaces
static std::vector< double > splitMzStringToDoubleVectorWithSpaces(const QString &text, std::size_t &error_count)
Definition utils.cpp:434
pappso::Utils::nearestGreater
static double nearestGreater(double value)
Definition utils.cpp:391
pappso::Utils::toUtf8StandardString
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:166
pappso::Utils::appendToFile
static bool appendToFile(const QString &text, const QString &file_name)
Definition utils.cpp:262
pappso::Utils::roundValueToDecimalPlaces
static double roundValueToDecimalPlaces(double value, int decimal_places, bool round_up=true)
Definition utils.cpp:371
pappso::Utils::fileReaderTypeAsString
static QString fileReaderTypeAsString(Enums::FileReaderType file_reader_type)
Definition utils.cpp:547
pappso::Utils::booleanToString
static QString booleanToString(bool value)
convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable ...
Definition utils.cpp:496
pappso::Utils::translateAaModificationFromUnimod
static AaModificationP translateAaModificationFromUnimod(const QString &unimod_accession)
Definition utils.cpp:753
pappso::Utils::chronoIntervalDebugString
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:413
pappso::Utils::roundToDecimal32bitsAsLongLongInt
static long long int roundToDecimal32bitsAsLongLongInt(pappso_double input)
Definition utils.cpp:150
pappso::Utils::writeToFile
static bool writeToFile(const QString &text, const QString &file_name)
Definition utils.cpp:216
pappso::Utils::splitSizetStringToSizetVectorWithSpaces
static std::vector< std::size_t > splitSizetStringToSizetVectorWithSpaces(const QString &text, std::size_t &error_count)
Definition utils.cpp:465
pappso::Utils::signedDoubleNumberExponentialRegExp
static QRegularExpression signedDoubleNumberExponentialRegExp
Definition utils.h:56
pappso::Utils::xyMassDataFormatRegExp
static QRegularExpression xyMassDataFormatRegExp
Regular expression matching <numerical value><non-numerical*><numericalvalue>.
Definition utils.h:60
pappso::Utils::mzListDataFormatRegExp
static QRegularExpression mzListDataFormatRegExp
Regular expression matching <m/z value><non-numerical*>.
Definition utils.h:63
pappso::Utils::unsignedDoubleNumberNoExponentialRegExp
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
Definition utils.h:54
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72
pappso::Utils::toJson
static QJsonArray toJson(const std::vector< double > &myVec)
convert vector of double into json array
Definition utils.cpp:793
pappso::Utils::sizetListDataFormatRegExp
static QRegularExpression sizetListDataFormatRegExp
Regular expression matching <size_t><non-numerical*>.
Definition utils.h:66
pappso::Utils::writeLexicalOrderedString
static void writeLexicalOrderedString(QTextStream *p_out, unsigned int num)
Definition utils.cpp:84
pappso::Utils::zeroDecimalsInValue
static int zeroDecimalsInValue(pappso_double value)
Determine the number of zero decimals between the decimal point and the first non-zero decimal.
Definition utils.cpp:102
pappso::Utils::endOfLineRegExp
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
Definition utils.h:69
pappso::Utils::getVersion
static QString getVersion()
Definition utils.cpp:669
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
pappso::Enums::MsDataFormat
MsDataFormat
Definition types.h:148
pappso::Enums::PeptideIon
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter).
Definition types.h:286
pappso::Enums::PrecisionUnit
PrecisionUnit
Definition types.h:96
pappso::Enums::FileReaderType
FileReaderType
Definition types.h:176
pappso::Enums::AminoAcidChar
AminoAcidChar
Definition types.h:196
pappso::specglob::SpectralAlignmentType
SpectralAlignmentType
Definition types.h:48
pappso::specglob::ExperimentalSpectrumDataPointType
ExperimentalSpectrumDataPointType
Definition types.h:78
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::AaModificationP
const AaModification * AaModificationP
Definition aamodification.h:52
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60
types.h
types.h