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.

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 }

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

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

◆ createProteinList()

ProteinListPtr createProteinList ( )

Definition at line 55 of file ProteinList_FilterTest.cpp.

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 }

References os_, and printProteinList().

Referenced by test().

◆ testSelectedIndices()

void testSelectedIndices ( ProteinListPtr  pl)

Definition at line 98 of file ProteinList_FilterTest.cpp.

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 }

References ralab::base::filter::filter(), os_, printProteinList(), and unit_assert_operator_equal.

Referenced by test().

◆ testIndexSet()

void testIndexSet ( ProteinListPtr  pl)

Definition at line 117 of file ProteinList_FilterTest.cpp.

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 }

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

Referenced by test().

◆ testIdSet()

void testIdSet ( ProteinListPtr  pl)

Definition at line 143 of file ProteinList_FilterTest.cpp.

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 }

References ralab::base::filter::filter(), os_, printProteinList(), and unit_assert_operator_equal.

Referenced by test().

◆ test()

void test ( )

Definition at line 166 of file ProteinList_FilterTest.cpp.

167 {
170  testIndexSet(pl);
171  testIdSet(pl);
172 }

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

Referenced by main().

◆ main()

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

Definition at line 175 of file ProteinList_FilterTest.cpp.

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 }

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

Variable Documentation

◆ os_

ostream* os_ = 0
pwiz::proteome::ProteinList::protein
virtual ProteinPtr protein(size_t index, bool getSequence=true) const =0
pwiz::proteome::ProteinListSimple
Definition: ProteomeData.hpp:76
os_
ostream * os_
Definition: ProteinList_FilterTest.cpp:38
ralab::base::filter::filter
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
printProteinList
void printProteinList(const ProteinList &pl, ostream &os)
Definition: ProteinList_FilterTest.cpp:41
pwiz::analysis::ProteinList_FilterPredicate_IdSet
Definition: ProteinList_Filter.hpp:88
pwiz::analysis::ProteinList_Filter
ProteinList filter, for creating Protein sub-lists.
Definition: ProteinList_Filter.hpp:39
SelectedIndexPredicate
Definition: ChromatogramList_FilterTest.cpp:139
testIndexSet
void testIndexSet(ProteinListPtr pl)
Definition: ProteinList_FilterTest.cpp:117
unit_assert_operator_equal
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
testSelectedIndices
void testSelectedIndices(ProteinListPtr pl)
Definition: ProteinList_FilterTest.cpp:98
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
pwiz::util::IntegerSet::insert
void insert(Interval interval)
insert an interval of integers into the virtual container
createProteinList
ProteinListPtr createProteinList()
Definition: ProteinList_FilterTest.cpp:55
testIdSet
void testIdSet(ProteinListPtr pl)
Definition: ProteinList_FilterTest.cpp:143
pwiz::proteome::ProteinListPtr
boost::shared_ptr< ProteinList > ProteinListPtr
Definition: ProteomeData.hpp:73
pwiz::proteome::Protein
Definition: ProteomeData.hpp:36
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
pwiz::proteome::ProteinList::size
virtual size_t size() const =0
pwiz::analysis::ProteinList_FilterPredicate_IndexSet
Definition: ProteinList_Filter.hpp:75
test
void test()
Definition: ProteinList_FilterTest.cpp:166
pwiz::util::IntegerSet
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
Definition: IntegerSet.hpp:37
pwiz::proteome::ProteinPtr
boost::shared_ptr< Protein > ProteinPtr
Definition: ProteomeData.hpp:48