Loading...
Searching...
No Matches
pappso::Utils Class Reference

`#include <utils.h>`

## Static Public Member Functions

static QString | getVersion ()
static const QString | getLexicalOrderedString (unsigned int num)
static void | writeLexicalOrderedString (QTextStream *p_out, unsigned int num)
static int | zeroDecimalsInValue (pappso_double value)
| Determine the number of zero decimals between the decimal point and the first non-zero decimal.
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)
| Tell if both double values, are equal within the double representation capabilities of the platform.
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)
static QString | booleanToString (bool value)
| convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable by R
static QString | msDataFormatAsString (Enums::MsDataFormat mz_format)
| Convenience function to return a string describing the MzFormat of a file.
static QString | fileReaderTypeAsString (Enums::FileReaderType file_reader_type)
static QString | toString (specglob::SpectralAlignmentType type)
| Convenience function to return a string describing the specglob alingment type.
static QString | toString (specglob::ExperimentalSpectrumDataPointType type)
| Convenience function to return a string describing the specglob experimental spectrum data point.
static QString | toString (Enums::PrecisionUnit precision_unit)
| Convenience function to return a string naming the precision.
static QString | toString (Enums::PeptideIon m_ionType)
| Convenience function to return a string describing the ion type.
static AaModificationP | guessAaModificationPbyMonoisotopicMassDelta (Enums::AminoAcidChar aa, pappso_double mass)
static AaModificationP | translateAaModificationFromUnimod (const QString &unimod_accession)
static QJsonArray | toJson (const std::vector< double > &myVec)
| convert vector of double into json array

## Static Public Attributes

static QRegularExpression | unsignedDoubleNumberNoExponentialRegExp
static QRegularExpression | anythingButDigitDotDash = QRegularExpression("[^\\d^\\.^-]+")
static QRegularExpression | signedDoubleNumberExponentialRegExp
static QRegularExpression | xyMassDataFormatRegExp
| Regular expression matching <numerical value><non-numerical*><numerical value>.
static QRegularExpression | mzListDataFormatRegExp
| Regular expression matching <m/z value><non-numerical*>.
static QRegularExpression | sizetListDataFormatRegExp
| Regular expression matching <size_t><non-numerical*>.
static QRegularExpression | endOfLineRegExp = QRegularExpression("^\\s+$")
| Regular expression that tracks the end of line in text files.

## Detailed Description

Definition at line 50 of file utils.h.

## Member Function Documentation

## almostEqual()

bool pappso::Utils::almostEqual | ( | double | value1,
|  | double | value2,
|  | int | decimalPlaces = 10 )

static

Tell if both double values, are equal within the double representation capabilities of the platform.

Definition at line 326 of file utils.cpp.

{
// QString value1String = QString("%1").arg(value1,
// 0, 'f', 60);
// QString value2String = QString("%1").arg(value2,
// 0, 'f', 60);
// qWarning() << __FILE__ << __LINE__ << __FUNCTION__
//<< "value1:" << value1String << "value2:" << value2String;
// The machine epsilon has to be scaled to the magnitude of the values used
// and multiplied by the desired precision in ULPs (units in the last place)
// (decimal places).
double valueSum = std::abs(value1 + value2);
// QString valueSumString = QString("%1").arg(valueSum,
// 0, 'f', 60);
double valueDiff = std::abs(value1 - value2);
// QString valueDiffString = QString("%1").arg(valueDiff,
// 0, 'f', 60);
double epsilon = std::numeric_limits<double>::epsilon();
// QString epsilonString = QString("%1").arg(epsilon,
// 0, 'f', 60);
double scaleFactor = epsilon * valueSum * decimalPlaces;
// QString scaleFactorString = QString("%1").arg(scaleFactor,
// 0, 'f', 60);
// qWarning() << "valueDiff:" << valueDiffString << "valueSum:" <<
// valueSumString <<
//"epsilon:" << epsilonString << "scaleFactor:" << scaleFactorString;
bool res = valueDiff < scaleFactor
// unless the result is subnormal:
|| valueDiff < std::numeric_limits<double>::min();
// qWarning() << __FILE__ << __LINE__ << __FUNCTION__
//<< "returning res:" << res;
return res;
}
pappso::Enums::PrecisionUnit::res
@ res
Definition types.h:100

Referenced by pappso::Trace::removeZeroYDataPoints().

## appendToFile()

bool pappso::Utils::appendToFile | ( | const QString & | text,
|  | const QString & | file_name )

static

Definition at line 262 of file utils.cpp.

{
QFile file(file_name);
if(file.open(QFile::WriteOnly | QFile::Append))
{
QTextStream out(&file);
out << text;
out.flush();
file.close();
return true;
}
return false;
}

