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

`#include <precision.h>`

## Static Public Member Functions

static PrecisionPtr | fromString (const QString &str)
| get a precision pointer from a string
static PrecisionPtr | getDaltonInstance (pappso_double value)
| get a Dalton precision pointer
static PrecisionPtr | getPpmInstance (pappso_double value)
| get a ppm precision pointer
static PrecisionPtr | getResInstance (pappso_double value)
| get a resolution precision pointer
static PrecisionPtr | getPrecisionPtrFractionInstance (PrecisionPtr origin, double fraction)
| get the fraction of an existing precision pointer
static PrecisionPtr | getPrecisionPtrInstance (PrecisionUnit unit, double value)
| get a precision pointer instance

## Private Types

using | MapDaltonPrecision = std::map< pappso_double, DaltonPrecision * >
using | MapPpmPrecision = std::map< pappso_double, PpmPrecision * >
using | MapResPrecision = std::map< pappso_double, ResPrecision * >

## Static Private Attributes

static MapDaltonPrecision | m_mapDalton
static MapPpmPrecision | m_mapPpm
static MapResPrecision | m_mapRes

## Detailed Description

Definition at line 126 of file precision.h.

## Member Typedef Documentation

## MapDaltonPrecision

using pappso::PrecisionFactory::MapDaltonPrecision = std::map<pappso_double, DaltonPrecision *>

private

Definition at line 128 of file precision.h.

## MapPpmPrecision

using pappso::PrecisionFactory::MapPpmPrecision = std::map<pappso_double, PpmPrecision *>

private

Definition at line 129 of file precision.h.

## MapResPrecision

using pappso::PrecisionFactory::MapResPrecision = std::map<pappso_double, ResPrecision *>

private

Definition at line 130 of file precision.h.

## Member Function Documentation

## fromString()

PrecisionPtr pappso::PrecisionFactory::fromString | ( | const QString & | str | ) |

static

get a precision pointer from a string

Parameters

  str | is of the form : "nominal_value unit", example : "0.02 dalton"

Definition at line 72 of file precision.cpp.

{
// The format of the string is <number><space *><string> with string either
// "ppm" or "dalton" or "res".
//
// If there only once component, that is, <string> is omitted and charge is
// not provided, then "dalton" is considered.
QStringList list = str.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
if(list.size() > 0)
{
bool ok;
pappso_double value = list[0].toDouble(&ok);
if(!ok)
{
throw ExceptionNotPossible(
QObject::tr("ERROR getting precision from string :\nunable to "
"convert %1 to number in %2")
.arg(value)
.arg(str));
}
if(list.size() == 1)
{
return PrecisionFactory::getDaltonInstance(value);
}
else if(list.size() == 2)
{
if(list[1].toLower() == "dalton")
{
return PrecisionFactory::getDaltonInstance(value);
}
if(list[1].toLower() == "ppm")
{
return PrecisionFactory::getPpmInstance(value);
}
if(list[1].toLower() == "res")
{
return PrecisionFactory::getResInstance(value);
}
throw ExceptionNotPossible(
QObject::tr("ERROR getting precision from string :\nprecision "
"unit %1 to not known in %2")
.arg(list[1])
.arg(str));
}
}
throw ExceptionNotPossible(QObject::tr("ERROR getting precision from string "
":\nunable to convert %1 to precision")
.arg(str));
}
pappso::PrecisionFactory::getResInstance
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition precision.cpp:177
pappso::PrecisionFactory::getPpmInstance
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Definition precision.cpp:150
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:130
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:50

References getDaltonInstance(), getPpmInstance(), and getResInstance().

Referenced by pappso::FilterChargeDeconvolution::buildFilterFromString(), pappso::FilterComplementIonEnhancer::buildFilterFromString(), and pappso::FilterMzExclusion::buildFilterFromString().

## getDaltonInstance()

