29 #include "boost/thread/thread.hpp" 30 #include "boost/thread/barrier.hpp" 31 #include "boost/exception/all.hpp" 32 #include "boost/foreach_field.hpp" 46 const vector<string>& cleavageAgentNames = Digestion::getCleavageAgentNames();
50 *
os_ <<
"Cleavage agents:" << endl;
51 BOOST_FOREACH(CVID agentCvid, cleavageAgents)
54 << Digestion::getCleavageAgentRegex(agentCvid)
58 *
os_ <<
"\nCleavage agent names" << endl;
59 BOOST_FOREACH(
string agentName, cleavageAgentNames)
61 *
os_ << agentName << endl;
122 const string& expectedSequence,
123 size_t expectedOffset,
124 size_t expectedMissedCleavages,
125 size_t expectedSpecificTermini,
126 const string& expectedPrefix,
127 const string& expectedSuffix)
141 cerr <<
"Testing peptide " << peptide.
sequence() <<
": " << e.what() << endl;
148 if (
os_) *
os_ <<
"Fully-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
150 vector<DigestedPeptide> trypticPeptides(trypticDigestion.
begin(), trypticDigestion.
end());
151 set<DigestedPeptide, DigestedPeptideLessThan> trypticPeptideSet(trypticPeptides.begin(), trypticPeptides.end());
173 unit_assert(!trypticPeptideSet.count(
"MKWVTFISLLLL"));
177 unit_assert(trypticPeptideSet.count(
"RDTHKSEIAHRFK"));
178 unit_assert(trypticPeptideSet.count(
"DTHKSEIAHRFK"));
181 unit_assert(trypticPeptideSet.count(
"EACFAVEGPKLVVSTQTALA"));
182 unit_assert(trypticPeptides.back().sequence() ==
"LVVSTQTALA");
185 unit_assert(!trypticPeptideSet.count(
"MKWVTFISLLLLFSSAYSRGVFRRDTHK"));
186 unit_assert(!trypticPeptideSet.count(
"LKPDPNTLCDEFKADEKKFWGKYLYEIARR"));
191 unit_assert(trypticPeptideSet.count(
"VLASSARQRLR"));
194 unit_assert(!trypticPeptideSet.count(
"MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFK"));
197 unit_assert(trypticPeptideSet.count(
"KWVTFISLLLLFSSAYSR"));
202 if (
os_) *
os_ <<
"Semi-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
204 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
206 vector<DigestedPeptide> semitrypticPeptides(semitrypticDigestion.
begin(), semitrypticDigestion.
end());
207 set<DigestedPeptide, DigestedPeptideLessThan> semitrypticPeptideSet(semitrypticPeptides.begin(), semitrypticPeptides.end());
239 unit_assert(semitrypticPeptides[0].NTerminusIsSpecific() &&
240 !semitrypticPeptides[0].CTerminusIsSpecific());
242 peptideItr = semitrypticPeptideSet.find(
"MKWVTFISLLLLFSSAYSR");
243 unit_assert(peptideItr != semitrypticPeptideSet.end());
248 peptideItr->CTerminusIsSpecific());
250 peptideItr = semitrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSR");
251 unit_assert(peptideItr != semitrypticPeptideSet.end());
256 peptideItr->CTerminusIsSpecific());
258 peptideItr = semitrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSRG");
259 unit_assert(peptideItr == semitrypticPeptideSet.end());
261 peptideItr = semitrypticPeptideSet.find(
"WVTFISLLLLFSSAYSR");
262 unit_assert(peptideItr != semitrypticPeptideSet.end());
267 peptideItr->CTerminusIsSpecific());
269 peptideItr = semitrypticPeptideSet.find(
"WVTFISLLLLFSSAYSRG");
270 unit_assert(peptideItr != semitrypticPeptideSet.end());
275 !peptideItr->CTerminusIsSpecific());
277 peptideItr = semitrypticPeptideSet.find(
"VTFISLLLLFSSAYSRG");
278 unit_assert(peptideItr == semitrypticPeptideSet.end());
281 unit_assert(semitrypticPeptideSet.count(
"WVTFISLLLLFSSAYSR"));
282 unit_assert(semitrypticPeptideSet.count(
"VTFISLLLLFSSAYSR"));
283 unit_assert(!semitrypticPeptideSet.count(
"VTFISLLLLFSSAYS"));
286 unit_assert(semitrypticPeptideSet.count(
"FAVEGPKLVVSTQTALA"));
287 unit_assert(!semitrypticPeptideSet.count(
"FAVEGPKLVVSTQTAL"));
292 if (
os_) *
os_ <<
"Non-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
294 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
296 vector<DigestedPeptide> nontrypticPeptides(nontrypticDigestion.
begin(), nontrypticDigestion.
end());
297 set<DigestedPeptide, DigestedPeptideLessThan> nontrypticPeptideSet(nontrypticPeptides.begin(), nontrypticPeptides.end());
321 unit_assert(nontrypticPeptides[0].NTerminusIsSpecific() &&
322 !nontrypticPeptides[0].CTerminusIsSpecific());
324 peptideItr = nontrypticPeptideSet.find(
"MKWVTFISLLLLFSSAYSR");
325 unit_assert(peptideItr != nontrypticPeptideSet.end());
330 peptideItr->CTerminusIsSpecific());
332 peptideItr = nontrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSR");
333 unit_assert(peptideItr != nontrypticPeptideSet.end());
338 peptideItr->CTerminusIsSpecific());
340 peptideItr = nontrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSRG");
341 unit_assert(peptideItr == nontrypticPeptideSet.end());
343 peptideItr = nontrypticPeptideSet.find(
"WVTFISLLLLFSSAYSR");
344 unit_assert(peptideItr != nontrypticPeptideSet.end());
349 peptideItr->CTerminusIsSpecific());
351 peptideItr = nontrypticPeptideSet.find(
"WVTFISLLLLFSSAYSRG");
352 unit_assert(peptideItr != nontrypticPeptideSet.end());
357 !peptideItr->CTerminusIsSpecific());
359 peptideItr = nontrypticPeptideSet.find(
"VTFISLLLLFSSAYSRG");
360 unit_assert(peptideItr != nontrypticPeptideSet.end());
365 !peptideItr->CTerminusIsSpecific());
368 unit_assert(nontrypticPeptideSet.count(
"WVTFISLLLLFSSAYSR"));
369 unit_assert(nontrypticPeptideSet.count(
"VTFISLLLLFSSAYSR"));
370 unit_assert(nontrypticPeptideSet.count(
"VTFISLLLLFSSAYS"));
373 unit_assert(nontrypticPeptideSet.count(
"FAVEGPKLVVSTQTALA"));
374 unit_assert(nontrypticPeptideSet.count(
"FAVEGPKLVVSTQTAL"));
378 unit_assert(nontrypticPeptideSet.count(
"KWVTFISLLLLFSSAYSR"));
379 unit_assert(!nontrypticPeptideSet.count(
"KWVTFISLLLLFSSAYSRG"));
384 unit_assert(nontrypticPeptideSet.count(
"VLASSAR"));
387 unit_assert(!nontrypticPeptideSet.count(
"EYEATLEECCAKDDPHACYSTVFDK"));
392 if (
os_) *
os_ <<
"Semi-specific BSA digest w/ methionine clipping (offset, missed cleavages, specific termini, length, sequence)" << endl;
394 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
396 vector<DigestedPeptide> semitrypticPeptides(semitrypticDigestion.
begin(), semitrypticDigestion.
end());
397 set<DigestedPeptide, DigestedPeptideLessThan> semitrypticPeptideSet(semitrypticPeptides.begin(), semitrypticPeptides.end());
430 unit_assert(semitrypticPeptides[0].NTerminusIsSpecific() &&
431 !semitrypticPeptides[0].CTerminusIsSpecific());
433 peptideItr = semitrypticPeptideSet.find(
"KWVTFISLLLLFSSAYS");
434 unit_assert(peptideItr != semitrypticPeptideSet.end());
440 peptideItr = semitrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSR");
441 unit_assert(peptideItr != semitrypticPeptideSet.end());
446 peptideItr->CTerminusIsSpecific());
448 peptideItr = semitrypticPeptideSet.find(
"KWVTFISLLLLFSSAYSRG");
449 unit_assert(peptideItr == semitrypticPeptideSet.end());
451 peptideItr = semitrypticPeptideSet.find(
"WVTFISLLLLFSSAYSR");
452 unit_assert(peptideItr != semitrypticPeptideSet.end());
457 peptideItr->CTerminusIsSpecific());
459 peptideItr = semitrypticPeptideSet.find(
"WVTFISLLLLFSSAYSRG");
460 unit_assert(peptideItr != semitrypticPeptideSet.end());
465 !peptideItr->CTerminusIsSpecific());
467 peptideItr = semitrypticPeptideSet.find(
"VTFISLLLLFSSAYSRG");
468 unit_assert(peptideItr == semitrypticPeptideSet.end());
471 unit_assert(semitrypticPeptideSet.count(
"WVTFISLLLLFSSAYSR"));
472 unit_assert(semitrypticPeptideSet.count(
"KWVTFISLLLLFSSAYSR"));
473 unit_assert(semitrypticPeptideSet.count(
"KWVTFISLLLLFSSAYS"));
474 unit_assert(!semitrypticPeptideSet.count(
"VTFISLLLLFSSAYS"));
477 unit_assert(semitrypticPeptideSet.count(
"FAVEGPKLVVSTQTALA"));
478 unit_assert(!semitrypticPeptideSet.count(
"FAVEGPKLVVSTQTAL"));
483 if (
os_) *
os_ <<
"BSA digestion test" << endl;
486 Peptide bsa(
"MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQQCPF" 487 "DEHVKLVNELTEFAKTCVADESHAGCEKSLHTLFGDELCKVASLRETYGDMADCCEKQEP" 488 "ERNECFLSHKDDSPDLPKLKPDPNTLCDEFKADEKKFWGKYLYEIARRHPYFYAPELLYY" 489 "ANKYNGVFQECCQAEDKGACLLPKIETMREKVLASSARQRLRCASIQKFGERALKAWSVA" 490 "RLSQKFPKAEFVEVTKLVTDLTKVHKECCHGDLLECADDRADLAKYICDNQDTISSKLKE" 491 "CCDKPLLEKSHCIAEVEKDAIPENLPPLTADFAEDKDVCKNYQEAKDAFLGSFLYEYSRR" 492 "HPEYAVSVLLRLAKEYEATLEECCAKDDPHACYSTVFDKLKHLVDEPQNLIKQNCDQFEK" 493 "LGEYGFQNALIVRYTRKVPQVSTPTLVEVSRSLGKVGTRCCTKPESERMPCTEDYLSLIL" 494 "NRLCVLHEKTPVSEKVTKCCTESLVNRRPCFSALTPDETYVPKAFDEKLFTFHADICTLP" 495 "DTEKQIKKQTALVELLKHKPKATEEQLKTVMENFVAFVDKCCAADDKEACFAVEGPKLVV" 516 vector<Peptide> funkyPeptides(funkyDigestion.
begin(), funkyDigestion.
end());
518 unit_assert_operator_equal(
"MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQQCPFDEHVKLVNELTEFAKTCVADESHAGCEKSLHTLFGDELCKVASLRETYGDMADCCEKQEPERNECFLSHKDDSPDLPKLKPDPNTLCDEFKADEKKFWGKYLYEIARRHPYFYAPELLYYANKYNGVFQECCQAEDKGACLLPKIETMREKVLASSARQRLRCASIQKFGERALKAWSVARLSQKFPKAE", funkyPeptides[0].sequence());
519 unit_assert_operator_equal(
"FVEVTKLVTDLTKVHKECCHGDLLECADDRADLAKYICDNQDTISSKLKECCDKPLLEKSHCIAEVEKDAIPENLPPLTAD", funkyPeptides[1].sequence());
520 unit_assert_operator_equal(
"FAEDKDVCKNYQEAKDAFLGSFLYEYSRRHPEYAVSVLLRLAKEYEATLEECCAKDDPHACYSTVFDKLKHLVDEPQNLIKQNCDQFEKLGEYGFQNALIVRYTRKVPQVSTPTLVEVSRSLGKVGTRCCTKPESERMPCTEDYLSLILNRLCVLHEKTPVSEKVTKCCTESLVNRRPCFSALTPDETYVPKAFDEKLFTFHADICTLPDTEKQIKKQTALVELLKHKPKATEEQLKTVMENFVAFVDKCCAADDKEACFAVEGPKLVVSTQTALA", funkyPeptides[2].sequence());
524 vector<Peptide> aspnPeptides(aspnDigestion.
begin(), aspnDigestion.
end());
533 vector<Peptide> noCleavagePeptides(noCleavageDigestion.
begin(), noCleavageDigestion.
end());
540 vector<Peptide> unspecificCleavagePeptides(unspecificCleavageDigestion.
begin(), unspecificCleavageDigestion.
end());
649 status.
exception = boost::copy_exception(runtime_error(e.what()));
653 status.
exception = boost::copy_exception(runtime_error(
"Unhandled exception in worker thread."));
661 boost::barrier testBarrier(testThreadCount);
662 list<pair<boost::shared_ptr<thread>,
ThreadStatus> > threads;
663 for (
int i=0; i < testThreadCount; ++i)
665 threads.push_back(make_pair(boost::shared_ptr<thread>(),
ThreadStatus()));
666 threads.back().first.reset(
new thread(
testThreadSafetyWorker, &testBarrier, boost::ref(threads.back().second)));
669 set<boost::shared_ptr<thread> > finishedThreads;
670 while (finishedThreads.size() < threads.size())
671 BOOST_FOREACH_FIELD((boost::shared_ptr<thread>& t)(
ThreadStatus& status), threads)
673 if (t->timed_join(boost::posix_time::seconds(1)))
674 finishedThreads.insert(t);
676 if (status.exception != NULL)
677 boost::rethrow_exception(status.exception);
682 int main(
int argc,
char* argv[])
686 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
687 if (
os_) *
os_ <<
"DigestionTest\n";
void testSemitrypticBSA(const Digestion &semitrypticDigestion)
void testCleavageAgents()
MS_Asp_N
Asp-N: Endoproteinase Asp-N.
PWIZ_API_DECL const CVTermInfo & cvTermInfo(CVID cvid)
returns CV term info for the specified CVID
MS_Arg_C
Arg-C: Endoproteinase Arg-C.
#define unit_assert_throws(x, exception)
void testTrypticBSA(const Digestion &trypticDigestion)
bool testDigestionMetadata(const DigestedPeptide &peptide, const string &expectedSequence, size_t expectedOffset, size_t expectedMissedCleavages, size_t expectedSpecificTermini, const string &expectedPrefix, const string &expectedSuffix)
void testThreadSafety(const int &testThreadCount)
MS_Trypsin
Trypsin: Enzyme trypsin.
PWIZ_API_DECL proteome::Peptide peptide(const Peptide &peptide)
creates a proteome::Peptide from an identdata::Peptide
size_t offset() const
returns the zero-based offset of the N terminus of the peptide in the polypeptide from which it was d...
MS_Glu_C
Glu-C (glutamyl endopeptidase): Enzyme glutamyl endopeptidase (EC 3.4.21.19).
sets constraints for valid peptides produced by iterating the digestion
MS_TrypChymo
TrypChymo: Cleavage agent TrypChymo.
MS_Asp_N_ambic
Asp-N_ambic: Enzyme Asp-N, Ammonium Bicarbonate (AmBic).
MS_CNBr
CNBr: Cyanogen bromide.
MS_V8_E
V8-E: Cleavage agent V8-E.
ThreadStatus(const boost::exception_ptr &e)
PWIZ_API_DECL std::vector< CVID > cleavageAgents(const Enzymes &enzymes)
returns a list of cleavage agent CVIDs for an identdata::Enzymes instance
MS_V8_DE
V8-DE: Cleavage agent V8-DE.
represents a peptide or polypeptide (a sequence of amino acids)
MS_Lys_C_P
Lys-C/P: Proteinase Lys-C/P.
std::string NTerminusPrefix() const
returns residue preceding digestion site
SemiSpecific
neither termini must match digestion motif(s)
#define unit_assert_operator_equal(expected, actual)
MS_no_cleavage
no cleavage: No cleavage.
size_t missedCleavages() const
returns the number of missed cleavage sites in the peptide
std::vector< DigestedPeptide > find_all(const Peptide &peptide) const
returns all instances of the given peptide in the polypeptide under digestion; note: the filters set ...
MS_Trypsin_P
Trypsin/P: Cleavage agent Trypsin/P.
void testNontrypticBSA(const Digestion &nontrypticDigestion)
MS_Lys_C
Lys-C: Endoproteinase Lys-C.
DigestedPeptide find_first(const Peptide &peptide, size_t offsetHint=0) const
returns the first instance of the given peptide in the polypeptide under digestion; if offsetHint is ...
const_iterator end() const
size_t specificTermini() const
returns the number of termini that matched to the digestion rules
void testSemitrypticMethionineClippingBSA(const Digestion &semitrypticDigestion)
boost::exception_ptr exception
MS_ion_trap
ion trap: A device for spatially confining ions using electric and magnetic fields alone or in combin...
MS_Formic_acid
Formic_acid: Formic acid.
#define TEST_PROLOG(argc, argv)
int main(int argc, char *argv[])
MS_glutamyl_endopeptidase
glutamyl endopeptidase: Enzyme glutamyl endopeptidase (EC 3.4.21.19).
enumerates the peptides from proteolytic digestion of a polypeptide or protein;
std::string CTerminusSuffix() const
returns residue following digestion site
const_iterator begin() const
peptide subclass that contains extra metadata provided by digestion
MS_unspecific_cleavage
unspecific cleavage: Unspecific cleavage.
MS_NoEnzyme_OBSOLETE
NoEnzyme:
MS_Chymotrypsin
Chymotrypsin: Enzyme chymotrypsin.
void testThreadSafetyWorker(boost::barrier *testBarrier, ThreadStatus &status)
const std::string & sequence() const
returns the sequence of amino acids making up the peptide
MS_PepsinA
PepsinA: PepsinA proteinase.