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

void testReversedList ( ProteinListPtr  pl)

Definition at line 39 of file ProteinList_DecoyGeneratorTest.cpp.

References os_, and unit_assert.

Referenced by test().

{
unit_assert(pl->size() == 3);
unit_assert(decoyList.size() == 6);
for (size_t i=0; i < pl->size(); ++i)
{
ProteinPtr target = decoyList.protein(i);
ProteinPtr decoy = decoyList.protein(i + pl->size());
if (os_) *os_ << target->id << " " << target->sequence() << endl;
if (os_) *os_ << decoy->id << " " << decoy->sequence() << endl;
unit_assert("reversed_" + target->id == decoy->id);
unit_assert(decoy->description.empty());
unit_assert(string(target->sequence().rbegin(), target->sequence().rend()) == decoy->sequence());
}
}
void testShuffledList ( ProteinListPtr  pl)

Definition at line 59 of file ProteinList_DecoyGeneratorTest.cpp.

References os_, and unit_assert.

Referenced by test().

{
unit_assert(pl->size() == 3);
unit_assert(decoyList.size() == 6);
boost::mt19937 engine(0);
boost::uniform_int<> distribution;
boost::variate_generator<boost::mt19937, boost::uniform_int<> > rng(engine, distribution);
for (size_t i=0; i < pl->size(); ++i)
{
ProteinPtr target = decoyList.protein(i);
ProteinPtr decoy = decoyList.protein(i + pl->size());
if (os_) *os_ << target->id << " " << target->sequence() << endl;
if (os_) *os_ << decoy->id << " " << decoy->sequence() << endl;
unit_assert("shuffled_" + target->id == decoy->id);
unit_assert(decoy->description.empty());
string sequence = target->sequence();
random_shuffle(sequence.begin(), sequence.end(), rng);
unit_assert(sequence == decoy->sequence());
}
}
void test ( )
int main ( int  argc,
char *  argv[] 
)

Definition at line 96 of file ProteinList_DecoyGeneratorTest.cpp.

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

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 36 of file ProteinList_DecoyGeneratorTest.cpp.