## booleanToString()

QString pappso::Utils::booleanToString | ( | bool | value | ) |

static

convenient function to transform a boolean to QString "TRUE" or "FALSE" QString returned is readable by R

Returns
  QString "TRUE" or "FALSE"

Definition at line 477 of file utils.cpp.

{
if(value)
return "TRUE";
return "FALSE";
}

## chronoIntervalDebugString()

QString pappso::Utils::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

Definition at line 394 of file utils.cpp.

{
QString debug_text =
QString(
"%1 %2 min = %3 s = %4 ms = %5 "
"µs\n")
.arg(msg)
.arg(std::chrono::duration_cast<std::chrono::minutes>(chrono_finish - chrono_start).count())
.arg(std::chrono::duration_cast<std::chrono::seconds>(chrono_finish - chrono_start).count())
.arg(
std::chrono::duration_cast<std::chrono::milliseconds>(chrono_finish - chrono_start).count())
.arg(std::chrono::duration_cast<std::chrono::microseconds>(chrono_finish - chrono_start)
.count());
return debug_text;
}

## chronoTimePointDebugString()

QString pappso::Utils::chronoTimePointDebugString | ( | const QString & | msg,
|  | std::chrono::system_clock::time_point | chrono_time = std::chrono::system_clock::now() )

static

Definition at line 379 of file utils.cpp.

{
time_t tt;
tt = std::chrono::system_clock::to_time_t(chrono_time);
QString debug_text = QString("%1 - %2\n").arg(msg).arg(QString::fromLatin1(ctime(&tt)));
return debug_text;
}

## extractScanNumberFromMzmlNativeId()

std::size_t pappso::Utils::extractScanNumberFromMzmlNativeId | ( | const QString & | spectrum_native_id | ) |

static

TODO activate this in a future release to ensure scan number for(auto i = 0; i < native_id_list.size(); i += 2) { if(native_id_list[i] == "scan") { return native_id_list[i + 1].toULong(); } }

throw ExceptionNotFound( QObject::tr("scan number not found in mzML native id %1") .arg(spectrum_native_id));

Definition at line 285 of file utils.cpp.

{
qDebug() << " " << spectrum_native_id;
QStringList native_id_list = spectrum_native_id.split("=");
if(native_id_list.size() < 2)
{
throw ExceptionNotFound(
QObject::tr("scan number not found in mzML native id %1").arg(spectrum_native_id));
}
else
{
/** TODO activate this in a future release to ensure scan number
for(auto i = 0; i < native_id_list.size(); i += 2)
{
if(native_id_list[i] == "scan")
{
return native_id_list[i + 1].toULong();
}
}
throw ExceptionNotFound(
QObject::tr("scan number not found in mzML native id %1")
.arg(spectrum_native_id));
*/
return native_id_list.back().toULong();
}
return 0;
}

Referenced by pappso::masschroq::PrecursorParser::setQualifiedMassSpectrum().

## fileReaderTypeAsString()

QString pappso::Utils::fileReaderTypeAsString | ( | Enums::FileReaderType | file_reader_type | ) |

static

Definition at line 528 of file utils.cpp.

{
if(file_reader_type == Enums::FileReaderType::pwiz)
return "pwiz";
else if(file_reader_type == Enums::FileReaderType::xy)
return "xy";
else if(file_reader_type == Enums::FileReaderType::tims)
return "tims";
else if(file_reader_type == Enums::FileReaderType::tims_frames)
return "tims_frames";
else
return "unknown";
}
pappso::Enums::FileReaderType::pwiz
@ pwiz
using libpwizlite
Definition types.h:177
pappso::Enums::FileReaderType::xy
@ xy
Definition types.h:179
pappso::Enums::FileReaderType::tims_frames
@ tims_frames
Definition types.h:182
pappso::Enums::FileReaderType::tims
@ tims
TimsMsRunReader : each scan is returned as a mass spectrum.
Definition types.h:181

References pappso::Enums::pwiz, pappso::Enums::tims, pappso::Enums::tims_frames, and pappso::Enums::xy.

## getLexicalOrderedString()

const QString pappso::Utils::getLexicalOrderedString | ( | unsigned int | num | ) |

static

Definition at line 72 of file utils.cpp.

{
int size = log10(num);
size += 97;
QLatin1Char latin1_char(size);
QString base(latin1_char);
base.append(QString().setNum(num));
return (base);
}
pappso::Enums::AxisScale::log10
@ log10
Definition types.h:270