PrecisionPtr pappso::PrecisionFactory::getDaltonInstance | ( | pappso_double | value | ) |

static

get a Dalton precision pointer

Parameters

  value | the precision value in dalton

Definition at line 130 of file precision.cpp.

{
MapDaltonPrecision::iterator it = m_mapDalton.find(value);
if(it == m_mapDalton.end())
{
// not found
std::pair<MapDaltonPrecision::iterator, bool> insert_res =
m_mapDalton.insert(std::pair<pappso_double, DaltonPrecision *>(
value, new DaltonPrecision(value)));
it = insert_res.first;
}
else
{
// found
}
return it->second;
}
pappso::PrecisionFactory::m_mapDalton
static MapDaltonPrecision m_mapDalton
Definition precision.h:133

References m_mapDalton.

Referenced by pappso::PrecisionWidget::PrecisionWidget(), fromString(), pappso::AaModification::getInstanceXtandemMod(), getPrecisionPtrInstance(), pappso::XtandemSpectrumProcess::process(), pappso::PrecisionWidget::setDaltonValueChanged(), and pappso::MzIntegrationParams::setPrecision().

## getPpmInstance()

PrecisionPtr pappso::PrecisionFactory::getPpmInstance | ( | pappso_double | value | ) |

static

get a ppm precision pointer

Parameters

  value | the precision value in ppm

Definition at line 150 of file precision.cpp.

{
if(!value)
throw ExceptionNotPossible(
QObject::tr("Fatal error at precision.cpp "
"-- ERROR trying to set a Resolution precision value of 0. "
"Program aborted."));
MapPpmPrecision::iterator it = m_mapPpm.find(value);
if(it == m_mapPpm.end())
{
// Not found.
std::pair<MapPpmPrecision::iterator, bool> insert_res =
m_mapPpm.insert(std::pair<pappso_double, PpmPrecision *>(
value, new PpmPrecision(value)));
it = insert_res.first;
}
else
{
// found
}
return it->second;
}
pappso::PrecisionFactory::m_mapPpm
static MapPpmPrecision m_mapPpm
Definition precision.h:134

References m_mapPpm.

Referenced by pappso::MzIntegrationParams::MzIntegrationParams(), pappso::MzIntegrationParams::MzIntegrationParams(), pappso::PrecisionWidget::PrecisionWidget(), pappso::MassSpectrum::equals(), fromString(), getPrecisionPtrInstance(), pappso::MzIntegrationParams::operator=(), pappso::MzIntegrationParams::reset(), and pappso::PrecisionWidget::setPpmValueChanged().

## getPrecisionPtrFractionInstance()

PrecisionPtr pappso::PrecisionFactory::getPrecisionPtrFractionInstance | ( | PrecisionPtr | origin,
|  | double | fraction
| ) |  |

static

get the fraction of an existing precision pointer

Parameters

  origin | the original precision pointer
  fraction | the fraction to apply on the original precision

Definition at line 206 of file precision.cpp.

{
PrecisionUnit unit = origin->unit();
double value = origin->getNominal() * fraction;
return getPrecisionPtrInstance(unit, value);
}
pappso::PrecisionFactory::getPrecisionPtrInstance
static PrecisionPtr getPrecisionPtrInstance(PrecisionUnit unit, double value)
get a precision pointer instance
Definition precision.cpp:217
pappso::PrecisionUnit
PrecisionUnit
Definition types.h:76

References pappso::PrecisionBase::getNominal(), getPrecisionPtrInstance(), and pappso::PrecisionBase::unit().

Referenced by pappso::FilterChargeDeconvolution::FilterChargeDeconvolution(), pappso::PsmFeatures::PsmFeatures(), and pappso::FilterChargeDeconvolution::buildFilterFromString().

## getPrecisionPtrInstance()

PrecisionPtr pappso::PrecisionFactory::getPrecisionPtrInstance | ( | PrecisionUnit | unit,
|  | double | value
| ) |  |

