Loading...
Searching...
No Matches
xtandemspectrumprocess.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/psm/xtandem/xtandemhyperscore.cpp
* \date 16/8/2016
* \author Olivier Langella
* \brief process spectrum to compute X!Tandem hyperscore
*/
/*******************************************************************************
* Copyright (c) 2016 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
******************************************************************************/
#include "xtandemspectrumprocess.h"
#include <QDebug>
namespace pappso
{
XtandemSpectrumProcess::XtandemSpectrumProcess()
: m_filter_keep_greater(150),
m_n_most_intense(100),
m_filter_rescale(100),
m_filter_highpass(0.9)
{
}
XtandemSpectrumProcess::XtandemSpectrumProcess(
const XtandemSpectrumProcess &copy)
: m_filter_keep_greater(copy.m_filter_keep_greater),
m_n_most_intense(copy.m_n_most_intense),
m_filter_rescale(copy.m_filter_rescale),
m_filter_highpass(copy.m_filter_highpass)
{
m_isRemoveIsotope = copy.m_isRemoveIsotope;
m_isExcludeParent_neutral_loss = copy.m_isExcludeParent_neutral_loss;
m_neutralLossMass = copy.m_neutralLossMass;
m_neutralLossWindowDalton = copy.m_neutralLossWindowDalton;
m_isExcludeParent = copy.m_isExcludeParent;
m_isExcludeParent_lower_dalton = copy.m_isExcludeParent_lower_dalton;
m_isExcludeParent_upper_dalton = copy.m_isExcludeParent_upper_dalton;
m_isRefineSpectrumModel = copy.m_isRefineSpectrumModel;
_y_ions = copy._y_ions; // PeptideIon::y
_b_ions = copy._b_ions; // PeptideIon::b
_ystar_ions = copy._ystar_ions; // PeptideIon::ystar
_bstar_ions = copy._bstar_ions; // PeptideIon::bstar
_c_ions = copy._c_ions; // PeptideIon::c
_z_ions = copy._z_ions; // PeptideIon::z
_a_ions = copy._a_ions; // PeptideIon::a
_x_ions = copy._x_ions; // CO2
_astar_ions = copy._astar_ions; // PeptideIon::a
_ao_ions = copy._ao_ions;
_bo_ions = copy._bo_ions;
_yo_ions = copy._yo_ions;
}
XtandemSpectrumProcess::~XtandemSpectrumProcess()
{
}
void
XtandemSpectrumProcess::setMinimumMz(pappso_double minimum_mz)
{
m_filter_keep_greater = FilterResampleKeepGreater(minimum_mz);
}
void
XtandemSpectrumProcess::setNmostIntense(unsigned int nmost_intense)
{
m_n_most_intense = FilterGreatestY(nmost_intense);
}
void
XtandemSpectrumProcess::setDynamicRange(pappso::pappso_double dynamic_range)
{
m_filter_rescale = FilterRescaleY(dynamic_range);
}
void
XtandemSpectrumProcess::setRemoveIsotope(bool remove_isotope)
{
m_isRemoveIsotope = remove_isotope;
}
void
XtandemSpectrumProcess::setExcludeParent(bool exclude_parent)
{
m_isExcludeParent = exclude_parent;
}
void
XtandemSpectrumProcess::setExcludeParentNeutralLoss(bool neutral_loss)
{
m_isExcludeParent_neutral_loss = neutral_loss;
}
void
XtandemSpectrumProcess::setNeutralLossMass(
pappso::pappso_double neutral_loss_mass)
{
m_neutralLossMass = neutral_loss_mass;
}
void
XtandemSpectrumProcess::setNeutralLossWindowDalton(
pappso_double neutral_loss_precision)
{
m_neutralLossWindowDalton = neutral_loss_precision;
}
void
XtandemSpectrumProcess::setRefineSpectrumModel(bool refine)
{
m_isRefineSpectrumModel = refine;
}
// FIXME: enumeration values 'bp' and 'yp' not handled in switch
void
XtandemSpectrumProcess::setIonScore(PeptideIon ion_type, bool compute_score)
{
switch(ion_type)
{
case PeptideIon::y:
_y_ions = compute_score;
break;
case PeptideIon::b:
_b_ions = compute_score;
break;
case PeptideIon::ystar:
_ystar_ions = compute_score;
break;
case PeptideIon::bstar:
_bstar_ions = compute_score;
break;
case PeptideIon::yo:
_yo_ions = compute_score;
break;
case PeptideIon::bo:
_bo_ions = compute_score;
break;
case PeptideIon::z:
_z_ions = compute_score;
break;
case PeptideIon::a:
_a_ions = compute_score;
break;
case PeptideIon::astar:
_astar_ions = compute_score;
break;
case PeptideIon::ao:
_ao_ions = compute_score;
break;
case PeptideIon::c:
_c_ions = compute_score;
break;
case PeptideIon::x:
_x_ions = compute_score;
break;
case PeptideIon::bp:
case PeptideIon::yp:
break;
}
}
pappso_double
XtandemSpectrumProcess::getMinimumMz() const
{
return m_filter_keep_greater.getThresholdX();
}
unsigned int
XtandemSpectrumProcess::getNmostIntense() const
{
return m_n_most_intense.getNumberOfPoints();
}
pappso::pappso_double
XtandemSpectrumProcess::getDynamicRange() const
{
return m_filter_rescale.getDynamicRange();
}
bool
XtandemSpectrumProcess::getRemoveIsotope() const
{
return m_isRemoveIsotope;
}
bool
XtandemSpectrumProcess::getExcludeParent() const
{
return m_isExcludeParent;
}
bool
XtandemSpectrumProcess::getExcludeParentNeutralLoss() const
{
return m_isExcludeParent_neutral_loss;
}
pappso::pappso_double
XtandemSpectrumProcess::getNeutralLossMass() const
{
return m_neutralLossMass;
}
pappso_double
XtandemSpectrumProcess::getNeutralLossWindowDalton() const
{
return m_neutralLossWindowDalton;
}
bool
XtandemSpectrumProcess::getRefineSpectrumModel() const
{
return m_isRefineSpectrumModel;
}
// FIXME: enumeration values 'bp' and 'yp' not handled in switch
bool
XtandemSpectrumProcess::getIonScore(PeptideIon ion_type) const
{
switch(ion_type)
{
case PeptideIon::y:
return _y_ions;
case PeptideIon::b:
return _b_ions;
case PeptideIon::ystar:
return _ystar_ions;
case PeptideIon::bstar:
return _bstar_ions;
case PeptideIon::yo:
return _yo_ions;
case PeptideIon::bo:
return _bo_ions;
case PeptideIon::z:
return _z_ions;
case PeptideIon::a:
return _a_ions;
case PeptideIon::astar:
return _astar_ions;
case PeptideIon::ao:
return _ao_ions;
case PeptideIon::c:
return _c_ions;
case PeptideIon::x:
return _x_ions;
default:
break;
}
return false;
}
MassSpectrum
XtandemSpectrumProcess::process(const MassSpectrum &spectrum,
pappso_double parent_ion_mz,
unsigned int parent_charge) const
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
<< " parent_charge==" << parent_charge;
// 1) clean isotopes
MassSpectrum spectrum_process(spectrum);
if(m_isRemoveIsotope)
{
spectrum_process.massSpectrumFilter(FilterTandemDeisotope());
}
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
// 2) remove parent ion mass
if(m_isExcludeParent)
{
spectrum_process.massSpectrumFilter(
MassSpectrumFilterResampleRemoveMzRange(
MzRange(parent_ion_mz,
PrecisionFactory::getDaltonInstance(
m_isExcludeParent_lower_dalton / parent_charge),
PrecisionFactory::getDaltonInstance(
m_isExcludeParent_upper_dalton / parent_charge))));
}
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() ";
// 3) remove low masses
// 4) normalization
m_filter_keep_greater.filter(spectrum_process);
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
m_filter_rescale.filter(spectrum_process);
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
// m_filter_floor.filter(spectrum_process);
m_filter_highpass.filter(spectrum_process);
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
// 5) remove neutral loss
if(m_isExcludeParent_neutral_loss)
{
pappso_double parent_ion_mhplus =
((parent_ion_mz - (MHPLUS * parent_charge)) * parent_charge) + MHPLUS;
MassSpectrumFilterResampleRemoveMzRange filter_parent(MzRange(
parent_ion_mhplus - m_neutralLossMass,
PrecisionFactory::getDaltonInstance(m_neutralLossWindowDalton)));
filter_parent.filter(spectrum_process);
}
// 6) clean isotopes
// 7) keep n most intense peaks
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
<< " parent_charge==" << parent_charge;
// return spectrum_process.massSpectrumFilter(m_filter_remove_c13)
// .filter(m_nMostIntense);
m_filter_remove_c13.filter(spectrum_process);
m_n_most_intense.filter(spectrum_process);
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() "
<< spectrum_process.size();
return spectrum_process;
}
} // namespace pappso
pappso::FilterGreatestY
keep N datapoints form the greatest intensities to the lowest
Definition filterpass.h:96
pappso::FilterGreatestY::filter
Trace & filter(Trace &data_points) const override
Definition filterpass.cpp:168
pappso::FilterGreatestY::getNumberOfPoints
std::size_t getNumberOfPoints() const
Definition filterpass.cpp:193
pappso::FilterHighPass::filter
Trace & filter(Trace &data_points) const override
Definition filterpass.cpp:91
pappso::FilterResampleKeepGreater
Definition filterresample.h:55
pappso::FilterResampleKeepGreater::getThresholdX
double getThresholdX() const
Definition filterresample.cpp:70
pappso::FilterResampleKeepGreater::filter
Trace & filter(Trace &trace) const override
Definition filterresample.cpp:84
pappso::FilterRescaleY
rescales Y values into a dynamic range if the dynamic range is set to 0, this filter is ignored
Definition filterpass.h:196
pappso::FilterRescaleY::filter
Trace & filter(Trace &data_points) const override
Definition filterpass.cpp:371
pappso::FilterRescaleY::getDynamicRange
double getDynamicRange() const
Definition filterpass.cpp:396
pappso::FilterTandemDeisotope
Deisotope the mass spectrum this mass spectrum is iterated over and according to a data point-based m...
Definition filtertandemremovec13.h:58
pappso::FilterTandemDeisotope::filter
MassSpectrum & filter(MassSpectrum &data_points) const override
Definition filtertandemremovec13.cpp:51
pappso::MassSpectrumFilterResampleRemoveMzRange
Definition filterresample.h:143
pappso::MassSpectrumFilterResampleRemoveMzRange::filter
MassSpectrum & filter(MassSpectrum &spectrum) const override
Definition filterresample.cpp:216
pappso::MassSpectrum
Class to represent a mass spectrum.
Definition massspectrum.h:73
pappso::MassSpectrum::massSpectrumFilter
virtual MassSpectrum & massSpectrumFilter(const MassSpectrumFilterInterface &filter) final
apply a filter on this MassSpectrum
Definition massspectrum.cpp:404
pappso::MzRange
Definition mzrange.h:46
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:130
pappso::XtandemSpectrumProcess
Definition xtandemspectrumprocess.h:42
pappso::XtandemSpectrumProcess::_astar_ions
bool _astar_ions
Definition xtandemspectrumprocess.h:102
pappso::XtandemSpectrumProcess::m_isExcludeParent
bool m_isExcludeParent
Definition xtandemspectrumprocess.h:87
pappso::XtandemSpectrumProcess::m_isExcludeParent_upper_dalton
pappso::pappso_double m_isExcludeParent_upper_dalton
Definition xtandemspectrumprocess.h:89
pappso::XtandemSpectrumProcess::setRemoveIsotope
void setRemoveIsotope(bool remove_isotope)
Definition xtandemspectrumprocess.cpp:96
pappso::XtandemSpectrumProcess::getRemoveIsotope
bool getRemoveIsotope() const
Definition xtandemspectrumprocess.cpp:204
pappso::XtandemSpectrumProcess::_c_ions
bool _c_ions
Definition xtandemspectrumprocess.h:98
pappso::XtandemSpectrumProcess::m_isRefineSpectrumModel
bool m_isRefineSpectrumModel
Definition xtandemspectrumprocess.h:93
pappso::XtandemSpectrumProcess::setRefineSpectrumModel
void setRefineSpectrumModel(bool refine)
Definition xtandemspectrumprocess.cpp:126
pappso::XtandemSpectrumProcess::_b_ions
bool _b_ions
Definition xtandemspectrumprocess.h:96
pappso::XtandemSpectrumProcess::XtandemSpectrumProcess
XtandemSpectrumProcess()
Definition xtandemspectrumprocess.cpp:37
pappso::XtandemSpectrumProcess::_bstar_ions
bool _bstar_ions
Definition xtandemspectrumprocess.h:97
pappso::XtandemSpectrumProcess::getDynamicRange
pappso::pappso_double getDynamicRange() const
Definition xtandemspectrumprocess.cpp:199
pappso::XtandemSpectrumProcess::m_filter_keep_greater
FilterResampleKeepGreater m_filter_keep_greater
Definition xtandemspectrumprocess.h:80
pappso::XtandemSpectrumProcess::setIonScore
void setIonScore(PeptideIon ion_type, bool compute_score)
Definition xtandemspectrumprocess.cpp:133
pappso::XtandemSpectrumProcess::getRefineSpectrumModel
bool getRefineSpectrumModel() const
Definition xtandemspectrumprocess.cpp:230
pappso::XtandemSpectrumProcess::~XtandemSpectrumProcess
~XtandemSpectrumProcess()
Definition xtandemspectrumprocess.cpp:75
pappso::XtandemSpectrumProcess::getExcludeParentNeutralLoss
bool getExcludeParentNeutralLoss() const
Definition xtandemspectrumprocess.cpp:214
pappso::XtandemSpectrumProcess::getNeutralLossMass
pappso::pappso_double getNeutralLossMass() const
Definition xtandemspectrumprocess.cpp:219
pappso::XtandemSpectrumProcess::getNmostIntense
unsigned int getNmostIntense() const
Definition xtandemspectrumprocess.cpp:194
pappso::XtandemSpectrumProcess::m_isExcludeParent_lower_dalton
pappso::pappso_double m_isExcludeParent_lower_dalton
Definition xtandemspectrumprocess.h:88
pappso::XtandemSpectrumProcess::_ao_ions
bool _ao_ions
Definition xtandemspectrumprocess.h:103
pappso::XtandemSpectrumProcess::setExcludeParentNeutralLoss
void setExcludeParentNeutralLoss(bool neutral_loss)
Definition xtandemspectrumprocess.cpp:107
pappso::XtandemSpectrumProcess::m_filter_rescale
FilterRescaleY m_filter_rescale
Definition xtandemspectrumprocess.h:82
pappso::XtandemSpectrumProcess::setNeutralLossMass
void setNeutralLossMass(pappso::pappso_double neutral_loss_mass)
Definition xtandemspectrumprocess.cpp:112
pappso::XtandemSpectrumProcess::getIonScore
bool getIonScore(PeptideIon ion_type) const
Definition xtandemspectrumprocess.cpp:237
pappso::XtandemSpectrumProcess::m_n_most_intense
FilterGreatestY m_n_most_intense
Definition xtandemspectrumprocess.h:81
pappso::XtandemSpectrumProcess::getMinimumMz
pappso_double getMinimumMz() const
Definition xtandemspectrumprocess.cpp:189
pappso::XtandemSpectrumProcess::m_neutralLossMass
pappso::pappso_double m_neutralLossMass
Definition xtandemspectrumprocess.h:91
pappso::XtandemSpectrumProcess::_ystar_ions
bool _ystar_ions
Definition xtandemspectrumprocess.h:95
pappso::XtandemSpectrumProcess::m_filter_remove_c13
FilterTandemDeisotope m_filter_remove_c13
Definition xtandemspectrumprocess.h:83
pappso::XtandemSpectrumProcess::setMinimumMz
void setMinimumMz(pappso_double minimum_mz)
Definition xtandemspectrumprocess.cpp:80
pappso::XtandemSpectrumProcess::_y_ions
bool _y_ions
Definition xtandemspectrumprocess.h:94
pappso::XtandemSpectrumProcess::setNeutralLossWindowDalton
void setNeutralLossWindowDalton(pappso::pappso_double neutral_loss_precision)
Definition xtandemspectrumprocess.cpp:118
pappso::XtandemSpectrumProcess::getNeutralLossWindowDalton
pappso::pappso_double getNeutralLossWindowDalton() const
Definition xtandemspectrumprocess.cpp:224
pappso::XtandemSpectrumProcess::_bo_ions
bool _bo_ions
Definition xtandemspectrumprocess.h:104
pappso::XtandemSpectrumProcess::_a_ions
bool _a_ions
Definition xtandemspectrumprocess.h:100
pappso::XtandemSpectrumProcess::_x_ions
bool _x_ions
Definition xtandemspectrumprocess.h:101
pappso::XtandemSpectrumProcess::setDynamicRange
void setDynamicRange(pappso::pappso_double dynamic_range)
Definition xtandemspectrumprocess.cpp:90
pappso::XtandemSpectrumProcess::m_isRemoveIsotope
bool m_isRemoveIsotope
Definition xtandemspectrumprocess.h:86
pappso::XtandemSpectrumProcess::m_neutralLossWindowDalton
pappso::pappso_double m_neutralLossWindowDalton
Definition xtandemspectrumprocess.h:92
pappso::XtandemSpectrumProcess::getExcludeParent
bool getExcludeParent() const
Definition xtandemspectrumprocess.cpp:209
pappso::XtandemSpectrumProcess::process
MassSpectrum process(const MassSpectrum &spectrum, pappso_double parent_ion_mass, unsigned int parent_charge) const
process raw spectrum to prepare hyperscore computation
Definition xtandemspectrumprocess.cpp:281
pappso::XtandemSpectrumProcess::m_filter_highpass
FilterHighPass m_filter_highpass
Definition xtandemspectrumprocess.h:85
pappso::XtandemSpectrumProcess::setExcludeParent
void setExcludeParent(bool exclude_parent)
Definition xtandemspectrumprocess.cpp:102
pappso::XtandemSpectrumProcess::_yo_ions
bool _yo_ions
Definition xtandemspectrumprocess.h:105
pappso::XtandemSpectrumProcess::setNmostIntense
void setNmostIntense(unsigned int nmost_intense)
Definition xtandemspectrumprocess.cpp:85
pappso::XtandemSpectrumProcess::_z_ions
bool _z_ions
Definition xtandemspectrumprocess.h:99
pappso::XtandemSpectrumProcess::m_isExcludeParent_neutral_loss
bool m_isExcludeParent_neutral_loss
Definition xtandemspectrumprocess.h:90
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::PeptideIon
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition types.h:432
pappso::PeptideIon::a
@ a
Nter aldimine ions.
pappso::PeptideIon::y
@ y
Cter amino ions.
pappso::PeptideIon::c
@ c
Nter amino ions.
pappso::PeptideIon::astar
@ astar
Nter aldimine ions + NH3 loss.
pappso::PeptideIon::bp
@ bp
pappso::PeptideIon::yp
@ yp
pappso::PeptideIon::ystar
@ ystar
Cter amino ions + NH3 loss.
pappso::PeptideIon::yo
@ yo
Cter amino ions + H2O loss.
pappso::PeptideIon::bstar
@ bstar
Nter acylium ions + NH3 loss.
pappso::PeptideIon::b
@ b
Nter acylium ions.
pappso::PeptideIon::x
@ x
Cter acylium ions.
pappso::PeptideIon::bo
@ bo
Nter acylium ions + H2O loss.
pappso::PeptideIon::ao
@ ao
Nter aldimine ions + H2O loss.
pappso::PeptideIon::z
@ z
Cter carbocations.
pappso::MHPLUS
const pappso_double MHPLUS(1.007276466879)
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:50
xtandemspectrumprocess.h