ProteoWizard
Classes | Functions | Variables
DigestionTest.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "Peptide.hpp"
#include "Digestion.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include "boost/thread/thread.hpp"
#include "boost/thread/barrier.hpp"
#include "boost/exception/all.hpp"
#include "boost/foreach_field.hpp"

Go to the source code of this file.

Classes

struct  DigestedPeptideLessThan
 
struct  ThreadStatus
 

Functions

void testCleavageAgents ()
 
bool testDigestionMetadata (const DigestedPeptide &peptide, const string &expectedSequence, size_t expectedOffset, size_t expectedMissedCleavages, size_t expectedSpecificTermini, const string &expectedPrefix, const string &expectedSuffix)
 
void testTrypticBSA (const Digestion &trypticDigestion)
 
void testSemitrypticBSA (const Digestion &semitrypticDigestion)
 
void testNontrypticBSA (const Digestion &nontrypticDigestion)
 
void testSemitrypticMethionineClippingBSA (const Digestion &semitrypticDigestion)
 
void testBSADigestion ()
 
void testDigestionCriteria ()
 
void testFind ()
 
void testThreadSafetyWorker (boost::barrier *testBarrier, ThreadStatus &status)
 
void testThreadSafety (const int &testThreadCount)
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ testCleavageAgents()

void testCleavageAgents ( )

Definition at line 43 of file DigestionTest.cpp.

44{
46 const vector<string>& cleavageAgentNames = Digestion::getCleavageAgentNames();
47
48 if (os_)
49 {
50 *os_ << "Cleavage agents:" << endl;
51 BOOST_FOREACH(CVID agentCvid, cleavageAgents)
52 {
53 *os_ << cvTermInfo(agentCvid).name << " ("
55 << ")" << endl;
56 }
57
58 *os_ << "\nCleavage agent names" << endl;
59 BOOST_FOREACH(string agentName, cleavageAgentNames)
60 {
61 *os_ << agentName << endl;
62 }
63 }
64
65 unit_assert(cleavageAgents.size() >= 14);
70
79
84
99
103
109 unit_assert_operator_equal("(?<![JIL])(?=[BNDK])", Digestion::disambiguateCleavageAgentRegex("(?<![J])(?=[BK])"));
110}
ostream * os_
static CVID getCleavageAgentByRegex(const std::string &agentRegex)
returns the cvid of the specified cleavage agent looking it up by the Perl regular expression,...
static CVID getCleavageAgentByName(const std::string &agentName)
returns the cvid of the specified cleavage agent using a case-insensitive search, or CVID_Unknown if ...
static const std::set< CVID > & getCleavageAgents()
returns the set of predefined cleavage agents defined in the PSI-MS CV
static const std::vector< std::string > & getCleavageAgentNames()
returns the names of the set of predefined cleavage agents defined in the PSI-MS CV
static std::string disambiguateCleavageAgentRegex(const std::string &cleavageAgentRegex)
returns a modified version of a cleavage agent regex where any ambiguous AA symbols (BJXZ) are augmen...
static const std::string & getCleavageAgentRegex(CVID agentCvid)
returns the official PSI Perl regular expression defining the places in a polypeptide or protein that...
MS_glutamyl_endopeptidase
glutamyl endopeptidase: Enzyme glutamyl endopeptidase (EC 3.4.21.19).
Definition cv.hpp:6165
MS_Trypsin
Trypsin: Enzyme trypsin.
Definition cv.hpp:4179
MS_Trypsin_P
Trypsin/P: Cleavage agent Trypsin/P.
Definition cv.hpp:4350
MS_no_cleavage
no cleavage: No cleavage.
Definition cv.hpp:6288
MS_CNBr
CNBr: Cyanogen bromide.
Definition cv.hpp:4329
MS_unspecific_cleavage
unspecific cleavage: Unspecific cleavage.
Definition cv.hpp:6291
MS_V8_DE
V8-DE: Cleavage agent V8-DE.
Definition cv.hpp:4353
MS_NoEnzyme_OBSOLETE
NoEnzyme:
Definition cv.hpp:3732
CVID_Unknown
Definition cv.hpp:114
MS_V8_E
V8-E: Cleavage agent V8-E.
Definition cv.hpp:4356
MS_TrypChymo
TrypChymo: Cleavage agent TrypChymo.
Definition cv.hpp:4347
MS_Asp_N
Asp-N: Endoproteinase Asp-N.
Definition cv.hpp:4320
MS_Arg_C
Arg-C: Endoproteinase Arg-C.
Definition cv.hpp:4311
MS_Glu_C
Glu-C (glutamyl endopeptidase): Enzyme glutamyl endopeptidase (EC 3.4.21.19).
Definition cv.hpp:6171
MS_ion_trap
ion trap: A device for spatially confining ions using electric and magnetic fields alone or in combin...
Definition cv.hpp:1278
MS_PepsinA
PepsinA: PepsinA proteinase.
Definition cv.hpp:4344
MS_Formic_acid
Formic_acid: Formic acid.
Definition cv.hpp:4332
MS_Chymotrypsin
Chymotrypsin: Enzyme chymotrypsin.
Definition cv.hpp:4326
MS_Lys_C
Lys-C: Endoproteinase Lys-C.
Definition cv.hpp:4335
MS_Asp_N_ambic
Asp-N_ambic: Enzyme Asp-N, Ammonium Bicarbonate (AmBic).
Definition cv.hpp:4323
MS_Lys_C_P
Lys-C/P: Proteinase Lys-C/P.
Definition cv.hpp:4341
PWIZ_API_DECL const CVTermInfo & cvTermInfo(CVID cvid)
returns CV term info for the specified CVID
PWIZ_API_DECL std::vector< CVID > cleavageAgents(const Enzymes &enzymes)
returns a list of cleavage agent CVIDs for an identdata::Enzymes instance
std::string name
Definition cv.hpp:14947
#define unit_assert(x)
Definition unit.hpp:85
#define unit_assert_throws(x, exception)
Definition unit.hpp:106
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92

