ProteoWizard
Serializer_mzML_Test.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2007 Spielberg Family Center for Applied Proteomics
8// Cedars-Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
24#include "Serializer_mzML.hpp"
25#include "Diff.hpp"
26#include "References.hpp"
27#include "examples.hpp"
29#include "boost/iostreams/positioning.hpp"
31#include <cstring>
32
33
34using namespace pwiz::util;
35using namespace pwiz::cv;
36using namespace pwiz::msdata;
37
38
39ostream* os_ = 0;
40
41
42void testWriteRead(const MSData& msd, const Serializer_mzML::Config& config, const DiffConfig &diffcfg)
43{
44 if (os_) *os_ << "testWriteRead() " << config << endl;
45
46 Serializer_mzML mzmlSerializer(config);
47
48 ostringstream oss;
49 mzmlSerializer.write(oss, msd);
50
51 if (os_) *os_ << "oss:\n" << oss.str() << endl;
52
53 shared_ptr<istringstream> iss(new istringstream(oss.str()));
54 MSData msd2;
55 mzmlSerializer.read(iss, msd2);
56
58
59 Diff<MSData, DiffConfig> diff(msd, msd2, diffcfg);
60 if (os_ && diff) *os_ << diff << endl;
62}
63
64
66{
67 MSData msd;
69 for (int zloop=2;zloop--;) // run through once without zlib, then with
70 {
71 DiffConfig diffcfg;
73
74 if (!zloop) // retest with compression
76
78 testWriteRead(msd, config, diffcfg);
79
81 testWriteRead(msd, config, diffcfg);
82
83 config.indexed = false;
84 testWriteRead(msd, config, diffcfg);
85
86 // lossy compression, increase allowable mismatch
87 diffcfg.precision = 0.01;
89 testWriteRead(msd, config, diffcfg);
90
92 testWriteRead(msd, config, diffcfg);
93
96 testWriteRead(msd, config, diffcfg);
97
98 if (!zloop) // provoke numpress temp. disable
99 {
102 testWriteRead(msd, config, diffcfg);
103 }
104 }
105
106}
107
108
109int main(int argc, char* argv[])
110{
111 TEST_PROLOG(argc, argv)
112
113 try
114 {
115 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
117 }
118 catch (exception& e)
119 {
120 TEST_FAILED(e.what())
121 }
122 catch (...)
123 {
124 TEST_FAILED("Caught unknown exception.")
125 }
126
128}
129
void diff(const string &filename1, const string &filename2)
int main(int argc, char *argv[])
ostream * os_
void testWriteRead()
MSData <-> mzML stream serialization.
void write(std::ostream &os, const MSData &msd, const pwiz::util::IterationListenerRegistry *iterationListenerRegistry=0) const
write MSData object to ostream as mzML; iterationListenerRegistry may be used to receive progress upd...
void read(boost::shared_ptr< std::istream > is, MSData &msd) const
read in MSData object from an mzML istream note: istream may be managed by MSData's SpectrumList,...
MS_intensity_array
intensity array: A data array of intensity values.
Definition cv.hpp:2151
PWIZ_API_DECL void resolve(ParamContainer &paramContainer, const MSData &msd)
PWIZ_API_DECL void initializeTiny(MSData &msd)
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
std::map< cv::CVID, Numpress > numpressOverrides
configuration struct for diffing MSData types
Definition Diff.hpp:206
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
Serializer_mzML configuration.
BinaryDataEncoder::Config binaryDataEncoderConfig
configuration for binary data encoding in write() note: byteOrder is ignored (mzML always little endi...
bool indexed
(indexed==true): read/write with <indexedmzML> wrapper
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175