ProteoWizard
Classes | Functions | Variables
ProteinList_FilterTest.cpp File Reference
#include "ProteinList_Filter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/IntegerSet.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <boost/assign.hpp>

Go to the source code of this file.

Classes

struct  SelectedIndexPredicate
 

Functions

void printProteinList (const ProteinList &pl, ostream &os)
 
ProteinListPtr createProteinList ()
 
void testSelectedIndices (ProteinListPtr pl)
 
void testIndexSet (ProteinListPtr pl)
 
void testIdSet (ProteinListPtr pl)
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

§ printProteinList()

void printProteinList ( const ProteinList pl,
ostream &  os 
)

Definition at line 41 of file ProteinList_FilterTest.cpp.

References pwiz::proteome::ProteinList::protein(), and pwiz::proteome::ProteinList::size().

Referenced by createProteinList(), testIdSet(), testIndexSet(), and testSelectedIndices().

42 {
43  os << "size: " << pl.size() << endl;
44 
45  for (size_t i=0, end=pl.size(); i<end; i++)
46  {
47  ProteinPtr protein = pl.protein(i, false);
48  os << protein->index << " "
49  << protein->id << " "
50  << endl;
51  }
52 }
virtual size_t size() const =0
boost::shared_ptr< Protein > ProteinPtr
virtual ProteinPtr protein(size_t index, bool getSequence=true) const =0

§ createProteinList()

ProteinListPtr createProteinList ( )

Definition at line 55 of file ProteinList_FilterTest.cpp.

References os_, and printProteinList().

Referenced by test().

56 {
57  shared_ptr<ProteinListSimple> pl(new ProteinListSimple);
58 
59  for (size_t i=0; i<10; ++i)
60  {
61  ProteinPtr protein(new Protein("Pro" + lexical_cast<string>(i+1), i, "", string(16, 'A'+i)));
62  pl->proteins.push_back(protein);
63  }
64 
65  if (os_)
66  {
67  *os_ << "original protein list:\n";
68  printProteinList(*pl, *os_);
69  *os_ << endl;
70  }
71 
72  return pl;
73 }
ostream * os_
boost::shared_ptr< Protein > ProteinPtr
void printProteinList(const ProteinList &pl, ostream &os)

§ testSelectedIndices()

void testSelectedIndices ( ProteinListPtr  pl)

Definition at line 98 of file ProteinList_FilterTest.cpp.

References ralab::base::filter::filter(), os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

99 {
100  if (os_) *os_ << "testSelectedIndices:\n";
101 
103 
104  if (os_)
105  {
107  *os_ << endl;
108  }
109 
111  unit_assert_operator_equal("Pro2", filter.protein(0)->id);
112  unit_assert_operator_equal("Pro4", filter.protein(1)->id);
113  unit_assert_operator_equal("Pro6", filter.protein(2)->id);
114 }
ostream * os_
ProteinList filter, for creating Protein sub-lists.
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
void printProteinList(const ProteinList &pl, ostream &os)
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112

§ testIndexSet()

void testIndexSet ( ProteinListPtr  pl)

Definition at line 117 of file ProteinList_FilterTest.cpp.

References ralab::base::filter::filter(), pwiz::util::IntegerSet::insert(), os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

118 {
119  if (os_) *os_ << "testIndexSet:\n";
120 
121  IntegerSet indexSet;
122  indexSet.insert(3,5);
123  indexSet.insert(7);
124  indexSet.insert(9);
125 
127 
128  if (os_)
129  {
131  *os_ << endl;
132  }
133 
135  unit_assert_operator_equal("Pro4", filter.protein(0)->id);
136  unit_assert_operator_equal("Pro5", filter.protein(1)->id);
137  unit_assert_operator_equal("Pro6", filter.protein(2)->id);
138  unit_assert_operator_equal("Pro8", filter.protein(3)->id);
139  unit_assert_operator_equal("Pro10", filter.protein(4)->id);
140 }
ostream * os_
a virtual container of integers, accessible via an iterator interface, stored as union of intervals ...
Definition: IntegerSet.hpp:37
ProteinList filter, for creating Protein sub-lists.
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
void printProteinList(const ProteinList &pl, ostream &os)
void insert(Interval interval)
insert an interval of integers into the virtual container
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112

§ testIdSet()

void testIdSet ( ProteinListPtr  pl)

Definition at line 143 of file ProteinList_FilterTest.cpp.

References ralab::base::filter::filter(), os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

144 {
145  if (os_) *os_ << "testIdSet:\n";
146 
147  set<string> idSet;
148  idSet += "Pro2", "Pro3", "Pro4", "Pro7";
149 
151 
152  if (os_)
153  {
155  *os_ << endl;
156  }
157 
159  unit_assert_operator_equal("Pro2", filter.protein(0)->id);
160  unit_assert_operator_equal("Pro3", filter.protein(1)->id);
161  unit_assert_operator_equal("Pro4", filter.protein(2)->id);
162  unit_assert_operator_equal("Pro7", filter.protein(3)->id);
163 }
ostream * os_
ProteinList filter, for creating Protein sub-lists.
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
void printProteinList(const ProteinList &pl, ostream &os)
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112

§ test()

void test ( )

Definition at line 166 of file ProteinList_FilterTest.cpp.

References createProteinList(), testIdSet(), testIndexSet(), and testSelectedIndices().

Referenced by main().

167 {
170  testIndexSet(pl);
171  testIdSet(pl);
172 }
ProteinListPtr createProteinList()
void testIdSet(ProteinListPtr pl)
void testSelectedIndices(ProteinListPtr pl)
boost::shared_ptr< ProteinList > ProteinListPtr
void testIndexSet(ProteinListPtr pl)

§ main()

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

Definition at line 175 of file ProteinList_FilterTest.cpp.

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

176 {
177  TEST_PROLOG(argc, argv)
178 
179  try
180  {
181  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
182  test();
183  }
184  catch (exception& e)
185  {
186  TEST_FAILED(e.what())
187  }
188  catch (...)
189  {
190  TEST_FAILED("Caught unknown exception.")
191  }
192 
194 }
ostream * os_
#define TEST_EPILOG
Definition: unit.hpp:182
void test()
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0