ProteoWizard
Classes | Functions | Variables
ChromatogramList_FilterTest.cpp File Reference
#include "ChromatogramList_Filter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/IntegerSet.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include "pwiz/data/msdata/examples.hpp"
#include "pwiz/data/msdata/Serializer_mzML.hpp"
#include <cstring>

Go to the source code of this file.

Classes

struct  EvenPredicate
 
struct  SelectedIndexPredicate
 

Functions

void printChromatogramList (const ChromatogramList &sl, ostream &os)
 
ChromatogramListPtr createChromatogramList ()
 
void testEven (ChromatogramListPtr sl)
 
void testSelectedIndices (ChromatogramListPtr sl)
 
void testIndexSet (ChromatogramListPtr sl)
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ printChromatogramList()

void printChromatogramList ( const ChromatogramList sl,
ostream &  os 
)

Definition at line 43 of file ChromatogramList_FilterTest.cpp.

44{
45 os << "size: " << sl.size() << endl;
46
47 for (size_t i=0, end=sl.size(); i<end; i++)
48 {
49 ChromatogramPtr chromatogram = sl.chromatogram(i, false);
50 os << chromatogram->index << " "
51 << chromatogram->id << " "
52 << endl;
53 }
54}
virtual size_t size() const =0
returns the number of chromatograms
virtual ChromatogramPtr chromatogram(size_t index, bool getBinaryData=false) const =0
retrieve a chromatogram by index
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition MSData.hpp:624

References pwiz::msdata::ChromatogramList::chromatogram(), and pwiz::msdata::ChromatogramList::size().

Referenced by createChromatogramList(), testEven(), testIndexSet(), and testSelectedIndices().

◆ createChromatogramList()

ChromatogramListPtr createChromatogramList ( )

Definition at line 57 of file ChromatogramList_FilterTest.cpp.

58{
60
61 {
62 ChromatogramPtr chromatogram(new Chromatogram);
63 chromatogram->index = sl->size();
64
65 chromatogram->id = "TIC";
66 chromatogram->setTimeIntensityPairs(vector<TimeIntensityPair>(42), UO_second, MS_number_of_detector_counts);
67 chromatogram->set(MS_TIC_chromatogram);
68
69 sl->chromatograms.push_back(chromatogram);
70 }
71
72 {
73 ChromatogramPtr chromatogram(new Chromatogram);
74 chromatogram->index = sl->size();
75
76 chromatogram->id = "SRM SIC Q1=123.45 Q3=234.56";
77 chromatogram->setTimeIntensityPairs(vector<TimeIntensityPair>(42), UO_second, MS_number_of_detector_counts);
79 chromatogram->precursor.isolationWindow.set(MS_isolation_window_target_m_z, 123.45, MS_m_z);
80 chromatogram->precursor.activation.set(MS_CID);
81 chromatogram->product.isolationWindow.set(MS_isolation_window_target_m_z, 234.56, MS_m_z);
82
83 sl->chromatograms.push_back(chromatogram);
84 }
85
86 {
87 ChromatogramPtr chromatogram(new Chromatogram);
88 chromatogram->index = sl->size();
89
90 chromatogram->id = "SIM SIC Q1=123.45";
91 chromatogram->setTimeIntensityPairs(vector<TimeIntensityPair>(42), UO_second, MS_number_of_detector_counts);
93 chromatogram->precursor.isolationWindow.set(MS_isolation_window_target_m_z, 123.45, MS_m_z);
94
95 sl->chromatograms.push_back(chromatogram);
96 }
97
98 if (os_)
99 {
100 *os_ << "original chromatogram list:\n";
102 *os_ << endl;
103 }
104
105 return sl;
106}
void printChromatogramList(const ChromatogramList &sl, ostream &os)
MS_TIC_chromatogram
TIC chromatogram (total ion current chromatogram): Chromatogram obtained by plotting the total ion cu...
Definition cv.hpp:1110
MS_CID
CID (collision-induced dissociation): The dissociation of an ion after collisional excitation....
Definition cv.hpp:750
MS_selected_ion_monitoring_chromatogram
selected ion monitoring chromatogram: Chromatogram created by creating an array of the measurements o...
Definition cv.hpp:4812
MS_m_z
m/z: Three-character symbol m/z is used to denote the quantity formed by dividing the mass of an ion ...
Definition cv.hpp:384
MS_isolation_window_target_m_z
isolation window target m/z: The primary or reference m/z about which the isolation window is defined...
Definition cv.hpp:3180
MS_number_of_detector_counts
number of detector counts: The number of counted events observed in one or a group of elements of a d...
Definition cv.hpp:741
MS_selected_reaction_monitoring_chromatogram
selected reaction monitoring chromatogram: Chromatogram created by creating an array of the measureme...
Definition cv.hpp:4818
UO_second
second: A time unit which is equal to the duration of 9 192 631 770 periods of the radiation correspo...
Definition cv.hpp:13833
boost::shared_ptr< ChromatogramListSimple > ChromatogramListSimplePtr
Definition MSData.hpp:805
A single chromatogram.
Definition MSData.hpp:578
Simple writeable in-memory implementation of ChromatogramList.
Definition MSData.hpp:791