Referenced by pappso::GrpGroup::getGroupingId(), pappso::GrpPeptide::getGroupingId(), pappso::GrpProtein::getGroupingId(), pappso::GrpSubGroup::getGroupingId(), pappso::BafAsciiFileReader::getMsRunIds(), pappso::MzcborMsFileReader::getMsRunIds(), pappso::PwizMsFileReader::getMsRunIds(), and pappso::XyMsFileReader::getMsRunIds().

## getVersion()

QString pappso::Utils::getVersion | ( |  | ) |

static

Definition at line 650 of file utils.cpp.

{
QString version(PAPPSOMSPP_VERSION);
return version;
}
PAPPSOMSPP_VERSION
#define PAPPSOMSPP_VERSION
Definition config.h:6

References PAPPSOMSPP_VERSION.

Referenced by pappso::cbor::psm::MzIdentMlReader::MzIdentMlReader(), pappso::cbor::psm::SageFileReader::SageFileReader(), pappso::cbor::psm::PsmFileScanProcessAndCopy::informationsReady(), and pappso::cbor::CborStreamWriter::writeInformations().

## guessAaModificationPbyMonoisotopicMassDelta()

pappso::AaModificationP pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta | ( | Enums::AminoAcidChar | aa,
|  | pappso::pappso_double | mass )

static

Definition at line 658 of file utils.cpp.

{
pappso::PrecisionPtr precision = pappso::PrecisionFactory::getDaltonInstance(0.01);
pappso::AaModificationP oxidation =
pappso::AaModification::getInstance("MOD:00425"); // MOD:00425 15.994915
if((aa == pappso::Enums::AminoAcidChar::methionine) &&
pappso::MzRange(oxidation->getMass(), precision).contains(mass))
{
return oxidation;
}
pappso::AaModificationP iodoacetamide =
pappso::AaModification::getInstance("MOD:00397"); // 57.021465
if(pappso::MzRange(iodoacetamide->getMass(), precision).contains(mass))
{
return iodoacetamide;
}
pappso::AaModificationP acetylated =
pappso::AaModification::getInstance("MOD:00408"); // 42.010567
if(pappso::MzRange(acetylated->getMass(), precision).contains(mass))
{
return acetylated;
}
pappso::AaModificationP phosphorylated =
pappso::AaModification::getInstance("MOD:00696"); // 79.96633
if(pappso::MzRange(phosphorylated->getMass(), precision).contains(mass))
{
return phosphorylated;
}
pappso::AaModificationP ammonia = pappso::AaModification::getInstance("MOD:01160"); //-17.026548
if(pappso::MzRange(ammonia->getMass(), precision).contains(mass))
{
return ammonia;
}
pappso::AaModificationP dehydrated =
pappso::AaModification::getInstance("MOD:00704"); //-18.010565
if(pappso::MzRange(dehydrated->getMass(), precision).contains(mass))
{
return dehydrated;
}
pappso::AaModificationP dimethylated =
pappso::AaModification::getInstance("MOD:00429"); // 28.0313
if(pappso::MzRange(dimethylated->getMass(), precision).contains(mass))
{
return dimethylated;
}
pappso::AaModificationP dimethylated_medium = pappso::AaModification::getInstance("MOD:00552");
if(pappso::MzRange(dimethylated_medium->getMass(), precision).contains(mass))
{
return dimethylated_medium;
}
pappso::AaModificationP dimethylated_heavy = pappso::AaModification::getInstance("MOD:00638");
if(pappso::MzRange(dimethylated_heavy->getMass(), precision).contains(mass))
{
return dimethylated_heavy;
}
pappso::AaModificationP DimethylpyrroleAdduct = pappso::AaModification::getInstance("MOD:00628");
if(pappso::MzRange(DimethylpyrroleAdduct->getMass(), precision).contains(mass))
{
return DimethylpyrroleAdduct;
}
// modification not found, creating customized mod :
return pappso::AaModification::getInstanceCustomizedMod(mass);
throw pappso::ExceptionNotFound(
QObject::tr("Utils::guessAaModificationPbyMonoisotopicMassDelta => "
"modification not found for mass %1")
.arg(mass));
}
pappso::AaModification::getMass
pappso_double getMass() const
Definition aamodification.cpp:759
pappso::AaModification::getInstance
static AaModificationP getInstance(const QString &accession)
Definition aamodification.cpp:368
pappso::AaModification::getInstanceCustomizedMod
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
Definition aamodification.cpp:349
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:136
pappso::Enums::AminoAcidChar::methionine
@ methionine
Definition types.h:207
pappso::AaModificationP
const AaModification * AaModificationP
Definition aamodification.h:52
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122

