Loading...
Searching...
No Matches
precision.h
Go to the documentation of this file.
/**
* \file pappsomspp/mass_range.h
* \date 4/3/2015
* \author Olivier Langella
* \brief object to handle a mass range (an mz value + or - some delta)
*/
/*******************************************************************************
* 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
#include <map>
#include <QString>
#include "pappsomspp/export-import-config.h"
#include "pappsomspp/core/types.h"
namespace pappso
{
class PMSPP_LIB_DECL PrecisionBase
{
protected:
const pappso_double m_nominal;
PrecisionBase(pappso_double nominal) : m_nominal(nominal)
{
}
public:
virtual Enums::PrecisionUnit unit() const = 0;
virtual pappso_double getNominal() const final;
virtual pappso_double delta(pappso_double value) const = 0;
virtual QString toString() const = 0;
};
/** \def specific type for a dalton precision
*
*/
class PMSPP_LIB_DECL DaltonPrecision : public PrecisionBase
{
friend class PrecisionFactory;
protected:
DaltonPrecision(pappso_double x);
public:
virtual ~DaltonPrecision();
virtual Enums::PrecisionUnit unit() const override;
virtual pappso_double delta(pappso_double value) const override;
virtual QString toString() const override;
};
/** \def specific type for a ppm precision
*
*/
class PMSPP_LIB_DECL PpmPrecision : public PrecisionBase
{
friend class PrecisionFactory;
protected:
PpmPrecision(pappso_double x);
public:
virtual ~PpmPrecision();
virtual Enums::PrecisionUnit unit() const override;
virtual pappso_double delta(pappso_double value) const override;
virtual QString toString() const override;
};
/** \def specific type for a res precision
*
*/
class PMSPP_LIB_DECL ResPrecision : public PrecisionBase
{
friend class PrecisionFactory;
protected:
ResPrecision(pappso_double x);
public:
virtual ~ResPrecision();
virtual Enums::PrecisionUnit unit() const override;
virtual pappso_double delta(pappso_double value) const override;
virtual QString toString() const override;
};
typedef const PrecisionBase *PrecisionPtr;
// was class Precision
class PMSPP_LIB_DECL PrecisionFactory
{
using MapDaltonPrecision = std::map<pappso_double, DaltonPrecision *>;
using MapPpmPrecision = std::map<pappso_double, PpmPrecision *>;
using MapResPrecision = std::map<pappso_double, ResPrecision *>;
private:
static MapDaltonPrecision m_mapDalton;
static MapPpmPrecision m_mapPpm;
static MapResPrecision m_mapRes;
public:
/** @brief get a precision pointer from a string
* @param str is of the form : "nominal_value unit", example : "0.02 dalton"
*/
static PrecisionPtr fromString(const QString &str);
/** @brief get a Dalton precision pointer
* @param value the precision value in dalton
*/
static PrecisionPtr getDaltonInstance(pappso_double value);
/** @brief get a ppm precision pointer
* @param value the precision value in ppm
*/
static PrecisionPtr getPpmInstance(pappso_double value);
/** @brief get a resolution precision pointer
* @param value the precision value in resolution
*/
static PrecisionPtr getResInstance(pappso_double value);
/** @brief get the fraction of an existing precision pointer
* @param origin the original precision pointer
* @param fraction the fraction to apply on the original precision
*/
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin,
double fraction);
/** @brief get a precision pointer instance
* @param unit the precision unit
* @param value the precision value
*/
static PrecisionPtr getPrecisionPtrInstance(Enums::PrecisionUnit unit, double value);
};
} // namespace pappso
pappso::DaltonPrecision::toString
virtual QString toString() const override
Definition precision.cpp:264
pappso::DaltonPrecision::unit
virtual Enums::PrecisionUnit unit() const override
Definition precision.cpp:252
pappso::DaltonPrecision::DaltonPrecision
DaltonPrecision(pappso_double x)
Definition precision.cpp:243
pappso::DaltonPrecision::delta
virtual pappso_double delta(pappso_double value) const override
Definition precision.cpp:258
pappso::DaltonPrecision::PrecisionFactory
friend class PrecisionFactory
Definition precision.h:65
pappso::PpmPrecision::PpmPrecision
PpmPrecision(pappso_double x)
Definition precision.cpp:270
pappso::PpmPrecision::delta
virtual pappso_double delta(pappso_double value) const override
Definition precision.cpp:287
pappso::PpmPrecision::unit
virtual Enums::PrecisionUnit unit() const override
Definition precision.cpp:280
pappso::PpmPrecision::toString
virtual QString toString() const override
Definition precision.cpp:294
pappso::PpmPrecision::PrecisionFactory
friend class PrecisionFactory
Definition precision.h:85
pappso::PrecisionBase
Definition precision.h:44
pappso::PrecisionBase::toString
virtual QString toString() const =0
pappso::PrecisionBase::m_nominal
const pappso_double m_nominal
Definition precision.h:46
pappso::PrecisionBase::PrecisionBase
PrecisionBase(pappso_double nominal)
Definition precision.h:48
pappso::PrecisionBase::getNominal
virtual pappso_double getNominal() const final
Definition precision.cpp:73
pappso::PrecisionBase::unit
virtual Enums::PrecisionUnit unit() const =0
pappso::PrecisionBase::delta
virtual pappso_double delta(pappso_double value) const =0
pappso::PrecisionFactory
Definition precision.h:127
pappso::PrecisionFactory::getPrecisionPtrInstance
static PrecisionPtr getPrecisionPtrInstance(Enums::PrecisionUnit unit, double value)
get a precision pointer instance
Definition precision.cpp:219
pappso::PrecisionFactory::getResInstance
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition precision.cpp:181
pappso::PrecisionFactory::fromString
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:80
pappso::PrecisionFactory::m_mapRes
static MapResPrecision m_mapRes
Definition precision.h:135
pappso::PrecisionFactory::m_mapPpm
static MapPpmPrecision m_mapPpm
Definition precision.h:134
pappso::PrecisionFactory::MapPpmPrecision
std::map< pappso_double, PpmPrecision * > MapPpmPrecision
Definition precision.h:129
pappso::PrecisionFactory::getPpmInstance
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Definition precision.cpp:155
pappso::PrecisionFactory::getPrecisionPtrFractionInstance
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin, double fraction)
get the fraction of an existing precision pointer
Definition precision.cpp:209
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:136
pappso::PrecisionFactory::MapDaltonPrecision
std::map< pappso_double, DaltonPrecision * > MapDaltonPrecision
Definition precision.h:128
pappso::PrecisionFactory::m_mapDalton
static MapDaltonPrecision m_mapDalton
Definition precision.h:133
pappso::PrecisionFactory::MapResPrecision
std::map< pappso_double, ResPrecision * > MapResPrecision
Definition precision.h:130
pappso::ResPrecision::unit
virtual Enums::PrecisionUnit unit() const override
Definition precision.cpp:310
pappso::ResPrecision::delta
virtual pappso_double delta(pappso_double value) const override
Definition precision.cpp:317
pappso::ResPrecision::toString
virtual QString toString() const override
Definition precision.cpp:324
pappso::ResPrecision::PrecisionFactory
friend class PrecisionFactory
Definition precision.h:106
pappso::ResPrecision::ResPrecision
ResPrecision(pappso_double x)
Definition precision.cpp:300
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
pappso::Enums::PrecisionUnit
PrecisionUnit
Definition types.h:96
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
types.h