libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
protein.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/protein/protein.cpp
3
* \date 2/7/2015
4
* \author Olivier Langella
5
* \brief object to handle a protein
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
10
*
11
* This file is part of the PAPPSOms++ library.
12
*
13
* PAPPSOms++ is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* PAPPSOms++ is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25
*
26
* Contributors:
27
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
28
*implementation
29
******************************************************************************/
30
31
#include "
protein.h
"
32
#include "
../peptide/peptide.h
"
33
#include <QStringList>
34
#include <algorithm>
35
#include "
pappsomspp/core/pappsoexception.h
"
36
37
namespace
pappso
38
{
39
40
QRegularExpression
Protein::m_removeTranslationStopRegExp
(
"\\*$"
);
41
42
/*
43
* http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml
44
*/
45
// For those programs that use amino acid query sequences (BLASTP and
46
// TBLASTN), the accepted amino acid codes are:
47
//
48
// A alanine P proline
49
// B aspartate/asparagine Q glutamine
50
// C cystine R arginine
51
// D aspartate S serine
52
// E glutamate T threonine
53
// F phenylalanine U selenocysteine
54
// G glycine V valine
55
// H histidine W tryptophan
56
// I isoleucine Y tyrosine
57
// K lysine Z glutamate/glutamine
58
// L leucine X any
59
// M methionine * translation stop
60
// N asparagine - gap of indeterminate length
61
62
Protein::Protein
()
63
{
64
}
65
Protein::Protein
(
const
QString &description,
const
QString &sequence)
66
:
m_description
(description.simplified()),
67
m_accession
(
m_description
.split(
" "
).at(0)),
68
m_sequence
(sequence)
69
{
70
m_description
=
m_description
.remove(0,
m_accession
.size()).simplified();
71
// m_sequence.replace(m_removeTranslationStopRegExp, "");
72
m_length
=
m_sequence
.size();
73
}
74
Protein::Protein
(
const
Protein
&protein)
75
:
m_description
(protein.
m_description
),
76
m_accession
(protein.
m_accession
),
77
m_sequence
(protein.
m_sequence
),
78
m_length
(protein.
m_length
)
79
{
80
}
81
82
Protein
&
83
Protein::removeTranslationStop
()
84
{
85
m_sequence
.replace(
m_removeTranslationStopRegExp
,
""
);
86
return
(*
this
);
87
}
88
89
Protein
&
90
Protein::reverse
()
91
{
92
std::reverse(
m_sequence
.begin(),
m_sequence
.end());
93
return
(*
this
);
94
}
95
96
ProteinSp
97
Protein::makeProteinSp
()
const
98
{
99
return
std::make_shared<Protein>(*
this
);
100
}
101
102
103
bool
104
Protein::operator==
(
const
Protein
&other)
const
105
{
106
return
(
m_accession
== other.
m_accession
);
107
}
108
109
void
110
Protein::setSequence
(
const
QString &sequence)
111
{
112
m_sequence
= sequence.simplified();
113
m_length
=
m_sequence
.size();
114
}
115
unsigned
int
116
Protein::size
()
const
117
{
118
return
m_length
;
119
}
120
121
const
QString &
122
Protein::getSequence
()
const
123
{
124
return
m_sequence
;
125
}
126
const
QString &
127
Protein::getAccession
()
const
128
{
129
return
m_accession
;
130
}
131
void
132
Protein::setAccession
(
const
QString &accession)
133
{
134
m_accession
= accession.simplified();
135
}
136
const
QString &
137
Protein::getDescription
()
const
138
{
139
return
m_description
;
140
}
141
void
142
Protein::setDescription
(
const
QString &description)
143
{
144
m_description
= description.simplified();
145
}
146
Protein::~Protein
()
147
{
148
}
149
pappso_double
150
Protein::getMass
()
const
151
{
152
try
153
{
154
// qDebug() << "ProteinXtp::getMass() begin " <<
155
// getOnlyAminoAcidSequence().replace("[BZX]","E");
156
// replace amino acid wildcard by E, just to give an random mass (assumed
157
// it is not perfect)
158
QString sequence(
m_sequence
);
159
sequence.replace(QRegularExpression(
"[^WGASPVTLINDKQEMHFRCYUBZX]"
),
""
);
160
pappso::Peptide
peptide(sequence.replace(QRegularExpression(
"[BZX]"
),
"E"
));
161
return
peptide.
getMass
();
162
}
163
catch
(
pappso::PappsoException
&error)
164
{
165
throw
pappso::PappsoException
(QObject::tr(
"Error computing mass for protein %1 :\n%2"
)
166
.arg(
getAccession
())
167
.arg(error.
qwhat
()));
168
}
169
}
170
}
// namespace pappso
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition
pappsoexception.h:66
pappso::Peptide
Definition
peptide.h:102
pappso::Peptide::getMass
pappso_double getMass()
Definition
peptide.cpp:375
pappso::Protein
Definition
protein.h:50
pappso::Protein::getAccession
const QString & getAccession() const
Definition
protein.cpp:127
pappso::Protein::~Protein
virtual ~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:98
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:96
pappso::Protein::m_removeTranslationStopRegExp
static QRegularExpression m_removeTranslationStopRegExp
Definition
protein.h:100
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:94
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:91
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:60
pappso::ProteinSp
std::shared_ptr< const Protein > ProteinSp
shared pointer on a Protein object
Definition
protein.h:47
pappsoexception.h
peptide.h
protein.h
pappsomspp
core
protein
protein.cpp
Generated on
for libpappsomspp by
1.17.0