References CVID_Unknown, pwiz::cv::cvTermInfo(), pwiz::proteome::Digestion::disambiguateCleavageAgentRegex(), pwiz::proteome::Digestion::getCleavageAgentByName(), pwiz::proteome::Digestion::getCleavageAgentByRegex(), pwiz::proteome::Digestion::getCleavageAgentNames(), pwiz::proteome::Digestion::getCleavageAgentRegex(), pwiz::proteome::Digestion::getCleavageAgents(), MS_Arg_C, MS_Asp_N, MS_Asp_N_ambic, MS_Chymotrypsin, MS_CNBr, MS_Formic_acid, MS_Glu_C, MS_glutamyl_endopeptidase, MS_ion_trap, MS_Lys_C, MS_Lys_C_P, MS_no_cleavage, MS_NoEnzyme_OBSOLETE, MS_PepsinA, MS_TrypChymo, MS_Trypsin, MS_Trypsin_P, MS_unspecific_cleavage, MS_V8_DE, MS_V8_E, pwiz::cv::CVTermInfo::name, os_, unit_assert, unit_assert_operator_equal, and unit_assert_throws.

Referenced by testThreadSafetyWorker().

◆ testDigestionMetadata()

bool testDigestionMetadata ( const DigestedPeptide peptide,
const string &  expectedSequence,
size_t  expectedOffset,
size_t  expectedMissedCleavages,
size_t  expectedSpecificTermini,
const string &  expectedPrefix,
const string &  expectedSuffix 
)

Definition at line 121 of file DigestionTest.cpp.

128{
129 try
130 {
131 unit_assert_operator_equal(expectedSequence, peptide.sequence());
132 unit_assert_operator_equal(expectedOffset, peptide.offset());
133 unit_assert_operator_equal(expectedMissedCleavages, peptide.missedCleavages());
134 unit_assert_operator_equal(expectedSpecificTermini, peptide.specificTermini());
135 unit_assert_operator_equal(expectedPrefix, peptide.NTerminusPrefix());
136 unit_assert_operator_equal(expectedSuffix, peptide.CTerminusSuffix());
137 return true;
138 }
139 catch(exception& e)
140 {
141 cerr << "Testing peptide " << peptide.sequence() << ": " << e.what() << endl;
142 return false;
143 }
144}
const std::string & sequence() const
returns the sequence of amino acids making up the peptide
PWIZ_API_DECL proteome::Peptide peptide(const Peptide &peptide)
creates a proteome::Peptide from an identdata::Peptide

References pwiz::proteome::Peptide::sequence(), and unit_assert_operator_equal.

Referenced by testFind(), and testTrypticBSA().

◆ testTrypticBSA()

void testTrypticBSA ( const Digestion trypticDigestion)

Definition at line 146 of file DigestionTest.cpp.

147{
148 if (os_) *os_ << "Fully-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
149
150 vector<DigestedPeptide> trypticPeptides(trypticDigestion.begin(), trypticDigestion.end());
151 set<DigestedPeptide, DigestedPeptideLessThan> trypticPeptideSet(trypticPeptides.begin(), trypticPeptides.end());
152
153 if (os_)
154 {
155 BOOST_FOREACH(const DigestedPeptide& peptide, trypticPeptides)
156 {
157 *os_ << peptide.offset() << "\t" << peptide.missedCleavages() << "\t" <<
158 peptide.specificTermini() << "\t" << peptide.sequence().length() <<
159 "\t" << peptide.sequence() << "\n";
160 }
161 }
162
163 // test count
164 unit_assert(trypticPeptides.size() > 4);
165
166 // test order of enumeration and metadata: sequence, Off, NMC, NTT, Pre, Suf
167 unit_assert(testDigestionMetadata(trypticPeptides[0], "MKWVTFISLLLLFSSAYSR", 0, 1, 2, "", "G"));
168 unit_assert(testDigestionMetadata(trypticPeptides[1], "MKWVTFISLLLLFSSAYSRGVFR", 0, 2, 2, "", "R"));
169 unit_assert(testDigestionMetadata(trypticPeptides[2], "MKWVTFISLLLLFSSAYSRGVFRR", 0, 3, 2, "", "D"));
170 unit_assert(testDigestionMetadata(trypticPeptides[3], "KWVTFISLLLLFSSAYSR", 1, 1, 2, "M", "G"));
171
172 // test for non-tryptic peptides
173 unit_assert(!trypticPeptideSet.count("MKWVTFISLLLL"));
174 unit_assert(!trypticPeptideSet.count("STQTALA"));
175
176 // test some middle peptides
177 unit_assert(trypticPeptideSet.count("RDTHKSEIAHRFK"));
178 unit_assert(trypticPeptideSet.count("DTHKSEIAHRFK"));
179
180 // test trypticPeptides at the C terminus
181 unit_assert(trypticPeptideSet.count("EACFAVEGPKLVVSTQTALA"));
182 unit_assert(trypticPeptides.back().sequence() == "LVVSTQTALA");
183
184 // test maximum missed cleavages
185 unit_assert(!trypticPeptideSet.count("MKWVTFISLLLLFSSAYSRGVFRRDTHK"));
186 unit_assert(!trypticPeptideSet.count("LKPDPNTLCDEFKADEKKFWGKYLYEIARR"));
187
188 // test minimum peptide length
189 unit_assert(!trypticPeptideSet.count("LR"));
190 unit_assert(!trypticPeptideSet.count("QRLR"));
191 unit_assert(trypticPeptideSet.count("VLASSARQRLR"));
192
193 // test maximum peptide length
194 unit_assert(!trypticPeptideSet.count("MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFK"));
195
196 // test methionine clipping at the N-terminus
197 unit_assert(trypticPeptideSet.count("KWVTFISLLLLFSSAYSR"));
198}
bool testDigestionMetadata(const DigestedPeptide &peptide, const string &expectedSequence, size_t expectedOffset, size_t expectedMissedCleavages, size_t expectedSpecificTermini, const string &expectedPrefix, const string &expectedSuffix)
peptide subclass that contains extra metadata provided by digestion
Definition Digestion.hpp:48
const_iterator begin() const
const_iterator end() const

References pwiz::proteome::Digestion::begin(), pwiz::proteome::Digestion::end(), os_, pwiz::proteome::Peptide::sequence(), testDigestionMetadata(), and unit_assert.

Referenced by testBSADigestion().

◆ testSemitrypticBSA()

void testSemitrypticBSA ( const Digestion semitrypticDigestion)

Definition at line 200 of file DigestionTest.cpp.