References pappso::MzRange::contains(), pappso::PrecisionFactory::getDaltonInstance(), pappso::AaModification::getInstance(), pappso::AaModification::getInstanceCustomizedMod(), pappso::AaModification::getMass(), and pappso::Enums::methionine.

Referenced by pappso::cbor::psm::SageReader::getStaticModificationList(), pappso::cbor::psm::SageReader::getVariableModificationList(), pappso::PeptideProFormaParser::parseStringToPeptide(), and pappso::cbor::psm::MzIdentMlReader::readPeptide().

## msDataFormatAsString()

QString pappso::Utils::msDataFormatAsString | ( | Enums::MsDataFormat | mz_format | ) |

static

Convenience function to return a string describing the MzFormat of a file.

Returns
  QString like "brukerTims" for enum value MzFormat::brukerTims.

Definition at line 485 of file utils.cpp.

{
if(mz_format == Enums::MsDataFormat::mzML)
return "mzML";
else if(mz_format == Enums::MsDataFormat::mzXML)
return "mzXML";
else if(mz_format == Enums::MsDataFormat::MGF)
return "MGF";
else if(mz_format == Enums::MsDataFormat::SQLite3)
return "SQLite3";
else if(mz_format == Enums::MsDataFormat::xy)
return "xy";
else if(mz_format == Enums::MsDataFormat::mz5)
return "mz5";
else if(mz_format == Enums::MsDataFormat::msn)
return "msn";
else if(mz_format == Enums::MsDataFormat::abSciexWiff)
return "abSciexWiff";
else if(mz_format == Enums::MsDataFormat::abSciexT2D)
return "abSciexT2D";
else if(mz_format == Enums::MsDataFormat::agilentMassHunter)
return "agilentMassHunter";
else if(mz_format == Enums::MsDataFormat::thermoRaw)
return "thermoRaw";
else if(mz_format == Enums::MsDataFormat::watersRaw)
return "watersRaw";
else if(mz_format == Enums::MsDataFormat::brukerFid)
return "brukerFid";
else if(mz_format == Enums::MsDataFormat::brukerYep)
return "brukerYep";
else if(mz_format == Enums::MsDataFormat::brukerBaf)
return "brukerBaf";
else if(mz_format == Enums::MsDataFormat::brukerTims)
return "brukerTims";
else if(mz_format == Enums::MsDataFormat::brukerBafAscii)
return "brukerBafAscii";
else
return "unknown";
}
pappso::Enums::MsDataFormat::brukerTims
@ brukerTims
Definition types.h:165
pappso::Enums::MsDataFormat::msn
@ msn
Definition types.h:156
pappso::Enums::MsDataFormat::xy
@ xy
(x,y) format
Definition types.h:154
pappso::Enums::MsDataFormat::agilentMassHunter
@ agilentMassHunter
Definition types.h:159
pappso::Enums::MsDataFormat::abSciexT2D
@ abSciexT2D
Definition types.h:158
pappso::Enums::MsDataFormat::mzXML
@ mzXML
mzXML
Definition types.h:151
pappso::Enums::MsDataFormat::watersRaw
@ watersRaw
Definition types.h:161
pappso::Enums::MsDataFormat::mz5
@ mz5
Definition types.h:155
pappso::Enums::MsDataFormat::brukerBaf
@ brukerBaf
Definition types.h:164
pappso::Enums::MsDataFormat::mzML
@ mzML
mzML
Definition types.h:150
pappso::Enums::MsDataFormat::abSciexWiff
@ abSciexWiff
Definition types.h:157
pappso::Enums::MsDataFormat::brukerBafAscii
@ brukerBafAscii
Definition types.h:166
pappso::Enums::MsDataFormat::brukerFid
@ brukerFid
Definition types.h:162
pappso::Enums::MsDataFormat::SQLite3
@ SQLite3
SQLite3 format.
Definition types.h:153
pappso::Enums::MsDataFormat::MGF
@ MGF
Mascot format.
Definition types.h:152
pappso::Enums::MsDataFormat::thermoRaw
@ thermoRaw
Definition types.h:160
pappso::Enums::MsDataFormat::brukerYep
@ brukerYep
Definition types.h:163

References pappso::Enums::abSciexT2D, pappso::Enums::abSciexWiff, pappso::Enums::agilentMassHunter, pappso::Enums::brukerBaf, pappso::Enums::brukerBafAscii, pappso::Enums::brukerFid, pappso::Enums::brukerTims, pappso::Enums::brukerYep, pappso::Enums::MGF, pappso::Enums::msn, pappso::Enums::mz5, pappso::Enums::mzML, pappso::Enums::mzXML, pappso::Enums::SQLite3, pappso::Enums::thermoRaw, pappso::Enums::watersRaw, and pappso::Enums::xy.