References MS_CID, MS_isolation_window_target_m_z, MS_m_z, MS_number_of_detector_counts, MS_selected_ion_monitoring_chromatogram, MS_selected_reaction_monitoring_chromatogram, MS_TIC_chromatogram, os_, printChromatogramList(), and UO_second.

Referenced by test().

◆ testEven()

void testEven ( ChromatogramListPtr  sl)

Definition at line 118 of file ChromatogramList_FilterTest.cpp.

119{
120 if (os_) *os_ << "testEven:\n";
121
123
124 if (os_)
125 {
126 printChromatogramList(filter, *os_);
127 *os_ << endl;
128 }
129
131 unit_assert_operator_equal(0, filter.chromatogramIdentity(0).index);
132 unit_assert_operator_equal("TIC", filter.chromatogramIdentity(0).id);
133 unit_assert_operator_equal(1, filter.chromatogramIdentity(1).index);
134 unit_assert_operator_equal("SIM SIC Q1=123.45", filter.chromatogramIdentity(1).id);
135
136}
ChromatogramList filter, for creating Chromatogram 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_, printChromatogramList(), and unit_assert_operator_equal.

Referenced by test().

◆ testSelectedIndices()

void testSelectedIndices ( ChromatogramListPtr  sl)

Definition at line 160 of file ChromatogramList_FilterTest.cpp.

161{
162 if (os_) *os_ << "testSelectedIndices:\n";
163
165
166 if (os_)
167 {
168 printChromatogramList(filter, *os_);
169 *os_ << endl;
170 }
171
173 unit_assert_operator_equal("SRM SIC Q1=123.45 Q3=234.56", filter.chromatogramIdentity(0).id);
174 unit_assert_operator_equal("SIM SIC Q1=123.45", filter.chromatogramIdentity(1).id);
175}

References os_, printChromatogramList(), and unit_assert_operator_equal.

Referenced by test().

◆ testIndexSet()

void testIndexSet ( ChromatogramListPtr  sl)

Definition at line 178 of file ChromatogramList_FilterTest.cpp.

179{
180 if (os_) *os_ << "testIndexSet:\n";
181
182 IntegerSet indexSet;
183 indexSet.insert(1);
184 indexSet.insert(2);
185
187
188 if (os_)
189 {
190 printChromatogramList(filter, *os_);
191 *os_ << endl;
192 }
193
195 unit_assert_operator_equal("SRM SIC Q1=123.45 Q3=234.56", filter.chromatogramIdentity(0).id);
196 unit_assert_operator_equal("SIM SIC Q1=123.45", filter.chromatogramIdentity(1).id);
197}
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_, printChromatogramList(), and unit_assert_operator_equal.

Referenced by test().

◆ test()

void test ( )

Definition at line 200 of file ChromatogramList_FilterTest.cpp.

201{
203 testEven(sl);
205 testIndexSet(sl);
206}
void testIndexSet(ChromatogramListPtr sl)
void testSelectedIndices(ChromatogramListPtr sl)
void testEven(ChromatogramListPtr sl)
ChromatogramListPtr createChromatogramList()
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition MSData.hpp:785

References createChromatogramList(), testEven(), testIndexSet(), and testSelectedIndices().

Referenced by compare(), ralab::base::base::log2(), main(), pwiz::minimxml::SAXParser::Handler::Attributes::attribute::matchName(), testMSXOnly(), and testOverlapOnly().

◆ main()

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

Definition at line 209 of file ChromatogramList_FilterTest.cpp.

210{
211 TEST_PROLOG(argc, argv)
212
213 try
214 {
215 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
216 test();
217 }
218 catch (exception& e)
219 {
220 TEST_FAILED(e.what())
221 }
222 catch (...)
223 {
224 TEST_FAILED("Caught unknown exception.")
225 }
226
228}
#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