201{
202 if (os_) *os_ << "Semi-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
203
204 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
205
206 vector<DigestedPeptide> semitrypticPeptides(semitrypticDigestion.begin(), semitrypticDigestion.end());
207 set<DigestedPeptide, DigestedPeptideLessThan> semitrypticPeptideSet(semitrypticPeptides.begin(), semitrypticPeptides.end());
208
209 if (os_)
210 {
211 BOOST_FOREACH(DigestedPeptide peptide, semitrypticPeptides)
212 {
213 *os_ << peptide.offset() << "\t" << peptide.missedCleavages() << "\t" <<
214 peptide.specificTermini() << "\t" << peptide.sequence().length() <<
215 "\t" << peptide.sequence() << "\n";
216 }
217 }
218
219 // test count
220 unit_assert(semitrypticPeptides.size() > 3);
221
222 // test order of enumeration and peptides at the N terminus
223 unit_assert_operator_equal("MKWVT", semitrypticPeptides[0].sequence());
224 unit_assert_operator_equal("MKWVTF", semitrypticPeptides[1].sequence());
225 unit_assert_operator_equal("MKWVTFI", semitrypticPeptides[2].sequence());
226
227 // test order of enumeration and peptides at the C terminus
228 unit_assert_operator_equal("QTALA", semitrypticPeptides.rbegin()->sequence());
229 unit_assert_operator_equal("TQTALA", (semitrypticPeptides.rbegin()+1)->sequence());
230 unit_assert_operator_equal("STQTALA", (semitrypticPeptides.rbegin()+2)->sequence());
231 unit_assert_operator_equal("LVVSTQTALA", (semitrypticPeptides.rbegin()+5)->sequence());
232 unit_assert_operator_equal("LVVSTQTAL", (semitrypticPeptides.rbegin()+6)->sequence());
233 unit_assert_operator_equal("LVVST", (semitrypticPeptides.rbegin()+10)->sequence());
234
235 // test digestion metadata
236 unit_assert_operator_equal(0, semitrypticPeptides[0].offset());
237 unit_assert_operator_equal(1, semitrypticPeptides[0].missedCleavages());
238 unit_assert_operator_equal(1, semitrypticPeptides[0].specificTermini());
239 unit_assert(semitrypticPeptides[0].NTerminusIsSpecific() &&
240 !semitrypticPeptides[0].CTerminusIsSpecific());
241
242 peptideItr = semitrypticPeptideSet.find("MKWVTFISLLLLFSSAYSR");
243 unit_assert(peptideItr != semitrypticPeptideSet.end());
244 unit_assert_operator_equal(0, peptideItr->offset());
245 unit_assert_operator_equal(1, peptideItr->missedCleavages());
246 unit_assert_operator_equal(2, peptideItr->specificTermini());
247 unit_assert(peptideItr->NTerminusIsSpecific() &&
248 peptideItr->CTerminusIsSpecific());
249
250 peptideItr = semitrypticPeptideSet.find("KWVTFISLLLLFSSAYSR");
251 unit_assert(peptideItr != semitrypticPeptideSet.end());
252 unit_assert_operator_equal(1, peptideItr->offset());
253 unit_assert_operator_equal(1, peptideItr->missedCleavages());
254 unit_assert_operator_equal(2, peptideItr->specificTermini());
255 unit_assert(peptideItr->NTerminusIsSpecific() &&
256 peptideItr->CTerminusIsSpecific());
257
258 peptideItr = semitrypticPeptideSet.find("KWVTFISLLLLFSSAYSRG"); // 2 missed cleavages
259 unit_assert(peptideItr == semitrypticPeptideSet.end());
260
261 peptideItr = semitrypticPeptideSet.find("WVTFISLLLLFSSAYSR");
262 unit_assert(peptideItr != semitrypticPeptideSet.end());
263 unit_assert_operator_equal(2, peptideItr->offset());
264 unit_assert_operator_equal(0, peptideItr->missedCleavages());
265 unit_assert_operator_equal(2, peptideItr->specificTermini());
266 unit_assert(peptideItr->NTerminusIsSpecific() &&
267 peptideItr->CTerminusIsSpecific());
268
269 peptideItr = semitrypticPeptideSet.find("WVTFISLLLLFSSAYSRG");
270 unit_assert(peptideItr != semitrypticPeptideSet.end());
271 unit_assert_operator_equal(2, peptideItr->offset());
272 unit_assert_operator_equal(1, peptideItr->missedCleavages());
273 unit_assert_operator_equal(1, peptideItr->specificTermini());
274 unit_assert(peptideItr->NTerminusIsSpecific() &&
275 !peptideItr->CTerminusIsSpecific());
276
277 peptideItr = semitrypticPeptideSet.find("VTFISLLLLFSSAYSRG"); // non-tryptic
278 unit_assert(peptideItr == semitrypticPeptideSet.end());
279
280 // test for non-specific peptides
281 unit_assert(semitrypticPeptideSet.count("WVTFISLLLLFSSAYSR")); // tryptic
282 unit_assert(semitrypticPeptideSet.count("VTFISLLLLFSSAYSR")); // semi-tryptic
283 unit_assert(!semitrypticPeptideSet.count("VTFISLLLLFSSAYS")); // non-tryptic
284
285 // test semi-specific peptides at the C terminus
286 unit_assert(semitrypticPeptideSet.count("FAVEGPKLVVSTQTALA")); // semi-tryptic
287 unit_assert(!semitrypticPeptideSet.count("FAVEGPKLVVSTQTAL")); // non-tryptic
288}

References pwiz::proteome::Digestion::begin(), pwiz::proteome::Digestion::end(), os_, pwiz::proteome::Peptide::sequence(), unit_assert, and unit_assert_operator_equal.

Referenced by testBSADigestion().

◆ testNontrypticBSA()

void testNontrypticBSA ( const Digestion nontrypticDigestion)

Definition at line 290 of file DigestionTest.cpp.

