protein.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/protein/protein.cpp
* \date 2/7/2015
* \author Olivier Langella
* \brief object to handle a protein
*/
/*******************************************************************************
* 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 "protein.h"
#include "../peptide/peptide.h"
#include <QStringList>
#include <algorithm>
#include "../pappsoexception.h"
namespace pappso
{
QRegExp Protein::m_removeTranslationStopRegExp("\\*$");
/*
* http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml
*/
// For those programs that use amino acid query sequences (BLASTP and
// TBLASTN), the accepted amino acid codes are:
//
// A alanine P proline
// B aspartate/asparagine Q glutamine
// C cystine R arginine
// D aspartate S serine
// E glutamate T threonine
// F phenylalanine U selenocysteine
// G glycine V valine
// H histidine W tryptophan
// I isoleucine Y tyrosine
// K lysine Z glutamate/glutamine
// L leucine X any
// M methionine * translation stop
// N asparagine - gap of indeterminate length
Protein::Protein()
{
}
Protein::Protein(const QString &description, const QString &sequence)
: m_description(description.simplified()),
m_accession(m_description.split(" ").at(0)),
m_sequence(sequence)
{
m_description = m_description.remove(0, m_accession.size()).simplified();
// m_sequence.replace(m_removeTranslationStopRegExp, "");
m_length = m_sequence.size();
}
Protein::Protein(const Protein &protein)
: m_description(protein.m_description),
m_accession(protein.m_accession),
m_sequence(protein.m_sequence),
m_length(protein.m_length)
{
}
Protein &
Protein::removeTranslationStop()
{
m_sequence.replace(m_removeTranslationStopRegExp, "");
return (*this);
}
Protein &
Protein::reverse()
{
std::reverse(m_sequence.begin(), m_sequence.end());
return (*this);
}
ProteinSp
Protein::makeProteinSp() const
{
return std::make_shared<Protein>(*this);
}
bool
Protein::operator==(const Protein &other) const
{
return (m_accession == other.m_accession);
}
void
Protein::setSequence(const QString &sequence)
{
m_sequence = sequence.simplified();
m_length = m_sequence.size();
}
unsigned int
Protein::size() const
{
return m_length;
}
const QString &
Protein::getSequence() const
{
return m_sequence;
}
const QString &
Protein::getAccession() const
{
return m_accession;
}
void
Protein::setAccession(const QString &accession)
{
m_accession = accession.simplified();
}
const QString &
Protein::getDescription() const
{
return m_description;
}
void
Protein::setDescription(const QString &description)
{
m_description = description.simplified();
}
Protein::~Protein()
{
}
pappso_double
Protein::getMass() const
{
try
{
// qDebug() << "ProteinXtp::getMass() begin " <<
// getOnlyAminoAcidSequence().replace("[BZX]","E");
// replace amino acid wildcard by E, just to give an random mass (assumed
// it is not perfect)
QString sequence(m_sequence);
sequence.replace(QRegExp("[^WGASPVTLINDKQEMHFRCYUBZX]"), "");
pappso::Peptide peptide(sequence.replace(QRegExp("[BZX]"), "E"));
return peptide.getMass();
}
catch(pappso::PappsoException &error)
{
throw pappso::PappsoException(
QObject::tr("Error computing mass for protein %1 :\n%2")
.arg(getAccession())
.arg(error.qwhat()));
}
}
} // namespace pappso
pappso::PappsoException
Definition: pappsoexception.h:42
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition: pappsoexception.h:68
pappso::Peptide
Definition: peptide.h:93
pappso::Peptide::getMass
pappso_double getMass()
Definition: peptide.cpp:191
pappso::Protein
Definition: protein.h:50
pappso::Protein::getAccession
const QString & getAccession() const
Definition: protein.cpp:127
pappso::Protein::m_removeTranslationStopRegExp
static QRegExp m_removeTranslationStopRegExp
Definition: protein.h:62
pappso::Protein::~Protein
~Protein()
Definition: protein.cpp:146
pappso::Protein::getDescription
const QString & getDescription() const
Definition: protein.cpp:137
pappso::Protein::removeTranslationStop
Protein & removeTranslationStop()
remove * characters at the end of the sequence
Definition: protein.cpp:83
pappso::Protein::Protein
Protein()
Definition: protein.cpp:62
pappso::Protein::m_length
unsigned int m_length
number of amino acid
Definition: protein.h:60
pappso::Protein::getMass
pappso_double getMass() const
get monoisotopic mass of ProteinSp Protein::makeProteinSp() const
Definition: protein.cpp:150
pappso::Protein::m_sequence
QString m_sequence
the amino acid sequence
Definition: protein.h:58
pappso::Protein::size
unsigned int size() const
protein amino acid sequence size
Definition: protein.cpp:116
pappso::Protein::reverse
Protein & reverse()
reverse characters in the sequence
Definition: protein.cpp:90
pappso::Protein::m_accession
QString m_accession
a single unique identifier of the protein (usually the first word of description)
Definition: protein.h:56
pappso::Protein::operator==
bool operator==(const Protein &other) const
Definition: protein.cpp:104
pappso::Protein::m_description
QString m_description
free text to describe the protein
Definition: protein.h:53
pappso::Protein::makeProteinSp
ProteinSp makeProteinSp() const
Definition: protein.cpp:97
pappso::Protein::setSequence
void setSequence(const QString &sequence)
Definition: protein.cpp:110
pappso::Protein::getSequence
const QString & getSequence() const
Definition: protein.cpp:122
pappso::Protein::setDescription
void setDescription(const QString &description)
Definition: protein.cpp:142
pappso::Protein::setAccession
virtual void setAccession(const QString &accession)
Definition: protein.cpp:132
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:48
pappso::ProteinSp
std::shared_ptr< const Protein > ProteinSp
shared pointer on a Protein object
Definition: protein.h:43
protein.h
object to handle a protein