static

get a precision pointer instance

Parameters

  unit | the precision unit
  value | the precision value

Definition at line 217 of file precision.cpp.

{
switch(unit)
{
case PrecisionUnit::dalton:
return getDaltonInstance(value);
case PrecisionUnit::ppm:
return getPpmInstance(value);
case PrecisionUnit::res:
return getResInstance(value);
case PrecisionUnit::mz:
return getDaltonInstance(value);
case PrecisionUnit::none:
throw ExceptionNotPossible(QObject::tr("Unknown precision unit"));
default:
throw ExceptionNotPossible(QObject::tr("Unknown precision unit"));
break;
}
return nullptr;
}
pappso::PrecisionUnit::none
@ none
pappso::PrecisionUnit::mz
@ mz
pappso::PrecisionUnit::res
@ res
pappso::PrecisionUnit::ppm
@ ppm
pappso::PrecisionUnit::dalton
@ dalton

References pappso::dalton, getDaltonInstance(), getPpmInstance(), getResInstance(), pappso::mz, pappso::none, pappso::ppm, and pappso::res.

Referenced by pappso::XtandemPresetReader::getMs2FiltersOptions(), and getPrecisionPtrFractionInstance().

## getResInstance()

PrecisionPtr pappso::PrecisionFactory::getResInstance | ( | pappso_double | value | ) |

static

get a resolution precision pointer

Parameters

  value | the precision value in resolution

Definition at line 177 of file precision.cpp.

{
// qDebug() << "Requested a Resolution precision instance for value:" <<
// value;
if(!value)
throw ExceptionNotPossible(
QObject::tr("Fatal error at precision.cpp "
"-- ERROR trying to set a Resolution precision value of 0. "
"Program aborted."));
MapResPrecision::iterator it = m_mapRes.find(value);
if(it == m_mapRes.end())
{
// not found
std::pair<MapResPrecision::iterator, bool> insert_res =
m_mapRes.insert(std::pair<pappso_double, ResPrecision *>(
value, new ResPrecision(value)));
it = insert_res.first;
}
else
{
// found
}
return it->second;
}
pappso::PrecisionFactory::m_mapRes
static MapResPrecision m_mapRes
Definition precision.h:135

References m_mapRes.

Referenced by pappso::MzIntegrationParams::MzIntegrationParams(), pappso::PrecisionWidget::PrecisionWidget(), fromString(), getPrecisionPtrInstance(), and pappso::PrecisionWidget::setResValueChanged().

## Member Data Documentation

## m_mapDalton

PrecisionFactory::MapDaltonPrecision pappso::PrecisionFactory::m_mapDalton

static private

Initial value:
= [] {
MapDaltonPrecision ret;
return ret;
}()
pappso::PrecisionFactory::MapDaltonPrecision
std::map< pappso_double, DaltonPrecision * > MapDaltonPrecision
Definition precision.h:128

Definition at line 133 of file precision.h.

Referenced by getDaltonInstance().

## m_mapPpm

PrecisionFactory::MapPpmPrecision pappso::PrecisionFactory::m_mapPpm

static private

Initial value:
= [] {
MapPpmPrecision ret;
return ret;
}()
pappso::PrecisionFactory::MapPpmPrecision
std::map< pappso_double, PpmPrecision * > MapPpmPrecision
Definition precision.h:129

Definition at line 134 of file precision.h.

Referenced by getPpmInstance().

## m_mapRes

PrecisionFactory::MapResPrecision pappso::PrecisionFactory::m_mapRes

static private

Initial value:
= [] {
MapResPrecision ret;
return ret;
}()
pappso::PrecisionFactory::MapResPrecision
std::map< pappso_double, ResPrecision * > MapResPrecision
Definition precision.h:130

Definition at line 135 of file precision.h.

Referenced by getResInstance().

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

- pappsomspp/precision.h
- pappsomspp/precision.cpp