291{
292 if (os_) *os_ << "Non-specific BSA digest (offset, missed cleavages, specific termini, length, sequence)" << endl;
293
294 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
295
296 vector<DigestedPeptide> nontrypticPeptides(nontrypticDigestion.begin(), nontrypticDigestion.end());
297 set<DigestedPeptide, DigestedPeptideLessThan> nontrypticPeptideSet(nontrypticPeptides.begin(), nontrypticPeptides.end());
298
299 if (os_)
300 {
301 BOOST_FOREACH(DigestedPeptide peptide, nontrypticPeptides)
302 {
303 *os_ << peptide.offset() << "\t" << peptide.missedCleavages() << "\t" <<
304 peptide.specificTermini() << "\t" << peptide.sequence().length() <<
305 "\t" << peptide.sequence() << "\n";
306 }
307 }
308
309 // test count
310 unit_assert(nontrypticPeptides.size() > 3);
311
312 // test order of enumeration and peptides at the N terminus
313 unit_assert_operator_equal("MKWVT", nontrypticPeptides[0].sequence());
314 unit_assert_operator_equal("MKWVTF", nontrypticPeptides[1].sequence());
315 unit_assert_operator_equal("MKWVTFI", nontrypticPeptides[2].sequence());
316
317 // test digestion metadata
318 unit_assert_operator_equal(0, nontrypticPeptides[0].offset());
319 unit_assert_operator_equal(1, nontrypticPeptides[0].missedCleavages());
320 unit_assert_operator_equal(1, nontrypticPeptides[0].specificTermini());
321 unit_assert(nontrypticPeptides[0].NTerminusIsSpecific() &&
322 !nontrypticPeptides[0].CTerminusIsSpecific());
323
324 peptideItr = nontrypticPeptideSet.find("MKWVTFISLLLLFSSAYSR");
325 unit_assert(peptideItr != nontrypticPeptideSet.end());
326 unit_assert_operator_equal(0, peptideItr->offset());
327 unit_assert_operator_equal(1, peptideItr->missedCleavages());
328 unit_assert_operator_equal(2, peptideItr->specificTermini());
329 unit_assert(peptideItr->NTerminusIsSpecific() &&
330 peptideItr->CTerminusIsSpecific());
331
332 peptideItr = nontrypticPeptideSet.find("KWVTFISLLLLFSSAYSR");
333 unit_assert(peptideItr != nontrypticPeptideSet.end());
334 unit_assert_operator_equal(1, peptideItr->offset());
335 unit_assert_operator_equal(1, peptideItr->missedCleavages());
336 unit_assert_operator_equal(2, peptideItr->specificTermini());
337 unit_assert(peptideItr->NTerminusIsSpecific() &&
338 peptideItr->CTerminusIsSpecific());
339
340 peptideItr = nontrypticPeptideSet.find("KWVTFISLLLLFSSAYSRG"); // 2 missed cleavages
341 unit_assert(peptideItr == nontrypticPeptideSet.end());
342
343 peptideItr = nontrypticPeptideSet.find("WVTFISLLLLFSSAYSR");
344 unit_assert(peptideItr != nontrypticPeptideSet.end());
345 unit_assert_operator_equal(2, peptideItr->offset());
346 unit_assert_operator_equal(0, peptideItr->missedCleavages());
347 unit_assert_operator_equal(2, peptideItr->specificTermini());
348 unit_assert(peptideItr->NTerminusIsSpecific() &&
349 peptideItr->CTerminusIsSpecific());
350
351 peptideItr = nontrypticPeptideSet.find("WVTFISLLLLFSSAYSRG");
352 unit_assert(peptideItr != nontrypticPeptideSet.end());
353 unit_assert_operator_equal(2, peptideItr->offset());
354 unit_assert_operator_equal(1, peptideItr->missedCleavages());
355 unit_assert_operator_equal(1, peptideItr->specificTermini());
356 unit_assert(peptideItr->NTerminusIsSpecific() &&
357 !peptideItr->CTerminusIsSpecific());
358
359 peptideItr = nontrypticPeptideSet.find("VTFISLLLLFSSAYSRG");
360 unit_assert(peptideItr != nontrypticPeptideSet.end());
361 unit_assert_operator_equal(3, peptideItr->offset());
362 unit_assert_operator_equal(1, peptideItr->missedCleavages());
363 unit_assert_operator_equal(0, peptideItr->specificTermini());
364 unit_assert(!peptideItr->NTerminusIsSpecific() &&
365 !peptideItr->CTerminusIsSpecific());
366
367 // test for peptides of all specificities
368 unit_assert(nontrypticPeptideSet.count("WVTFISLLLLFSSAYSR")); // tryptic
369 unit_assert(nontrypticPeptideSet.count("VTFISLLLLFSSAYSR")); // semi-tryptic
370 unit_assert(nontrypticPeptideSet.count("VTFISLLLLFSSAYS")); // non-tryptic
371
372 // test non-specific peptides at the C terminus
373 unit_assert(nontrypticPeptideSet.count("FAVEGPKLVVSTQTALA")); // semi-tryptic
374 unit_assert(nontrypticPeptideSet.count("FAVEGPKLVVSTQTAL")); // non-tryptic
375 unit_assert_operator_equal("QTALA", nontrypticPeptides.back().sequence()); // semi-tryptic
376
377 // test maximum missed cleavages
378 unit_assert(nontrypticPeptideSet.count("KWVTFISLLLLFSSAYSR"));
379 unit_assert(!nontrypticPeptideSet.count("KWVTFISLLLLFSSAYSRG"));
380
381 // test minimum peptide length
382 unit_assert(!nontrypticPeptideSet.count("LR"));
383 unit_assert(!nontrypticPeptideSet.count("QRLR"));
384 unit_assert(nontrypticPeptideSet.count("VLASSAR"));
385
386 // test maximum peptide length
387 unit_assert(!nontrypticPeptideSet.count("EYEATLEECCAKDDPHACYSTVFDK"));
388}

References pwiz::proteome::Digestion::begin(), pwiz::proteome::Digestion::end(), os_, pwiz::proteome::Peptide::sequence(), unit_assert, and unit_assert_operator_equal.

Referenced by testBSADigestion().

◆ testSemitrypticMethionineClippingBSA()

void testSemitrypticMethionineClippingBSA ( const Digestion semitrypticDigestion)

Definition at line 390 of file DigestionTest.cpp.

