Loading...
Searching...
No Matches
peptidefragment.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/peptide/peptidefragment.h
* \date 10/3/2015
* \author Olivier Langella
* \brief peptide fragment model
*/
/*******************************************************************************
* 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
******************************************************************************/
#include "peptidefragment.h"
#include "pappsomspp/core/pappsoexception.h"
namespace pappso
{
PeptideFragment::PeptideFragment(const PeptideSp &sp_peptide,
PeptideDirection direction,
unsigned int size)
: msp_peptide(sp_peptide), m_direction(direction), m_size(size)
{
if(m_direction == PeptideDirection::Nter)
{
std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
unsigned int i = 0;
while(i < m_size)
{
m_mass += it->getMass();
it++;
i++;
}
if(msp_peptide.get()->getNterModification() != nullptr)
{
m_mass += msp_peptide.get()->getNterModification()->getMass();
}
}
else
{
std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
unsigned int i = 0;
while(i < m_size)
{
m_mass += it->getMass();
it++;
i++;
}
if(msp_peptide.get()->getCterModification() != nullptr)
{
m_mass += msp_peptide.get()->getCterModification()->getMass();
}
}
m_mass += msp_peptide.get()->getCleavageNterModification()->getMass();
m_mass += msp_peptide.get()->getCleavageCterModification()->getMass();
}
PeptideFragment::PeptideFragment(const PeptideFragment &other)
: msp_peptide(other.msp_peptide), m_direction(other.m_direction), m_size(other.m_size)
{
m_mass = other.m_mass;
}
PeptideFragment::PeptideFragment(PeptideFragment &&toCopy) // move constructor
: msp_peptide(std::move(toCopy.msp_peptide)),
m_direction(toCopy.m_direction),
m_size(toCopy.m_size),
m_mass(toCopy.m_mass)
{
}
PeptideFragment::~PeptideFragment()
{
}
const QString
PeptideFragment::getPeptideIonDirectionName(PeptideDirection direction)
{
switch(direction)
{
case PeptideDirection::Cter:
return "Cter";
break;
case PeptideDirection::Nter:
return "Nter";
break;
default:
throw PappsoException(QString("direction name not implemented"));
break;
}
}
const QString
PeptideFragment::getSequence() const
{
QString sequence = msp_peptide.get()->getSequence();
int diffSize = msp_peptide.get()->size() - m_size;
if(m_direction == PeptideDirection::Nter)
{
sequence = sequence.mid(0, m_size);
}
else
{
sequence = sequence.mid(diffSize, m_size);
}
return sequence;
}
int
PeptideFragment::getNumberOfAtom(Enums::AtomIsotopeSurvey atom) const
{
int number = 0;
if(m_direction == PeptideDirection::Nter)
{
std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
unsigned int i = 0;
while(i < m_size)
{
number += it->getNumberOfAtom(atom);
it++;
i++;
}
if(msp_peptide.get()->getNterModification() != nullptr)
{
number += msp_peptide.get()->getNterModification()->getNumberOfAtom(atom);
}
}
else
{
std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
unsigned int i = 0;
while(i < m_size)
{
number += it->getNumberOfAtom(atom);
it++;
i++;
}
if(msp_peptide.get()->getCterModification() != nullptr)
{
number += msp_peptide.get()->getCterModification()->getNumberOfAtom(atom);
}
}
number += msp_peptide.get()->getCleavageNterModification()->getNumberOfAtom(atom);
number += msp_peptide.get()->getCleavageCterModification()->getNumberOfAtom(atom);
// qDebug() << "Aa::getMass() end " << mass;
return number;
}
int
PeptideFragment::getNumberOfIsotope(Enums::Isotope isotope) const
{
int number = 0;
if(m_direction == PeptideDirection::Nter)
{
std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
unsigned int i = 0;
while(i < m_size)
{
number += it->getNumberOfIsotope(isotope);
it++;
i++;
}
if(msp_peptide.get()->getNterModification() != nullptr)
{
number += msp_peptide.get()->getNterModification()->getNumberOfIsotope(isotope);
}
}
else
{
std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
unsigned int i = 0;
while(i < m_size)
{
number += it->getNumberOfIsotope(isotope);
it++;
i++;
}
if(msp_peptide.get()->getCterModification() != nullptr)
{
number += msp_peptide.get()->getCterModification()->getNumberOfIsotope(isotope);
}
}
number += msp_peptide.get()->getCleavageNterModification()->getNumberOfIsotope(isotope);
number += msp_peptide.get()->getCleavageCterModification()->getNumberOfIsotope(isotope);
// number += m_nterCterCleavage->getNumberOfIsotope(atom);
// qDebug() << "Aa::getMass() end " << mass;
return number;
}
const PeptideSp &
PeptideFragment::getPeptideSp() const
{
return msp_peptide;
};
unsigned int
PeptideFragment::size() const
{
return m_size;
}
pappso_double
PeptideFragment::getMass() const
{
return m_mass;
}
PeptideDirection
PeptideFragment::getPeptideIonDirection() const
{
return m_direction;
}
bool
PeptideFragment::isPalindrome() const
{
return msp_peptide.get()->isPalindrome();
}
} // namespace pappso
pappso::PappsoException
Definition pappsoexception.h:41
pappso::PeptideFragment::m_size
const unsigned int m_size
Definition peptidefragment.h:74
pappso::PeptideFragment::getPeptideIonDirection
PeptideDirection getPeptideIonDirection() const
Definition peptidefragment.cpp:240
pappso::PeptideFragment::getMass
virtual pappso_double getMass() const override
Definition peptidefragment.cpp:234
pappso::PeptideFragment::getSequence
virtual const QString getSequence() const override
amino acid sequence without modification
Definition peptidefragment.cpp:120
pappso::PeptideFragment::msp_peptide
const PeptideSp msp_peptide
Definition peptidefragment.h:72
pappso::PeptideFragment::PeptideFragment
PeptideFragment(const PeptideSp &sp_peptide, PeptideDirection direction, unsigned int size)
Definition peptidefragment.cpp:38
pappso::PeptideFragment::getPeptideSp
virtual const PeptideSp & getPeptideSp() const
Definition peptidefragment.cpp:223
pappso::PeptideFragment::getPeptideIonDirectionName
static const QString getPeptideIonDirectionName(PeptideDirection direction)
Definition peptidefragment.cpp:103
pappso::PeptideFragment::isPalindrome
virtual bool isPalindrome() const override
tells if the peptide sequence is a palindrome
Definition peptidefragment.cpp:246
pappso::PeptideFragment::~PeptideFragment
virtual ~PeptideFragment()
Definition peptidefragment.cpp:98
pappso::PeptideFragment::getNumberOfIsotope
virtual int getNumberOfIsotope(Enums::Isotope isotope) const override
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
Definition peptidefragment.cpp:179
pappso::PeptideFragment::size
virtual unsigned int size() const override
Definition peptidefragment.cpp:228
pappso::PeptideFragment::m_mass
pappso_double m_mass
Definition peptidefragment.h:76
pappso::PeptideFragment::m_direction
const PeptideDirection m_direction
Definition peptidefragment.h:73
pappso::PeptideFragment::getNumberOfAtom
virtual int getNumberOfAtom(Enums::AtomIsotopeSurvey atom) const override
get the number of atom C, O, N, H in the molecule
Definition peptidefragment.cpp:137
pappso::Enums::AtomIsotopeSurvey
AtomIsotopeSurvey
Definition types.h:110
pappso::Enums::Isotope
Isotope
Definition types.h:126
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition aamodification.h:48
pappso::PeptideDirection
PeptideDirection
Definition peptide.h:47
pappso::PeptideDirection::Cter
@ Cter
Definition peptide.h:49
pappso::PeptideDirection::Nter
@ Nter
Definition peptide.h:48
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60
pappsoexception.h
peptidefragment.h