ProteoWizard
Functions | Variables
ProteinList_DecoyGeneratorTest.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "ProteinList_DecoyGenerator.hpp"
#include "pwiz/data/proteome/examples.hpp"
#include "boost/random.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testReversedList (ProteinListPtr pl)
 
void testShuffledList (ProteinListPtr pl)
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

§ testReversedList()

void testReversedList ( ProteinListPtr  pl)

Definition at line 39 of file ProteinList_DecoyGeneratorTest.cpp.

References os_, and unit_assert.

Referenced by test().

40 {
41  unit_assert(pl->size() == 3);
43  unit_assert(decoyList.size() == 6);
44  for (size_t i=0; i < pl->size(); ++i)
45  {
46  ProteinPtr target = decoyList.protein(i);
47  ProteinPtr decoy = decoyList.protein(i + pl->size());
48 
49  if (os_) *os_ << target->id << " " << target->sequence() << endl;
50  if (os_) *os_ << decoy->id << " " << decoy->sequence() << endl;
51 
52  unit_assert("reversed_" + target->id == decoy->id);
53  unit_assert(decoy->description.empty());
54  unit_assert(string(target->sequence().rbegin(), target->sequence().rend()) == decoy->sequence());
55  }
56 }
creates a reversed copy of every target protein with the specified decoy string prefixed to the id ...
boost::shared_ptr< Protein > ProteinPtr
#define unit_assert(x)
Definition: unit.hpp:85
ProteinList decoy generator for creating decoy proteins on the fly.

§ testShuffledList()

void testShuffledList ( ProteinListPtr  pl)

Definition at line 59 of file ProteinList_DecoyGeneratorTest.cpp.

References os_, and unit_assert.

Referenced by test().

60 {
61  unit_assert(pl->size() == 3);
63  unit_assert(decoyList.size() == 6);
64 
65  boost::mt19937 engine(0);
66  boost::uniform_int<> distribution;
67  boost::variate_generator<boost::mt19937, boost::uniform_int<> > rng(engine, distribution);
68 
69  for (size_t i=0; i < pl->size(); ++i)
70  {
71  ProteinPtr target = decoyList.protein(i);
72  ProteinPtr decoy = decoyList.protein(i + pl->size());
73 
74  if (os_) *os_ << target->id << " " << target->sequence() << endl;
75  if (os_) *os_ << decoy->id << " " << decoy->sequence() << endl;
76 
77  unit_assert("shuffled_" + target->id == decoy->id);
78  unit_assert(decoy->description.empty());
79  string sequence = target->sequence();
80  random_shuffle(sequence.begin(), sequence.end(), rng);
81  unit_assert(sequence == decoy->sequence());
82  }
83 }
creates a randomly shuffled copy of every target protein with the specified decoy string prefixed to ...
boost::shared_ptr< Protein > ProteinPtr
#define unit_assert(x)
Definition: unit.hpp:85
ProteinList decoy generator for creating decoy proteins on the fly.

§ test()

void test ( )

Definition at line 86 of file ProteinList_DecoyGeneratorTest.cpp.

References pwiz::proteome::examples::initializeTiny(), pwiz::proteome::ProteomeData::proteinListPtr, testReversedList(), and testShuffledList().

Referenced by main().

87 {
88  ProteomeData pd;
91  testReversedList(pl);
92  testShuffledList(pl);
93 }
void testShuffledList(ProteinListPtr pl)
void testReversedList(ProteinListPtr pl)
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
boost::shared_ptr< ProteinList > ProteinListPtr

§ main()

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

Definition at line 96 of file ProteinList_DecoyGeneratorTest.cpp.

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

97 {
98  TEST_PROLOG(argc, argv)
99 
100  try
101  {
102  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
103  test();
104  }
105  catch (exception& e)
106  {
107  TEST_FAILED(e.what())
108  }
109  catch (...)
110  {
111  TEST_FAILED("Caught unknown exception.")
112  }
113 
115 }
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 36 of file ProteinList_DecoyGeneratorTest.cpp.

Referenced by main(), testReversedList(), and testShuffledList().