391{
392 if (os_) *os_ << "Semi-specific BSA digest w/ methionine clipping (offset, missed cleavages, specific termini, length, sequence)" << endl;
393
394 set<DigestedPeptide, DigestedPeptideLessThan>::const_iterator peptideItr;
395
396 vector<DigestedPeptide> semitrypticPeptides(semitrypticDigestion.begin(), semitrypticDigestion.end());
397 set<DigestedPeptide, DigestedPeptideLessThan> semitrypticPeptideSet(semitrypticPeptides.begin(), semitrypticPeptides.end());
398
399 if (os_)
400 {
401 BOOST_FOREACH(DigestedPeptide peptide, semitrypticPeptides)
402 {
403 *os_ << peptide.offset() << "\t" << peptide.missedCleavages() << "\t" <<
404 peptide.specificTermini() << "\t" << peptide.sequence().length() <<
405 "\t" << peptide.sequence() << "\n";
406 }
407 }
408
409 // test count
410 unit_assert(semitrypticPeptides.size() > 3);
411
412 // test order of enumeration and peptides at the N terminus;
413 // even with methionine clipping, MKWVT contains just one missed cleavage
414 unit_assert_operator_equal("MKWVT", semitrypticPeptides[0].sequence());
415 unit_assert_operator_equal("MKWVTF", semitrypticPeptides[1].sequence());
416 unit_assert_operator_equal("MKWVTFI", semitrypticPeptides[2].sequence());
417
418 // test order of enumeration and peptides at the C terminus
419 unit_assert_operator_equal("QTALA", semitrypticPeptides.rbegin()->sequence());
420 unit_assert_operator_equal("TQTALA", (semitrypticPeptides.rbegin()+1)->sequence());
421 unit_assert_operator_equal("STQTALA", (semitrypticPeptides.rbegin()+2)->sequence());
422 unit_assert_operator_equal("LVVSTQTALA", (semitrypticPeptides.rbegin()+5)->sequence());
423 unit_assert_operator_equal("LVVSTQTAL", (semitrypticPeptides.rbegin()+6)->sequence());
424 unit_assert_operator_equal("LVVST", (semitrypticPeptides.rbegin()+10)->sequence());
425
426 // test digestion metadata ([0]: MKWVT)
427 unit_assert_operator_equal(0, semitrypticPeptides[0].offset());
428 unit_assert_operator_equal(1, semitrypticPeptides[0].missedCleavages());
429 unit_assert_operator_equal(1, semitrypticPeptides[0].specificTermini());
430 unit_assert(semitrypticPeptides[0].NTerminusIsSpecific() &&
431 !semitrypticPeptides[0].CTerminusIsSpecific());
432
433 peptideItr = semitrypticPeptideSet.find("KWVTFISLLLLFSSAYS"); // clipped methionine
434 unit_assert(peptideItr != semitrypticPeptideSet.end());
435 unit_assert_operator_equal(1, peptideItr->offset());
436 unit_assert_operator_equal(1, peptideItr->missedCleavages());
437 unit_assert_operator_equal(1, peptideItr->specificTermini());
438 unit_assert(peptideItr->NTerminusIsSpecific());
439
440 peptideItr = semitrypticPeptideSet.find("KWVTFISLLLLFSSAYSR"); // clipped methionine
441 unit_assert(peptideItr != semitrypticPeptideSet.end());
442 unit_assert_operator_equal(1, peptideItr->offset());
443 unit_assert_operator_equal(1, peptideItr->missedCleavages());
444 unit_assert_operator_equal(2, peptideItr->specificTermini());
445 unit_assert(peptideItr->NTerminusIsSpecific() &&
446 peptideItr->CTerminusIsSpecific());
447
448 peptideItr = semitrypticPeptideSet.find("KWVTFISLLLLFSSAYSRG"); // 2 missed cleavages
449 unit_assert(peptideItr == semitrypticPeptideSet.end());
450
451 peptideItr = semitrypticPeptideSet.find("WVTFISLLLLFSSAYSR");
452 unit_assert(peptideItr != semitrypticPeptideSet.end());
453 unit_assert_operator_equal(2, peptideItr->offset());
454 unit_assert_operator_equal(0, peptideItr->missedCleavages());
455 unit_assert_operator_equal(2, peptideItr->specificTermini());
456 unit_assert(peptideItr->NTerminusIsSpecific() &&
457 peptideItr->CTerminusIsSpecific());
458
459 peptideItr = semitrypticPeptideSet.find("WVTFISLLLLFSSAYSRG");
460 unit_assert(peptideItr != semitrypticPeptideSet.end());
461 unit_assert_operator_equal(2, peptideItr->offset());
462 unit_assert_operator_equal(1, peptideItr->missedCleavages());
463 unit_assert_operator_equal(1, peptideItr->specificTermini());
464 unit_assert(peptideItr->NTerminusIsSpecific() &&
465 !peptideItr->CTerminusIsSpecific());
466
467 peptideItr = semitrypticPeptideSet.find("VTFISLLLLFSSAYSRG"); // non-tryptic
468 unit_assert(peptideItr == semitrypticPeptideSet.end());
469
470 // test for non-specific peptides
471 unit_assert(semitrypticPeptideSet.count("WVTFISLLLLFSSAYSR")); // tryptic
472 unit_assert(semitrypticPeptideSet.count("KWVTFISLLLLFSSAYSR")); // semi-tryptic
473 unit_assert(semitrypticPeptideSet.count("KWVTFISLLLLFSSAYS")); // clipped methionine & semi-specific
474 unit_assert(!semitrypticPeptideSet.count("VTFISLLLLFSSAYS")); // non-specific
475
476 // test semi-specific peptides at the C terminus
477 unit_assert(semitrypticPeptideSet.count("FAVEGPKLVVSTQTALA")); // semi-tryptic
478 unit_assert(!semitrypticPeptideSet.count("FAVEGPKLVVSTQTAL")); // non-tryptic
479}

References pwiz::proteome::Digestion::begin(), pwiz::proteome::Digestion::end(), os_, pwiz::proteome::Peptide::sequence(), unit_assert, and unit_assert_operator_equal.

Referenced by testBSADigestion().

◆ testBSADigestion()

void testBSADigestion ( )

Definition at line 481 of file DigestionTest.cpp.

