ProteoWizard
Functions | Variables
ChromatogramList_mzML_Test.cpp File Reference
#include "ChromatogramList_mzML.hpp"
#include "Serializer_mzML.hpp"
#include "examples.hpp"
#include "pwiz/utility/minimxml/XMLWriter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

void test (bool indexed)
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ test() [1/2]

void test ( bool  indexed)

Definition at line 40 of file ChromatogramList_mzML_Test.cpp.

41{
42 if (os_) *os_ << "test(): indexed=\"" << boolalpha << indexed << "\"\n";
43
44 MSData tiny;
46
48 config.indexed = indexed;
49 Serializer_mzML serializer(config);
50
51 ostringstream oss;
52 serializer.write(oss, tiny);
53
54 if (os_) *os_ << "oss:\n" << oss.str() << endl;
55
56 shared_ptr<istream> is(new istringstream(oss.str()));
57
58 // dummy would normally be read in from file
59
60 MSData dummy;
61
62 // so we don't have any dangling references
63 //dummy.instrumentPtrs.push_back(InstrumentPtr(new Instrument("LCQ_Deca")));
64 dummy.dataProcessingPtrs.push_back(DataProcessingPtr(new DataProcessing("pwiz_processing")));
65 dummy.dataProcessingPtrs.push_back(DataProcessingPtr(new DataProcessing("CompassXtract processing")));
66
67 Index_mzML_Ptr index(new Index_mzML(is, dummy));
69
70 // check easy functions
71
72 unit_assert(sl.get());
73 unit_assert(sl->size() == 2);
74 unit_assert(sl->find("tic") == 0);
75 unit_assert(sl->find("sic") == 1);
76
77 // check tic
78
79 ChromatogramPtr s = sl->chromatogram(0); // read without binary data
80 unit_assert(s.get());
81 unit_assert(s->id == "tic");
82 unit_assert(s->binaryDataArrayPtrs.empty());
83
84 unit_assert(sl->chromatogramIdentity(0).index == 0);
85 unit_assert(sl->chromatogramIdentity(0).id == "tic");
86
87 s = sl->chromatogram(0, true); // read with binary data
88
89 vector<TimeIntensityPair> pairs;
90 s->getTimeIntensityPairs(pairs);
91 unit_assert(pairs.size() == 15);
92 for (int i=0; i<15; i++)
93 unit_assert(pairs[i].time==i && pairs[i].intensity==15-i);
94
95 // check sic
96
97 s = sl->chromatogram(1, true);
98 unit_assert(s.get());
99 unit_assert(s->id == "sic");
100
101 unit_assert(sl->chromatogramIdentity(1).index == 1);
102 unit_assert(sl->chromatogramIdentity(1).id == "sic");
103
104 pairs.clear();
105 s->getTimeIntensityPairs(pairs);
106 unit_assert(pairs.size() == 10);
107 for (int i=0; i<10; i++)
108 unit_assert(pairs[i].time==i && pairs[i].intensity==(10-i));
109}
ostream * os_
static ChromatogramListPtr create(boost::shared_ptr< std::istream > is, const MSData &msd, const Index_mzML_Ptr &indexPtr)
MSData <-> mzML stream serialization.
PWIZ_API_DECL void initializeTiny(MSData &msd)
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition MSData.hpp:288
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition MSData.hpp:624
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition MSData.hpp:785
boost::shared_ptr< Index_mzML > Index_mzML_Ptr
Description of the way in which a particular software was used.
Definition MSData.hpp:274
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
std::vector< DataProcessingPtr > dataProcessingPtrs
list and descriptions of data processing applied to this data.
Definition MSData.hpp:880
Serializer_mzML configuration.
bool indexed
(indexed==true): read/write with <indexedmzML> wrapper
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::msdata::ChromatogramList_mzML::create(), pwiz::msdata::MSData::dataProcessingPtrs, pwiz::msdata::Serializer_mzML::Config::indexed, pwiz::msdata::examples::initializeTiny(), os_, unit_assert, and pwiz::msdata::Serializer_mzML::write().

◆ test() [2/2]

void test ( )

Definition at line 112 of file ChromatogramList_mzML_Test.cpp.

113{
114 bool indexed = true;
115 test(indexed);
116
117 indexed = false;
118 test(indexed);
119}

References test().

Referenced by main(), and test().

◆ main()

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

Definition at line 122 of file ChromatogramList_mzML_Test.cpp.

123{
124 TEST_PROLOG(argc, argv)
125
126 try
127 {
128 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
129 test();
130 }
131 catch (exception& e)
132 {
133 TEST_FAILED(e.what())
134 }
135 catch (...)
136 {
137 TEST_FAILED("Caught unknown exception.")
138 }
139
141}
#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

Definition at line 37 of file ChromatogramList_mzML_Test.cpp.

Referenced by main(), and test().