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

void test ( bool  indexed)

Definition at line 40 of file ChromatogramList_mzML_Test.cpp.

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

{
if (os_) *os_ << "test(): indexed=\"" << boolalpha << indexed << "\"\n";
MSData tiny;
config.indexed = indexed;
Serializer_mzML serializer(config);
ostringstream oss;
serializer.write(oss, tiny);
if (os_) *os_ << "oss:\n" << oss.str() << endl;
shared_ptr<istream> is(new istringstream(oss.str()));
// dummy would normally be read in from file
MSData dummy;
// so we don't have any dangling references
//dummy.instrumentPtrs.push_back(InstrumentPtr(new Instrument("LCQ_Deca")));
dummy.dataProcessingPtrs.push_back(DataProcessingPtr(new DataProcessing("pwiz_processing")));
dummy.dataProcessingPtrs.push_back(DataProcessingPtr(new DataProcessing("CompassXtract processing")));
Index_mzML_Ptr index(new Index_mzML(is, dummy));
ChromatogramListPtr sl = ChromatogramList_mzML::create(is, dummy, index);
// check easy functions
unit_assert(sl.get());
unit_assert(sl->size() == 2);
unit_assert(sl->find("tic") == 0);
unit_assert(sl->find("sic") == 1);
// check tic
ChromatogramPtr s = sl->chromatogram(0); // read without binary data
unit_assert(s.get());
unit_assert(s->id == "tic");
unit_assert(s->binaryDataArrayPtrs.empty());
unit_assert(sl->chromatogramIdentity(0).index == 0);
unit_assert(sl->chromatogramIdentity(0).id == "tic");
s = sl->chromatogram(0, true); // read with binary data
vector<TimeIntensityPair> pairs;
s->getTimeIntensityPairs(pairs);
unit_assert(pairs.size() == 15);
for (int i=0; i<15; i++)
unit_assert(pairs[i].time==i && pairs[i].intensity==15-i);
// check sic
s = sl->chromatogram(1, true);
unit_assert(s.get());
unit_assert(s->id == "sic");
unit_assert(sl->chromatogramIdentity(1).index == 1);
unit_assert(sl->chromatogramIdentity(1).id == "sic");
pairs.clear();
s->getTimeIntensityPairs(pairs);
unit_assert(pairs.size() == 10);
for (int i=0; i<10; i++)
unit_assert(pairs[i].time==i && pairs[i].intensity==(10-i));
}
void test ( )

Definition at line 112 of file ChromatogramList_mzML_Test.cpp.

References test().

{
bool indexed = true;
test(indexed);
indexed = false;
test(indexed);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 122 of file ChromatogramList_mzML_Test.cpp.

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

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 37 of file ChromatogramList_mzML_Test.cpp.