482{
483 if (os_) *os_ << "BSA digestion test" << endl;
484
485 // >P02769|ALBU_BOVIN Serum albumin - Bos taurus (Bovine).
486 Peptide bsa("MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQQCPF"
487 "DEHVKLVNELTEFAKTCVADESHAGCEKSLHTLFGDELCKVASLRETYGDMADCCEKQEP"
488 "ERNECFLSHKDDSPDLPKLKPDPNTLCDEFKADEKKFWGKYLYEIARRHPYFYAPELLYY"
489 "ANKYNGVFQECCQAEDKGACLLPKIETMREKVLASSARQRLRCASIQKFGERALKAWSVA"
490 "RLSQKFPKAEFVEVTKLVTDLTKVHKECCHGDLLECADDRADLAKYICDNQDTISSKLKE"
491 "CCDKPLLEKSHCIAEVEKDAIPENLPPLTADFAEDKDVCKNYQEAKDAFLGSFLYEYSRR"
492 "HPEYAVSVLLRLAKEYEATLEECCAKDDPHACYSTVFDKLKHLVDEPQNLIKQNCDQFEK"
493 "LGEYGFQNALIVRYTRKVPQVSTPTLVEVSRSLGKVGTRCCTKPESERMPCTEDYLSLIL"
494 "NRLCVLHEKTPVSEKVTKCCTESLVNRRPCFSALTPDETYVPKAFDEKLFTFHADICTLP"
495 "DTEKQIKKQTALVELLKHKPKATEEQLKTVMENFVAFVDKCCAADDKEACFAVEGPKLVV"
496 "STQTALA");
497
498 // test fully-specific trypsin digest
500 testTrypticBSA(Digestion(bsa, "(?<=[KR])", Digestion::Config(3, 5, 40)));
501
502 // test semi-specific trypsin digest
503 testSemitrypticBSA(Digestion(bsa, MS_Trypsin_P, Digestion::Config(1, 5, 20, Digestion::SemiSpecific)));
504 testSemitrypticBSA(Digestion(bsa, "(?<=[KR])", Digestion::Config(1, 5, 20, Digestion::SemiSpecific)));
505
506 // test non-specific trypsin digest
507 testNontrypticBSA(Digestion(bsa, MS_Trypsin_P, Digestion::Config(1, 5, 20, Digestion::NonSpecific)));
508 testNontrypticBSA(Digestion(bsa, "(?<=[KR])", Digestion::Config(1, 5, 20, Digestion::NonSpecific)));
509
510 // test semi-specific trypsin digest with n-terminal methionine clipping (motif and regex only)
511 testSemitrypticMethionineClippingBSA(Digestion(bsa, "(?<=^M)|(?<=[KR])", Digestion::Config(1, 5, 20, Digestion::SemiSpecific)));
512 testSemitrypticMethionineClippingBSA(Digestion(bsa, "(?<=(^M)|([KR]))", Digestion::Config(1, 5, 20, Digestion::SemiSpecific)));
513
514 // test funky digestion
515 Digestion funkyDigestion(bsa, "(?<=A[DE])(?=[FG])", Digestion::Config(0, 5, 100000, Digestion::FullySpecific, false));
516 vector<Peptide> funkyPeptides(funkyDigestion.begin(), funkyDigestion.end());
517
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());
521
522 // test fully specific Asp-N digest (thus testing ambiguous residue disambiguation)
523 Digestion aspnDigestion(bsa, MS_Asp_N, Digestion::Config(0, 5, 100000, Digestion::FullySpecific, false));
524 vector<Peptide> aspnPeptides(aspnDigestion.begin(), aspnDigestion.end());
525 unit_assert_operator_equal("MKWVTFISLLLLFSSAYSRGVFRR", aspnPeptides[0].sequence());
526 unit_assert_operator_equal("DTHKSEIAHRFK", aspnPeptides[1].sequence());
527 unit_assert_operator_equal("DLGEEHFKGLVLIAFSQYLQQCPF", aspnPeptides[2].sequence());
528 unit_assert_operator_equal("DEHVKLV", aspnPeptides[3].sequence());
529 unit_assert_operator_equal("NELTEFAKTCVA", aspnPeptides[4].sequence());
530
531 // test no cleavage "digestion"
532 Digestion noCleavageDigestion("ELVISLIVESK", MS_no_cleavage);
533 vector<Peptide> noCleavagePeptides(noCleavageDigestion.begin(), noCleavageDigestion.end());
534
535 unit_assert_operator_equal(1, noCleavagePeptides.size());
536 unit_assert_operator_equal("ELVISLIVESK", noCleavagePeptides[0].sequence());
537
538 // test unspecific cleavage digestion
539 Digestion unspecificCleavageDigestion("ELVISLK", MS_unspecific_cleavage, Digestion::Config(0, 5, 5, Digestion::FullySpecific, false));
540 vector<Peptide> unspecificCleavagePeptides(unspecificCleavageDigestion.begin(), unspecificCleavageDigestion.end());
541
542 unit_assert_operator_equal(3, unspecificCleavagePeptides.size());
543 unit_assert_operator_equal("ELVIS", unspecificCleavagePeptides[0].sequence());
544 unit_assert_operator_equal("LVISL", unspecificCleavagePeptides[1].sequence());
545 unit_assert_operator_equal("VISLK", unspecificCleavagePeptides[2].sequence());
546}
void testNontrypticBSA(const Digestion &nontrypticDigestion)
void testTrypticBSA(const Digestion &trypticDigestion)
void testSemitrypticBSA(const Digestion &semitrypticDigestion)
void testSemitrypticMethionineClippingBSA(const Digestion &semitrypticDigestion)
enumerates the peptides from proteolytic digestion of a polypeptide or protein;
represents a peptide or polypeptide (a sequence of amino acids)
Definition Peptide.hpp:62
sets constraints for valid peptides produced by iterating the digestion

References pwiz::proteome::Digestion::begin(), pwiz::proteome::Digestion::end(), MS_Asp_N, MS_no_cleavage, MS_Trypsin_P, MS_unspecific_cleavage, os_, testNontrypticBSA(), testSemitrypticBSA(), testSemitrypticMethionineClippingBSA(), testTrypticBSA(), and unit_assert_operator_equal.

Referenced by testThreadSafetyWorker().

◆ testDigestionCriteria()

void testDigestionCriteria ( )

Definition at line 548 of file DigestionTest.cpp.

