ProteoWizard
Functions
ProteomeDataTest.cpp File Reference
#include "ProteomeData.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

void testProteinListSimple ()
int main (int argc, const char *argv[])

Function Documentation

void testProteinListSimple ( )

Definition at line 31 of file ProteomeDataTest.cpp.

References pwiz::proteome::ProteinList::find(), pwiz::proteome::ProteinList::findKeyword(), pwiz::proteome::ProteinList::protein(), pwiz::proteome::ProteomeData::proteinListPtr, pwiz::proteome::ProteinList::size(), and unit_assert.

Referenced by main().

{
// fill in ProteinListSimple
shared_ptr<ProteinListSimple> proteinListSimple(new ProteinListSimple);
unit_assert(proteinListSimple->empty());
Protein emptyProtein("", 0, "", "");
unit_assert(emptyProtein.empty());
ProteinPtr protein0(new Protein("IPI-1701", 0, "The final frontier!", ""));
ProteinPtr protein1(new Protein("SPROT|42", 1, "Life, the universe, and everything.", ""));
unit_assert(!protein0->empty());
proteinListSimple->proteins.push_back(protein0);
proteinListSimple->proteins.push_back(protein1);
// let a ProteomeData object hold onto it as a ProteinListPtr
data.proteinListPtr = proteinListSimple;
// test ProteinList interface
// verify index()
const ProteinList& proteinList = *data.proteinListPtr;
unit_assert(proteinList.size() == 2);
unit_assert(proteinList.find("IPI-1701") == 0);
unit_assert(proteinList.find("SPROT|42") == 1);
// verify findKeyword
IndexList result = proteinList.findKeyword("final");
unit_assert(result.size()==1 && result[0]==0);
result = proteinList.findKeyword("the", false);
unit_assert(result.size()==2 && result[0]==0 && result[1]==1);
result = proteinList.findKeyword("the");
unit_assert(result.size()==1 && result[0]==1);
result = proteinList.findKeyword("42");
unit_assert(result.empty());
// verify protein 0
ProteinPtr protein = proteinList.protein(0);
unit_assert(protein->index == protein0->index);
unit_assert(protein->id == protein0->id);
// verify spectrum 1
protein = proteinList.protein(1);
unit_assert(protein->index == protein1->index);
unit_assert(protein->id == protein1->id);
}
int main ( int  argc,
const char *  argv[] 
)

Definition at line 88 of file ProteomeDataTest.cpp.

References e(), TEST_EPILOG, TEST_FAILED, TEST_PROLOG, and testProteinListSimple().

{
TEST_PROLOG(argc, argv)
try
{
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}