## nearestGreater()

double pappso::Utils::nearestGreater | ( | double | value | ) |

static

Definition at line 372 of file utils.cpp.

{
return std::nextafter(value, value + 1);
}

## pointerToString()

QString pappso::Utils::pointerToString | ( | const void *const | pointer | ) |

static

Definition at line 317 of file utils.cpp.

{
return QString("%1").arg((quintptr)pointer, QT_POINTER_SIZE * 2, 16, QChar('0'));
}

Referenced by pappso::MsRunDataSetTreeNode::toString(), and pappso::QualifiedMassSpectrum::toString().

## roundToDecimal32bitsAsLongLongInt()

long long int pappso::Utils::roundToDecimal32bitsAsLongLongInt | ( | pappso::pappso_double | input | ) |

static

Definition at line 150 of file utils.cpp.

{
pappso::pappso_double test_decimal = 100000000000;
if(sizeof(int *) == 4)
{ // 32bits
test_decimal = 100000000;
}
return (floor(input * test_decimal));
}
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60

## roundToDecimals()

pappso_double pappso::Utils::roundToDecimals | ( | pappso_double | value,
|  | int | decimal_places )

static

Definition at line 140 of file utils.cpp.

{
if(decimal_places < 0)
return value;
return ceil((value * pow(10, decimal_places)) - 0.49) / pow(10, decimal_places);
}

Referenced by pappso::TraceMinusCombiner::combine(), and pappso::TracePlusCombiner::combine().

## splitMzStringToDoubleVectorWithSpaces()

std::vector< double > pappso::Utils::splitMzStringToDoubleVectorWithSpaces | ( | const QString & | text,
|  | std::size_t & | error_count )

static

Definition at line 415 of file utils.cpp.

{
QStringList string_list = text.split(QRegularExpression("[\\s]+"), Qt::SkipEmptyParts);
// qDebug() << "string list:" << string_list;
std::vector<double> double_vector;
for(int iter = 0; iter < string_list.size(); ++iter)
{
QString current_string = string_list.at(iter);
bool ok = false;
double current_double = current_string.toDouble(&ok);
if(!current_double && !ok)
{
++error_count;
continue;
}
double_vector.push_back(current_double);
}
return double_vector;
}

## splitSizetStringToSizetVectorWithSpaces()

std::vector< std::size_t > pappso::Utils::splitSizetStringToSizetVectorWithSpaces | ( | const QString & | text,
|  | std::size_t & | error_count )

static

Definition at line 446 of file utils.cpp.

{
// qDebug() << "Parsing text:" << text;
QStringList string_list = text.split(QRegularExpression("[\\s]+"), Qt::SkipEmptyParts);
// qDebug() << "string list size:" << string_list.size()
//<< "values:" << string_list;
std::vector<std::size_t> sizet_vector;
for(int iter = 0; iter < string_list.size(); ++iter)
{
QString current_string = string_list.at(iter);
bool ok = false;
std::size_t current_sizet = current_string.toUInt(&ok);
if(!current_sizet && !ok)
{
++error_count;
continue;
}
sizet_vector.push_back(current_sizet);
}
return sizet_vector;
}

## toJson()

QJsonArray pappso::Utils::toJson | ( | const std::vector< double > & | myVec | ) |

static

convert vector of double into json array

Definition at line 774 of file utils.cpp.

{
QJsonArray result;
for(auto i = myVec.begin(); i != myVec.end(); i++)
{
result.push_back((*i));
}
return result;
}

Referenced by pappso::MassSpectrumWidget::getJsonPsmIsotope().

## toString() [1/4]

QString pappso::Utils::toString | ( | Enums::PeptideIon | m_ionType | ) |

static

Convenience function to return a string describing the ion type.

Returns
  QString

Definition at line 564 of file utils.cpp.

