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}
virtual ProteinPtr protein(size_t index, bool getSequence=true) const =0
virtual size_t size() const =0
boost::shared_ptr< Protein > ProteinPtr

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}
void printProteinList(const ProteinList &pl, ostream &os)
ostream * os_

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 {
106 printProteinList(filter, *os_);
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}
ProteinList filter, for creating Protein sub-lists.
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
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92

References 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 {
130 printProteinList(filter, *os_);
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}
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
void insert(Interval interval)
insert an interval of integers into the virtual container

References 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 {
154 printProteinList(filter, *os_);
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 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}
void testIndexSet(ProteinListPtr pl)
ProteinListPtr createProteinList()
void testIdSet(ProteinListPtr pl)
void testSelectedIndices(ProteinListPtr pl)
boost::shared_ptr< ProteinList > ProteinListPtr

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}
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

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

Variable Documentation

◆ os_

ostream* os_ = 0