549{
550 // >P02769|ALBU_BOVIN Serum albumin - Bos taurus (Bovine).
551 Peptide bsa("MKWVTFISLLLLFSSAYSRGVFRRDTHKSEIAHRFKDLGEEHFKGLVLIAFSQYLQQCPF"
552 "DEHVKLVNELTEFAKTCVADESHAGCEKSLHTLFGDELCKVASLRETYGDMADCCEKQEP"
553 "ERNECFLSHKDDSPDLPKLKPDPNTLCDEFKADEKKFWGKYLYEIARRHPYFYAPELLYY"
554 "ANKYNGVFQECCQAEDKGACLLPKIETMREKVLASSARQRLRCASIQKFGERALKAWSVA"
555 "RLSQKFPKAEFVEVTKLVTDLTKVHKECCHGDLLECADDRADLAKYICDNQDTISSKLKE"
556 "CCDKPLLEKSHCIAEVEKDAIPENLPPLTADFAEDKDVCKNYQEAKDAFLGSFLYEYSRR"
557 "HPEYAVSVLLRLAKEYEATLEECCAKDDPHACYSTVFDKLKHLVDEPQNLIKQNCDQFEK"
558 "LGEYGFQNALIVRYTRKVPQVSTPTLVEVSRSLGKVGTRCCTKPESERMPCTEDYLSLIL"
559 "NRLCVLHEKTPVSEKVTKCCTESLVNRRPCFSALTPDETYVPKAFDEKLFTFHADICTLP"
560 "DTEKQIKKQTALVELLKHKPKATEEQLKTVMENFVAFVDKCCAADDKEACFAVEGPKLVV"
561 "STQTALA");
562
563 for (const DigestedPeptide& peptide : Digestion(bsa, MS_Trypsin_P, Digestion::Config(3, 5, 40)))
564 {
565 unit_assert(peptide.missedCleavages() <= 3);
566 unit_assert(peptide.sequence().length() >= 5);
567 unit_assert(peptide.sequence().length() <= 40);
568 }
569
570 for (const DigestedPeptide& peptide : Digestion(bsa, MS_Trypsin_P, Digestion::Config(0, 3, 10)))
571 {
572 unit_assert(peptide.missedCleavages() <= 0);
573 unit_assert(peptide.sequence().length() >= 3);
574 unit_assert(peptide.sequence().length() <= 10);
575 }
576
577 for (const DigestedPeptide& peptide : Digestion(bsa, MS_Trypsin_P, Digestion::Config(10, 25, 100)))
578 {
579 unit_assert(peptide.missedCleavages() <= 10);
580 unit_assert(peptide.sequence().length() >= 25);
581 unit_assert(peptide.sequence().length() <= 100);
582 }
583
584 unit_assert_operator_equal(0, boost::distance(Digestion(bsa, MS_Trypsin_P, Digestion::Config(10, 1000, 2000))));
585}

References MS_Trypsin_P, pwiz::proteome::Peptide::sequence(), unit_assert, and unit_assert_operator_equal.

Referenced by testThreadSafetyWorker().

◆ testFind()

void testFind ( )

Definition at line 588 of file DigestionTest.cpp.

589{
590 Digestion fully("PEPKTIDEKPEPTIDERPEPKTIDEKKKPEPTIDER", MS_Lys_C_P, Digestion::Config(2, 5, 10));
591 Digestion semi("PEPKTIDEKPEPTIDERPEPKTIDEKKKPEPTIDER", MS_Lys_C_P, Digestion::Config(2, 5, 10, Digestion::SemiSpecific));
592 Digestion non("PEPKTIDEKPEPTIDERPEPKTIDEKKKPEPTIDER", MS_Lys_C_P, Digestion::Config(2, 5, 10, Digestion::NonSpecific));
593 Digestion clipped("MPEPKTIDEKPEPTIDERPEPKTIDEKKKPEPTIDER", MS_Lys_C_P, Digestion::Config(2, 5, 10));
594
595 // test find_all
596 unit_assert(fully.find_all("ABC").empty()); // not in peptide
597 unit_assert(fully.find_all("PEPK").empty()); // too short
598 unit_assert(fully.find_all("PEPKTIDEKK").empty()); // no N-terminal cleavage
599 unit_assert(fully.find_all("PEPTIDERPEPK").empty()); // too long
600 unit_assert(fully.find_all("PEPTIDERPEPTIDEK").empty()); // too long
601 unit_assert(semi.find_all("PEPKTIDEKKK").empty()); // too many missed cleavages
602 unit_assert(semi.find_all("EPKTIDE").empty()); // no specific termini
603 unit_assert(non.find_all("EPKTIDEKKK").empty()); // too many missed cleavages
604
605 unit_assert(fully.find_all("PEPKTIDEK").size() == 1);
606 unit_assert(testDigestionMetadata(fully.find_all("PEPKTIDEK")[0], "PEPKTIDEK", 0, 1, 2, "", "P"));
607
608 unit_assert(fully.find_all("TIDEK").size() == 2);
609 unit_assert(testDigestionMetadata(fully.find_all("TIDEK")[0], "TIDEK", 4, 0, 2, "K", "P"));
610 unit_assert(testDigestionMetadata(fully.find_all("TIDEK")[1], "TIDEK", 21, 0, 2, "K", "K"));
611
612 unit_assert(fully.find_all("TIDEKK").size() == 1);
613 unit_assert(testDigestionMetadata(fully.find_all("TIDEKK")[0], "TIDEKK", 21, 1, 2, "K", "K"));
614
615 unit_assert(fully.find_all("TIDEKKK").size() == 1);
616 unit_assert(testDigestionMetadata(fully.find_all("TIDEKKK")[0], "TIDEKKK", 21, 2, 2, "K", "P"));
617
618 unit_assert(fully.find_all("PEPTIDER").size() == 1);
619 unit_assert(testDigestionMetadata(fully.find_all("PEPTIDER")[0], "PEPTIDER", 28, 0, 2, "K", ""));
620
621 unit_assert(semi.find_all("PEPKTIDEKK").size() == 1);
622 unit_assert(testDigestionMetadata(semi.find_all("PEPKTIDEKK")[0], "PEPKTIDEKK", 17, 2, 1, "R", "K"));
623
624 unit_assert(semi.find_all("EPKTIDEKK").size() == 1);
625 unit_assert(testDigestionMetadata(semi.find_all("EPKTIDEKK")[0], "EPKTIDEKK", 18, 2, 1, "P", "K"));
626
627 unit_assert(non.find_all("PEPKTIDE").size() == 2);
628 unit_assert(testDigestionMetadata(non.find_all("PEPKTIDE")[0], "PEPKTIDE", 0, 1, 1, "", "K"));
629 unit_assert(testDigestionMetadata(non.find_all("PEPKTIDE")[1], "PEPKTIDE", 17, 1, 0, "R", "K"));
630
631 unit_assert(fully.find_all("EPKTIDEK").empty()); // N-terminal 'P' is not clipped
632 unit_assert(clipped.find_all("PEPKTIDEK").size() == 1); // N-terminal 'M' is clipped
633 unit_assert(testDigestionMetadata(clipped.find_all("PEPKTIDEK")[0], "PEPKTIDEK", 1, 1, 2, "M", "P"));
634
635 // test find_first
636 unit_assert_throws(fully.find_first("ABC"), runtime_error); // not in peptide
637 unit_assert_throws(fully.find_first("PEPK"), runtime_error); // too short
638 unit_assert_throws(fully.find_first("PEPKTIDEKK"), runtime_error); // no N-terminal cleavage
639 unit_assert_throws(fully.find_first("PEPTIDERPEPK"), runtime_error); // too long
640 unit_assert_throws(fully.find_first("PEPTIDERPEPTIDEK"), runtime_error); // too long
641 unit_assert_throws(semi.find_first("EPKTIDE"), runtime_error); // no specific termini
642 unit_assert_throws(semi.find_first("PEPKTIDEKKK"), runtime_error); // too many missed cleavages
643 unit_assert_throws(non.find_first("PEPKTIDEKKK"), runtime_error); // too many missed cleavages
644
645 unit_assert(testDigestionMetadata(fully.find_first("PEPKTIDEK"), "PEPKTIDEK", 0, 1, 2, "", "P"));
646 unit_assert(testDigestionMetadata(fully.find_first("PEPKTIDEK", 4242), "PEPKTIDEK", 0, 1, 2, "", "P"));
647
648 unit_assert(testDigestionMetadata(fully.find_first("TIDEK"), "TIDEK", 4, 0, 2, "K", "P"));
649 unit_assert(testDigestionMetadata(fully.find_first("TIDEK", 4242), "TIDEK", 4, 0, 2, "K", "P"));
650 unit_assert(testDigestionMetadata(fully.find_first("TIDEK", 15), "TIDEK", 21, 0, 2, "K", "K"));
651 unit_assert(testDigestionMetadata(fully.find_first("TIDEK", 21), "TIDEK", 21, 0, 2, "K", "K"));
652
653 unit_assert(testDigestionMetadata(fully.find_first("TIDEKK"), "TIDEKK", 21, 1, 2, "K", "K"));
654 unit_assert(testDigestionMetadata(fully.find_first("TIDEKKK"), "TIDEKKK", 21, 2, 2, "K", "P"));
655 unit_assert(testDigestionMetadata(fully.find_first("PEPTIDER"), "PEPTIDER", 28, 0, 2, "K", ""));
656
657 unit_assert(testDigestionMetadata(semi.find_first("IDEKK"), "IDEKK", 22, 1, 1, "T", "K"));
658 unit_assert(testDigestionMetadata(semi.find_first("IDEKKK"), "IDEKKK", 22, 2, 1, "T", "P"));
659 unit_assert(testDigestionMetadata(semi.find_first("PEPTIDER"), "PEPTIDER", 9, 0, 1, "K", "P"));
660 unit_assert(testDigestionMetadata(semi.find_first("PEPTIDER", 28), "PEPTIDER", 28, 0, 2, "K", ""));
661
662 unit_assert(testDigestionMetadata(non.find_first("EPTIDE"), "EPTIDE", 10, 0, 0, "P", "R"));
663 unit_assert(testDigestionMetadata(non.find_first("EPTIDE", 29), "EPTIDE", 29, 0, 0, "P", "R"));
664}