{
switch(m_ionType)
{
case Enums::PeptideIon::y:
return "y";
break;
case Enums::PeptideIon::yp:
return "yP";
break;
case Enums::PeptideIon::ystar:
return "y*";
break;
case Enums::PeptideIon::yo:
return "yO";
break;
case Enums::PeptideIon::bstar:
return "b*";
break;
case Enums::PeptideIon::bo:
return "bO";
break;
case Enums::PeptideIon::a:
return "a";
break;
case Enums::PeptideIon::astar:
return "a*";
break;
case Enums::PeptideIon::ao:
return "aO";
break;
case Enums::PeptideIon::c:
return "c";
break;
// SvgIon.moxygen - mN
case Enums::PeptideIon::z:
return "z";
break;
case Enums::PeptideIon::b:
return "b";
break;
case Enums::PeptideIon::bp:
return "bP";
break;
case Enums::PeptideIon::x:
return "x";
break;
default:
throw PappsoException(QString("Enums::PeptideIon name not implemented"));
break;
}
}
pappso::Enums::PeptideIon::a
@ a
Nter aldimine ions.
Definition types.h:290
pappso::Enums::PeptideIon::y
@ y
Cter amino ions.
Definition types.h:295
pappso::Enums::PeptideIon::c
@ c
Nter amino ions.
Definition types.h:294
pappso::Enums::PeptideIon::astar
@ astar
Nter aldimine ions + NH3 loss.
Definition types.h:291
pappso::Enums::PeptideIon::bp
@ bp
Definition types.h:293
pappso::Enums::PeptideIon::yp
@ yp
Definition types.h:299
pappso::Enums::PeptideIon::ystar
@ ystar
Cter amino ions + NH3 loss.
Definition types.h:296
pappso::Enums::PeptideIon::yo
@ yo
Cter amino ions + H2O loss.
Definition types.h:297
pappso::Enums::PeptideIon::bstar
@ bstar
Nter acylium ions + NH3 loss.
Definition types.h:288
pappso::Enums::PeptideIon::b
@ b
Nter acylium ions.
Definition types.h:287
pappso::Enums::PeptideIon::x
@ x
Cter acylium ions.
Definition types.h:300
pappso::Enums::PeptideIon::bo
@ bo
Nter acylium ions + H2O loss.
Definition types.h:289
pappso::Enums::PeptideIon::ao
@ ao
Nter aldimine ions + H2O loss.
Definition types.h:292
pappso::Enums::PeptideIon::z
@ z
Cter carbocations.
Definition types.h:298

References pappso::Enums::a, pappso::Enums::ao, pappso::Enums::astar, pappso::Enums::b, pappso::Enums::bo, pappso::Enums::bp, pappso::Enums::bstar, pappso::Enums::c, pappso::Enums::x, pappso::Enums::y, pappso::Enums::yo, pappso::Enums::yp, pappso::Enums::ystar, and pappso::Enums::z.

## toString() [2/4]

QString pappso::Utils::toString | ( | Enums::PrecisionUnit | precision_unit | ) |

static

Convenience function to return a string naming the precision.

Returns
  QString

Definition at line 638 of file utils.cpp.

{
auto it = precisionUnitMap.find(precision_unit);
if(it != precisionUnitMap.end())
{
return it->second;
}
throw pappso::ExceptionNotFound(QObject::tr("precision unit not found in precisionUnitMap"));
}
pappso::precisionUnitMap
std::map< Enums::PrecisionUnit, QString > precisionUnitMap
Definition precision.cpp:43

References pappso::precisionUnitMap.

## toString() [3/4]

QString pappso::Utils::toString | ( | specglob::ExperimentalSpectrumDataPointType | type | ) |

static

Convenience function to return a string describing the specglob experimental spectrum data point.

Returns
  QString

Definition at line 619 of file utils.cpp.

{
switch(type)
{
case specglob::ExperimentalSpectrumDataPointType::both:
return "both";
break;
case specglob::ExperimentalSpectrumDataPointType::native:
return "native";
break;
case specglob::ExperimentalSpectrumDataPointType::symmetric:
return "symmetric";
break;
default:
return "synthetic";
}
}
pappso::specglob::ExperimentalSpectrumDataPointType::native
@ native
Definition types.h:79
pappso::specglob::ExperimentalSpectrumDataPointType::both
@ both
both, the ion and the complement exists in the original spectrum
Definition types.h:83
pappso::specglob::ExperimentalSpectrumDataPointType::symmetric
@ symmetric
new peak : computed symmetric mass from a corresponding native peak
Definition types.h:81

References pappso::specglob::both, pappso::specglob::native, and pappso::specglob::symmetric.

## toString() [4/4]

QString pappso::Utils::toString | ( | specglob::SpectralAlignmentType | type | ) |

static

Convenience function to return a string describing the specglob alingment type.

Returns
  QString

Definition at line 544 of file utils.cpp.

{
switch(type)
{
case specglob::SpectralAlignmentType::align:
return "AL";
break;
case specglob::SpectralAlignmentType::nonAlign:
return "NA";
break;
case specglob::SpectralAlignmentType::reAlign:
return "RA";
break;
default:
return "ER";
}
}
pappso::specglob::SpectralAlignmentType::nonAlign
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)
Definition types.h:49
pappso::specglob::SpectralAlignmentType::reAlign
@ reAlign
Re Alignment (1 - RE).
Definition types.h:51
pappso::specglob::SpectralAlignmentType::align
@ align
Alignment (2 - AL).
Definition types.h:52

