27#include "boost/thread/thread.hpp"
28#include "boost/thread/barrier.hpp"
41 Peptide angiotensin(
"DRVYIHPF");
70 {
"ELK", 388.2322, 389.24005, 195.12396, 388.45918, 389.4665, 195.2369 },
71 {
"DEERLICKER", 1289.6398, 1290.6477, 645.8278, 1290.44644, 1291.4537, 646.2305 },
72 {
"ELVISLIVES", 1100.6329, 1101.6408, 551.3243, 1101.29052, 1102.2978, 551.6525 },
73 {
"THEQUICKRWNFUMPSVERTHELAYDG", 3348.3249, 3349.3328, 1675.17035, 3348.44626, 3349.45416, 1675.23103 },
74 {
"No?PepTidE...", 0, 0, 0, 0, 0, 0 }
84 double BIG_EPSILON = 0.001;
122 {
"M",
"O1", 15.9949, 15.9994,
true },
123 {
"C",
"C2H3N1O1", 57.02146, 57.052,
false },
124 {
"(Q",
"N-1H-3", -17.02655, -17.0306,
false },
125 {
"(E",
"N-1H-3", -17.02655, -17.0306,
true },
126 {
"N!G",
"N-1H-3", -17.02655, -17.0306,
true },
128 {
"[STY]!{STY}",
"H1P1O3", 79.96633, 79.9799,
true },
129 {
"(",
"C2H2O1", 42.010565, 42.0367,
true },
130 {
"[ED)]",
"C2H5N1", 43.042199, 43.0678,
true },
138 ModificationParsing
mp;
139 ModificationDelimiter
md;
153 879.41205, 879.97844,
163 879.41205, 879.97844,
171 ModificationParsing_Auto,
173 879.41205, 879.97844,
178 {
"M(15.9949,15.9994)EERKAT",
183 879.41205, 879.97844,
188 {
"M[15.9949,15.9994]EERKAT",
193 879.41205, 879.97844,
198 {
"M(15.9949,15.9994)EERKAT",
201 ModificationParsing_Auto,
203 879.41205, 879.97844,
213 879.41205, 879.97844,
218 {
"THEQICKRWNFMPSVERTHELAYDG",
223 3103.43929, 3105.4218,
228 {
"THEQICKRWNFMPSVERTHELAYDG",
233 3119.43419, 3121.4212,
238 {
"THEQIC{C2H3N1O1}KRWNFM{O1}PSVERTHELAYDG",
242 ModificationDelimiter_Braces,
243 3119.43419, 3121.4212,
248 {
"THEQIC{C2H3N1O1}KRWNFM{15.9949,15.9994}PSVERTHELAYDG",
251 ModificationParsing_Auto,
252 ModificationDelimiter_Braces,
253 3119.43419, 3121.4212,
258 {
"QICKRWNFMPSVERTHELAYDG",
263 2719.26356, 2721.0341,
273 1100.63293, 1101.29052,
288 {
"E(N-1H-3)LVISLIVES",
298 {
"E(N-1H-3)LVISLIVES",
308 {
"E(N-1H-3)LVISLIVES",
311 ModificationParsing_Auto,
318 {
"E(-17.02655,-17.0306)LVISLIVES",
328 {
"E(-17.02655,-17.0306)LVISLIVES",
331 ModificationParsing_Auto,
363 1143.62099, 1144.3815,
371 ModificationParsing_Auto,
373 1143.62099, 1144.3815,
383 1303.55365, 1304.3413,
393 709.339545, 709.7479,
419 double monoDeltaMass = 0;
420 double avgDeltaMass = 0;
421 double BIG_EPSILON = 0.001;
436 vector<string> tokens;
437 boost::split(tokens, p.
mods, boost::is_space());
438 for (
size_t i=0; i < tokens.size(); i+=2)
443 if (tokens[i+1] ==
"n")
445 else if (tokens[i+1] ==
"c")
448 modOffset = lexical_cast<int>(tokens[i+1]);
464 vector<string> tokens;
465 boost::split(tokens, p.
mods, boost::is_space());
466 for (
size_t i=0; i < tokens.size(); i+=2)
471 if (tokens[i+1] ==
"n")
473 else if (tokens[i+1] ==
"c")
476 modOffset = lexical_cast<int>(tokens[i+1]);
499 }
else if (p.
mods != NULL)
501 "[Peptide::formula()] peptide formula cannot be generated when any modifications have no formula info");
512 cout <<
"Unit test " << lexical_cast<string>(i+1) <<
" on modified peptide \"" << p.
sequence <<
"\" failed:\n" << e.what() << endl;
527 {
"PEPTIDE",
"PEPTIDE", 0},
528 {
"PEPTIDE",
"PEPTIDEK", -1},
529 {
"PEPTIDEK",
"PEPTIDE", 1},
531 {
"(42)PEPTIDE",
"(42)PEPTIDE", 0},
532 {
"PEP(42)TIDE",
"PEP(42)TIDE", 0},
533 {
"PEPTIDE(42)",
"PEPTIDE(42)", 0},
534 {
"PEPTIDE",
"(42)PEPTIDE", -1},
535 {
"(42)PEPTIDE",
"PEPTIDE", 1},
536 {
"PEPTIDE(41)",
"PEPTIDE(42)", -1},
537 {
"PEPTIDE(42)",
"PEPTIDE(41)", 1},
538 {
"(42)PEPTIDE(42)",
"(42)PEPTIDE(42)", 0},
539 {
"(42)PEPTIDE(41)",
"(42)PEPTIDE(42)", -1},
540 {
"(42)PEPTIDE(42)",
"(42)PEPTIDE(41)", 1},
541 {
"(42)PEPTIDE",
"(42)PEPTIDE(42)", -1},
542 {
"(42)PEPTIDE(42)",
"PEPTIDE(42)", 1},
543 {
"P(42)EPTIDE(42)",
"PEPTIDE(42)", 1},
544 {
"(42)PEPTIDE",
"P(42)EPTIDE", -1},
545 {
"P(42)EPTIDE",
"(42)PEPTIDE", 1},
592 cout <<
"Unit test " << lexical_cast<string>(i+1) <<
" comparing \"" << p.
lhsPeptide <<
"\" and \"" << p.
rhsPeptide <<
"\" failed:\n" << e.what() << endl;
614 104.05344, 818.41949, 52.53066, 409.71368,
615 132.04836, 846.41441, 66.52811, 423.71114,
616 149.07490, 762.39328, 75.04139, 381.70057,
617 146.04538, 759.36375, 73.52662, 380.18581,
618 120.06611, 864.42497, 60.53699, 432.71642,
619 103.03956, 847.39842, 52.02372, 424.20315
622 {
"THEQICKRWNFMPSVERTHELAYDG",
623 74.06063, 3001.42018, 37.53425, 1501.21402,
624 102.05555, 3029.41509, 51.53171, 1515.21148,
625 119.08210, 2989.42018, 60.04498, 1495.21402,
626 102.01916, 2972.35724, 51.51352, 1486.68256,
627 76.03990, 3047.42566, 38.52388, 1524.21676,
628 59.01335, 3030.39911, 30.01061, 1515.70349
636 size_t length = p.
sequence().length();
639 for (
size_t i=1; i <= length; ++i)
644 for (
size_t i=1; i <= length; ++i)
649 for (
size_t i=1; i < length; ++i)
654 for (
size_t i=1; i < length; ++i)
659 for (
size_t i=1; i <= length; ++i)
664 for (
size_t i=1; i <= length; ++i)
671 const double EPSILON = 0.005;
676 size_t length = string(tf.
sequence).length();
728 Peptide p(
"THEQICKRWNFMPSVERTHELAYDG");
736 double EPSILON = 0.00000001;
737 for (
size_t i=1; i <= 5; ++i)
744 for (
size_t i=6; i <= 11; ++i)
746 double deltaMass = C57.monoisotopicDeltaMass();
752 for (
size_t i=12; i <= p.
sequence().length(); ++i)
761 for (
size_t i=1; i <= 13; ++i)
768 for (
size_t i=14; i <= 19; ++i)
776 for (
size_t i=20; i <= p.
sequence().length(); ++i)
787 Peptide p(
"QICKRWNFMPSVERTHELAYDG");
795 double EPSILON = 0.00000001;
797 for (
size_t i=0; i <= 10; ++i)
799 double deltaMass = Q17.monoisotopicDeltaMass();
805 for (
size_t i=11; i <= p.
sequence().length(); ++i)
814 for (
size_t i=1; i <= 11; ++i)
821 for (
size_t i=12; i <= p.
sequence().length(); ++i)
846 cerr <<
"Exception in worker thread: " << e.what() << endl;
850 cerr <<
"Unhandled exception in worker thread." << endl;
856 boost::barrier testBarrier(testThreadCount);
857 boost::thread_group testThreadGroup;
858 for (
int i=0; i < testThreadCount; ++i)
860 testThreadGroup.join_all();
864int main(
int argc,
char* argv[])
870 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
871 if (
os_) *
os_ <<
"PeptideTest\n";
ModificationDelimiter_Parentheses
ModificationParsing_ByMass
oxidized P in peptide: PEP(O)TIDE
ModificationParsing_ByFormula
any non-AA characters will cause an exception
ModificationDelimiter_Brackets
'(' and ')'
int main(int argc, char *argv[])
const TestOperator testOperators[]
void testThreadSafetyWorker(boost::barrier *testBarrier)
const TestFragmentation testFragmentations[]
void writeFragmentation(const Peptide &p, const Fragmentation &f, ostream &os)
const size_t testPeptidesSize
const size_t testOperatorsSize
const size_t testFragmentationsSize
TestModifiedPeptide testModifiedPeptides[]
TestPeptide testPeptides[]
TestModification testModifications[]
const size_t testModificationsSize
const size_t testModifiedPeptidesSize
provides fragment ion masses for a peptide
double x(size_t length, size_t charge=0) const
returns the x ion of length <length> example: x(1) returns the x1 ion if <charge> = 0: returns neutra...
double c(size_t length, size_t charge=0) const
returns the c ion of length <length> example: c(1) returns the c1 ion if <charge> = 0: returns neutra...
double z(size_t length, size_t charge=0) const
returns the z ion of length <length> example: z(1) returns the z1 ion if <charge> = 0: returns neutra...
double b(size_t length, size_t charge=0) const
returns the b ion of length <length> example: b(1) returns the b1 ion if <charge> = 0: returns neutra...
double a(size_t length, size_t charge=0) const
returns the a ion of length <length>; example: a(1) returns the a1 ion if <charge> = 0: returns neutr...
double y(size_t length, size_t charge=0) const
returns the y ion of length <length> example: y(1) returns the y1 ion if <charge> = 0: returns neutra...
represents a post-translational modification (PTM) modification formula or masses must be provided at...
double monoisotopicDeltaMass() const
represents a list of modifications on a single amino acid
maps peptide/protein sequence indexes (0-based) to a modification list
virtual iterator end()
Returns an iterator pointing to the last element stored in the map; in other words,...
virtual iterator find(const key_type &x)
Searches the map for a pair with the key value x and returns an iterator to that pair if it is found....
represents a peptide or polypeptide (a sequence of amino acids)
const std::string & sequence() const
returns the sequence of amino acids making up the peptide
chemistry::Formula formula(bool modified=false) const
if modified = false: returns the composition formula of sequence()+water if modified = true: returns ...
double molecularWeight(int charge=0, bool modified=true) const
if charge = 0: returns neutral mass if charge > 0: returns charged m/z if modified = false: returns t...
double monoisotopicMass(int charge=0, bool modified=true) const
if charge = 0: returns neutral mass if charge > 0: returns charged m/z if modified = false: returns t...
Fragmentation fragmentation(bool monoisotopic=true, bool modified=true) const
returns a fragmentation model for the peptide; fragment masses can calculated as mono/avg and as modi...
ModificationMap & modifications()
the map of sequence offsets (0-based) to modifications; modifications can be added or removed from th...
virtual bool empty() const
Returns true if the map is empty, false otherwise.
BaseType::const_iterator const_iterator
const double Proton
the mass of a proton in unified atomic mass units
#define unit_assert_equal(x, y, epsilon)
#define unit_assert_throws_what(x, exception, whatStr)
#define TEST_PROLOG(argc, argv)