References pwiz::proteome::Digestion::find_all(), pwiz::proteome::Digestion::find_first(), MS_Lys_C_P, testDigestionMetadata(), unit_assert, and unit_assert_throws.

Referenced by testThreadSafetyWorker().

◆ testThreadSafetyWorker()

void testThreadSafetyWorker ( boost::barrier *  testBarrier,
ThreadStatus status 
)

Definition at line 676 of file DigestionTest.cpp.

677{
678 testBarrier->wait(); // wait until all threads have started
679
680 try
681 {
685 testFind();
686 }
687 catch (exception& e)
688 {
689 status.exception = boost::copy_exception(runtime_error(e.what()));
690 }
691 catch (...)
692 {
693 status.exception = boost::copy_exception(runtime_error("Unhandled exception in worker thread."));
694 }
695}
void testFind()
void testCleavageAgents()
void testBSADigestion()
void testDigestionCriteria()
boost::exception_ptr exception

References ThreadStatus::exception, testBSADigestion(), testCleavageAgents(), testDigestionCriteria(), and testFind().

Referenced by testThreadSafety().

◆ testThreadSafety()

void testThreadSafety ( const int &  testThreadCount)

Definition at line 697 of file DigestionTest.cpp.

698{
699 using boost::thread;
700
701 boost::barrier testBarrier(testThreadCount);
702 list<pair<boost::shared_ptr<thread>, ThreadStatus> > threads;
703 for (int i=0; i < testThreadCount; ++i)
704 {
705 threads.push_back(make_pair(boost::shared_ptr<thread>(), ThreadStatus()));
706 threads.back().first.reset(new thread(testThreadSafetyWorker, &testBarrier, boost::ref(threads.back().second)));
707 }
708
709 set<boost::shared_ptr<thread> > finishedThreads;
710 while (finishedThreads.size() < threads.size())
711 BOOST_FOREACH_FIELD((boost::shared_ptr<thread>& t)(ThreadStatus& status), threads)
712 {
713 if (t->timed_join(boost::posix_time::seconds(1)))
714 finishedThreads.insert(t);
715
716 if (status.exception != NULL) // non-null exception?
717 boost::rethrow_exception(status.exception);
718 }
719}
void testThreadSafetyWorker(boost::barrier *testBarrier, ThreadStatus &status)

References ThreadStatus::exception, and testThreadSafetyWorker().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 722 of file DigestionTest.cpp.

723{
724 TEST_PROLOG(argc, argv)
725
726 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
727 if (os_) *os_ << "DigestionTest\n";
728
729 try
730 {
731 //testThreadSafety(1); // does not test thread-safety of singleton initialization
734 //testThreadSafety(8);
735 //testThreadSafety(16); // high thread count fails non-deterministically on MSVC; I haven't been able to find the cause.
736 }
737 catch (exception& e)
738 {
739 TEST_FAILED(e.what())
740 }
741 catch (...)
742 {
743 TEST_FAILED("Caught unknown exception.")
744 }
745
747}
void testThreadSafety()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, and testThreadSafety().

Variable Documentation

◆ os_

ostream* os_ = 0