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, char *argv[])
 

Function Documentation

§ testProteinListSimple()

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().

32 {
33  // fill in ProteinListSimple
34 
35  shared_ptr<ProteinListSimple> proteinListSimple(new ProteinListSimple);
36 
37  unit_assert(proteinListSimple->empty());
38 
39  Protein emptyProtein("", 0, "", "");
40  unit_assert(emptyProtein.empty());
41 
42  ProteinPtr protein0(new Protein("IPI-1701", 0, "The final frontier!", ""));
43  ProteinPtr protein1(new Protein("SPROT|42", 1, "Life, the universe, and everything.", ""));
44 
45  unit_assert(!protein0->empty());
46 
47  proteinListSimple->proteins.push_back(protein0);
48  proteinListSimple->proteins.push_back(protein1);
49 
50  // let a ProteomeData object hold onto it as a ProteinListPtr
51 
52  ProteomeData data;
53  data.proteinListPtr = proteinListSimple;
54 
55  // test ProteinList interface
56 
57  // verify index()
58  const ProteinList& proteinList = *data.proteinListPtr;
59  unit_assert(proteinList.size() == 2);
60  unit_assert(proteinList.find("IPI-1701") == 0);
61  unit_assert(proteinList.find("SPROT|42") == 1);
62 
63  // verify findKeyword
64  IndexList result = proteinList.findKeyword("final");
65  unit_assert(result.size()==1 && result[0]==0);
66 
67  result = proteinList.findKeyword("the", false);
68  unit_assert(result.size()==2 && result[0]==0 && result[1]==1);
69 
70  result = proteinList.findKeyword("the");
71  unit_assert(result.size()==1 && result[0]==1);
72 
73  result = proteinList.findKeyword("42");
74  unit_assert(result.empty());
75 
76  // verify protein 0
77  ProteinPtr protein = proteinList.protein(0);
78  unit_assert(protein->index == protein0->index);
79  unit_assert(protein->id == protein0->id);
80 
81  // verify spectrum 1
82  protein = proteinList.protein(1);
83  unit_assert(protein->index == protein1->index);
84  unit_assert(protein->id == protein1->id);
85 }
virtual IndexList findKeyword(const std::string &keyword, bool caseSensitive=true) const
virtual size_t size() const =0
boost::shared_ptr< Protein > ProteinPtr
virtual size_t find(const std::string &id) const
#define unit_assert(x)
Definition: unit.hpp:85
virtual ProteinPtr protein(size_t index, bool getSequence=true) const =0

§ main()

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

Definition at line 88 of file ProteomeDataTest.cpp.

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

89 {
90  TEST_PROLOG(argc, argv)
91 
92  try
93  {
95  }
96  catch (exception& e)
97  {
98  TEST_FAILED(e.what())
99  }
100  catch (...)
101  {
102  TEST_FAILED("Caught unknown exception.")
103  }
104 
106 }
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
void testProteinListSimple()