References pappso::specglob::align, pappso::specglob::nonAlign, and pappso::specglob::reAlign.

Referenced by pappso::MassSpectrumWidget::getJsonPsmIsotope(), pappso::Peptide::getMassIonSerie(), pappso::cbor::psm::PsmFeatures::parameterMapReady(), pappso::cbor::psm::PsmIonSeries::parameterMapReady(), pappso::cbor::psm::PsmIonSeriesScan::process(), pappso::specglob::PeptideModel::toProForma(), and pappso::specglob::PeptideModel::toString().

## toUtf8StandardString()

std::string pappso::Utils::toUtf8StandardString | ( | const QString & | text | ) |

static

Definition at line 166 of file utils.cpp.

{
std::string env_backup;
try
{
#ifdef MXE
// std::locale::global(std::locale("C")); // set locale to default locale
env_backup = std::setlocale(LC_ALL, nullptr);
std::setlocale(LC_ALL, "C");
#else
std::locale::global(std::locale("C")); // set locale to default locale
#endif
}
catch(std::exception &error)
{
throw pappso::PappsoException(
QObject::tr("Error trying to set local to C : %1").arg(error.what()));
}
// Now perform the conversion.
QByteArray byte_array = text.toUtf8();
std::string stdText = "";
for(char c : byte_array)
{
stdText += c;
}
try
{
#ifdef MXE
// std::locale::global(std::locale("C")); // set locale to default locale
std::setlocale(LC_ALL, env_backup.c_str());
#else // Set back the locale to the backed-up one.
std::locale::global(std::locale("")); // sets locale according to OS environment
#endif
}
catch(std::exception &error)
{
throw pappso::PappsoException(
QObject::tr("Error trying to set local to original system one %1 : %2")
.arg(env_backup.c_str())
.arg(error.what()));
}
return stdText;
}
pappso::PeptideIonNter::c
@ c
Definition peptide.h:81

References pappso::c.

Referenced by pappso::PwizMsFileReader::initialize(), and pappso::PwizMsRunReader::initialize().

## translateAaModificationFromUnimod()

pappso::AaModificationP pappso::Utils::translateAaModificationFromUnimod | ( | const QString & | unimod_accession | ) |

static

Definition at line 734 of file utils.cpp.

{
if(unimod_accession == "UNIMOD:1")
{
return pappso::AaModification::getInstance("MOD:00394");
}
if(unimod_accession == "UNIMOD:4")
{
return pappso::AaModification::getInstance("MOD:00397");
}
if(unimod_accession == "UNIMOD:7")
{
return pappso::AaModification::getInstance("MOD:00400");
}
if(unimod_accession == "UNIMOD:27")
{
return pappso::AaModification::getInstance("MOD:00420");
}
// UNIMOD:28 => MOD:00040
if(unimod_accession == "UNIMOD:28")
{
return pappso::AaModification::getInstance("MOD:00040");
}
if(unimod_accession == "UNIMOD:35")
{
return pappso::AaModification::getInstance("MOD:00425");
}
qInfo() << "unimod_accession:" << unimod_accession << " not found";
return nullptr;
}

References pappso::AaModification::getInstance().

Referenced by pappso::cbor::psm::MzIdentMlReader::readPeptide().

## writeLexicalOrderedString()

void pappso::Utils::writeLexicalOrderedString | ( | QTextStream * | p_out,
|  | unsigned int | num )

static

Definition at line 84 of file utils.cpp.

{
*p_out << (char)(log10(num) + 97) << num;
}

## writeToFile() [1/2]

bool pappso::Utils::writeToFile | ( | const QString & | text,
|  | const QString & | file_name )

static

Definition at line 216 of file utils.cpp.

{
QFile file(file_name);
if(file.open(QFile::WriteOnly | QFile::Truncate))
{
QTextStream out(&file);
out << text;
out.flush();
file.close();
return true;
}
return false;
}

Referenced by pappso::MzIntegrationParams::createArbitraryBins(), and pappso::MzIntegrationParams::createDataBasedBins().

## writeToFile() [2/2]

bool pappso::Utils::writeToFile | ( | const std::vector< double > & | data,
|  | int | decimals,
|  | const QString & | file_name )

static

Definition at line 239 of file utils.cpp.

{
QFile file(file_name);
if(file.open(QFile::WriteOnly | QFile::Append))
{
file.open(QIODevice::WriteOnly);
QTextStream fileStream(&file);
for(auto &&value : data)
fileStream << QString("%1\n").arg(value, 0, 'f', decimals);
fileStream.flush();
file.close();
return true;
}
return false;
}

## zeroDecimalsInValue()

int pappso::Utils::zeroDecimalsInValue | ( | pappso_double | value | ) |

static

Determine the number of zero decimals between the decimal point and the first non-zero decimal.

0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3

Parameters

  value | the value to be analyzed

Returns
  the number of '0' decimals between the decimal separator '.' and the first non-0 decimal

Definition at line 102 of file utils.cpp.

{
// qDebug() << qSetRealNumberPrecision(10) << "Double value: " << value;
int intPart = static_cast<int>(value);
// qDebug() << "int part:" << intPart;
double decimalPart = value - intPart;
// qDebug() << qSetRealNumberPrecision(10) << "decimal part: " << decimalPart;
int count = 0;
while(decimalPart > 0)
{
++count;
decimalPart *= 10;
// qDebug() << "Iteration " << count << "decimal part:" << decimalPart;
if(decimalPart >= 1)
{
// qDebug() << "Because decimal part " << decimalPart
//<< "is >= 1, breaking loop while count is " << count << ".";
break;
}
}
// qDebug() << "Returning count:" << count - 1;
return count - 1;
}

Referenced by pappso::MzIntegrationParams::createArbitraryBins(), pappso::BasePlotWidget::drawXScopeSpanFeatures(), and pappso::BasePlotWidget::drawYScopeSpanFeatures().

## Member Data Documentation

## anythingButDigitDotDash

QRegularExpression pappso::Utils::anythingButDigitDotDash = QRegularExpression("[^\\d^\\.^-]+")

static

Definition at line 55 of file utils.h.

## endOfLineRegExp

QRegularExpression pappso::Utils::endOfLineRegExp = QRegularExpression("^\\s+$")

static

Regular expression that tracks the end of line in text files.

Definition at line 69 of file utils.h.

Referenced by pappso::XyMsRunReader::accept(), pappso::BafAsciiFileReader::initialize(), pappso::XyMsFileReader::initialize(), and pappso::XyMsRunReader::qualifiedMassSpectrumFromXyMSDataFile().

## mzListDataFormatRegExp

QRegularExpression pappso::Utils::mzListDataFormatRegExp

static

Regular expression matching <m/z value><non-numerical*>.

Definition at line 63 of file utils.h.

## signedDoubleNumberExponentialRegExp

QRegularExpression pappso::Utils::signedDoubleNumberExponentialRegExp

static

Initial value:
=
QRegularExpression("-?\\d*\\.?\\d*[e-]?\\d*")

Definition at line 56 of file utils.h.

## sizetListDataFormatRegExp

QRegularExpression pappso::Utils::sizetListDataFormatRegExp

static

Regular expression matching <size_t><non-numerical*>.

Definition at line 66 of file utils.h.

## unsignedDoubleNumberNoExponentialRegExp

QRegularExpression pappso::Utils::unsignedDoubleNumberNoExponentialRegExp

static

Initial value:
=
QRegularExpression("\\d*\\.?\\d+")

Definition at line 54 of file utils.h.

Referenced by pappso::BafAsciiMsRunReader::craftLineParserRegExpPattern(), and pappso::BafAsciiFileReader::initialize().

## xyMassDataFormatRegExp

QRegularExpression pappso::Utils::xyMassDataFormatRegExp

static

Initial value:
=
QRegularExpression(QString("^(%1)(%2)(%3)")
.arg(Utils::unsignedDoubleNumberNoExponentialRegExp.pattern())
.arg(Utils::anythingButDigitDotDash.pattern())
.arg(Utils::signedDoubleNumberExponentialRegExp.pattern()))
pappso::Utils::anythingButDigitDotDash
static QRegularExpression anythingButDigitDotDash
Definition utils.h:55
pappso::Utils::signedDoubleNumberExponentialRegExp
static QRegularExpression signedDoubleNumberExponentialRegExp
Definition utils.h:56
pappso::Utils::unsignedDoubleNumberNoExponentialRegExp
static QRegularExpression unsignedDoubleNumberNoExponentialRegExp
Definition utils.h:54

Regular expression matching <numerical value><non-numerical*><numerical value>.

Definition at line 60 of file utils.h.

Referenced by pappso::XyMsRunReader::accept(), pappso::DataPoint::initialize(), pappso::XyMsFileReader::initialize(), and pappso::XyMsRunReader::qualifiedMassSpectrumFromXyMSDataFile().

The documentation for this class was generated from the following files:

- pappsomspp/core/utils.h
- pappsomspp/core/utils.cpp