ProteoWizard
Classes | Functions | Variables
IOTest.cpp File Reference
#include "IO.hpp"
#include "Diff.hpp"
#include "References.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

class  TestIterationListener
 
class  TestIterationListener_WithCancel
 

Functions

template<typename object_type >
void testObject (const object_type &a)
 
template<typename object_type >
void testObjectWithMSData (const object_type &a, const MSData &msd)
 
void testObject_SpectrumList (const SpectrumList &a)
 
void testObject_ChromatogramList (const ChromatogramList &a)
 
void testCV ()
 
void testUserParam ()
 
void testCVParam ()
 
void testParamGroup ()
 
template<typename object_type >
void testNamedParamContainer ()
 
void testSourceFile ()
 
void testFileDescription ()
 
void testSample ()
 
void testComponent ()
 
void testComponentList ()
 
void testSoftware ()
 
void testInstrumentConfiguration ()
 
void testProcessingMethod ()
 
void testDataProcessing ()
 
void testScanSettings ()
 
void testPrecursor ()
 
void testProduct ()
 
void testScan ()
 
void testScanList ()
 
void testBinaryDataArray (const BinaryDataEncoder::Config &config)
 
void testBinaryDataArray ()
 
void testBinaryDataArrayExternalMetadata ()
 
void testSpectrum ()
 
void testChromatogram ()
 
void testSpectrumList ()
 
void testSpectrumListWithPositions ()
 
void testSpectrumListWriteProgress ()
 
void testChromatogramList ()
 
void testChromatogramListWithPositions ()
 
void testRun ()
 
void initializeTestData (MSData &msd)
 
void testMSData ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 
const char * bdaWithExternalMetadata
 

Function Documentation

◆ testObject()

template<typename object_type >
void testObject ( const object_type &  a)

Definition at line 42 of file IOTest.cpp.

43{
44 if (os_) *os_ << "testObject(): " << typeid(a).name() << endl;
45
46 // write 'a' out to a stream
47
48 ostringstream oss;
49 XMLWriter writer(oss);
50 IO::write(writer, a);
51 if (os_) *os_ << oss.str() << endl;
52
53 // read 'b' in from stream
54
55 object_type b;
56 istringstream iss(oss.str());
57 IO::read(iss, b);
58
59 // compare 'a' and 'b'
60
62 if (diff && os_) *os_ << "diff:\n" << diff << endl;
64}
void diff(const string &filename1, const string &filename2)
The XMLWriter class provides simple, tag-level XML syntax writing.
Definition XMLWriter.hpp:48
ostream * os_
Definition IOTest.cpp:38
PWIZ_API_DECL void read(std::istream &is, CV &cv)
PWIZ_API_DECL void write(minimxml::XMLWriter &writer, const CV &cv)
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
#define unit_assert(x)
Definition unit.hpp:85

References diff(), os_, pwiz::msdata::IO::read(), unit_assert, and pwiz::msdata::IO::write().

Referenced by testComponent(), testComponentList(), testCV(), testCVParam(), testDataProcessing(), testFileDescription(), testInstrumentConfiguration(), testNamedParamContainer(), testParamGroup(), testPrecursor(), testProcessingMethod(), testProduct(), testSample(), testScanSettings(), testSoftware(), testSourceFile(), and testUserParam().

◆ testObjectWithMSData()

template<typename object_type >
void testObjectWithMSData ( const object_type &  a,
const MSData msd 
)

Definition at line 68 of file IOTest.cpp.

69{
70 if (os_) *os_ << "testObject(): " << typeid(a).name() << endl;
71
72 // write 'a' out to a stream
73
74 ostringstream oss;
75 XMLWriter writer(oss);
76 IO::write(writer, a, msd);
77 if (os_) *os_ << oss.str() << endl;
78
79 // read 'b' in from stream
80
81 object_type b;
82 istringstream iss(oss.str());
83 IO::read(iss, b);
84
85 // compare 'a' and 'b'
86
88 if (diff && os_) *os_ << "diff:\n" << diff << endl;
90}

References diff(), os_, pwiz::msdata::IO::read(), unit_assert, and pwiz::msdata::IO::write().

Referenced by testScan(), and testScanList().

◆ testObject_SpectrumList()

void testObject_SpectrumList ( const SpectrumList a)

Definition at line 93 of file IOTest.cpp.

94{
95 if (os_) *os_ << "testObject_SpectrumList(): " << endl;
96
97 // write 'a' out to a stream
98
99 ostringstream oss;
100 XMLWriter writer(oss);
101 MSData dummy;
102 IO::write(writer, a, dummy);
103 if (os_) *os_ << oss.str() << endl;
104
105 // read 'b' in from stream
106
108 istringstream iss(oss.str());
109 IO::read(iss, b);
110
111 // compare 'a' and 'b'
112
114 if (diff && os_) *os_ << "diff:\n" << diff << endl;
116
117
118}
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
Simple writeable in-memory implementation of SpectrumList.
Definition MSData.hpp:717

References diff(), os_, pwiz::msdata::IO::read(), unit_assert, and pwiz::msdata::IO::write().

Referenced by testSpectrumList().

◆ testObject_ChromatogramList()

void testObject_ChromatogramList ( const ChromatogramList a)

Definition at line 120 of file IOTest.cpp.

122{
123 if (os_) *os_ << "testObject_ChromatogramList(): " << endl;
124
125 // write 'a' out to a stream
126
127 ostringstream oss;
128 XMLWriter writer(oss);
129 IO::write(writer, a);
130 if (os_) *os_ << oss.str() << endl;
131
132 // read 'b' in from stream
133
135 istringstream iss(oss.str());
136 IO::read(iss, b);
137
138 // compare 'a' and 'b'
139
141 if (diff && os_) *os_ << "diff:\n" << diff << endl;
143}
Simple writeable in-memory implementation of ChromatogramList.
Definition MSData.hpp:791

References diff(), os_, pwiz::msdata::IO::read(), unit_assert, and pwiz::msdata::IO::write().

Referenced by testChromatogramList().

◆ testCV()

void testCV ( )

Definition at line 146 of file IOTest.cpp.

147{
148 CV a;
149 a.URI = "abcd";
150 a.id = "efgh";
151 a.fullName = "ijkl";
152 a.version = "mnop";
153
154 testObject(a);
155}
void testObject(const object_type &a)
Definition IOTest.cpp:42
Information about an ontology or CV source and a short 'lookup' tag to refer to.
Definition cv.hpp:14916
std::string id
the short label to be used as a reference tag with which to refer to this particular Controlled Vocab...
Definition cv.hpp:14918
std::string fullName
the usual name for the resource (e.g. The PSI-MS Controlled Vocabulary).
Definition cv.hpp:14924
std::string URI
the URI for the resource.
Definition cv.hpp:14921
std::string version
the version of the CV from which the referred-to terms are drawn.
Definition cv.hpp:14927

References pwiz::cv::CV::fullName, pwiz::cv::CV::id, testObject(), pwiz::cv::CV::URI, and pwiz::cv::CV::version.

Referenced by test().

◆ testUserParam()

void testUserParam ( )

Definition at line 158 of file IOTest.cpp.

159{
160 UserParam a;
161 a.name = "abcd";
162 a.value = "efgh";
163 a.type = "ijkl";
164 a.units = UO_minute;
165
166 testObject(a);
167}
UO_minute
minute: A time unit which is equal to 60 seconds.
Definition cv.hpp:13896
Uncontrolled user parameters (essentially allowing free text). Before using these,...
CVID units
an optional CV parameter for the unit term associated with the value, if any (e.g....
std::string value
the value for the parameter, where appropriate.
std::string name
the name for the parameter.
std::string type
the datatype of the parameter, where appropriate (e.g.: xsd:float).

References pwiz::data::UserParam::name, testObject(), pwiz::data::UserParam::type, pwiz::data::UserParam::units, UO_minute, and pwiz::data::UserParam::value.

Referenced by test().

◆ testCVParam()

void testCVParam ( )

Definition at line 170 of file IOTest.cpp.

171{
172 CVParam a(MS_selected_ion_m_z, "810.48", MS_m_z);
173 testObject(a);
174
175 CVParam b(UO_second, "123.45");
176 testObject(b);
177}
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_selected_ion_m_z
selected ion m/z: Mass-to-charge ratio of an selected ion.
Definition cv.hpp:2901
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
represents a tag-value pair, where the tag comes from the controlled vocabulary

References MS_m_z, MS_selected_ion_m_z, testObject(), and UO_second.

Referenced by test().

◆ testParamGroup()

void testParamGroup ( )

Definition at line 180 of file IOTest.cpp.

181{
182 ParamGroup a("pg");
183 a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
184 a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
185 a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
186 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pgp")));
187 testObject(a);
188}
MS_ionization_type
ionization type: The method by which gas phase ions are generated from the sample.
Definition cv.hpp:285
boost::shared_ptr< ParamGroup > ParamGroupPtr
A collection of CVParam and UserParam elements that can be referenced from elsewhere in this mzML doc...

References pwiz::data::ParamContainer::cvParams, MS_ionization_type, MS_m_z, MS_selected_ion_m_z, pwiz::data::ParamContainer::paramGroupPtrs, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testNamedParamContainer()

template<typename object_type >
void testNamedParamContainer ( )

Definition at line 192 of file IOTest.cpp.

193{
194 object_type a;
195 a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
196 a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
197 a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
198 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pgp")));
199 testObject(a);
200}

References MS_ionization_type, MS_m_z, MS_selected_ion_m_z, and testObject().

◆ testSourceFile()

void testSourceFile ( )

Definition at line 203 of file IOTest.cpp.

204{
205 SourceFile a("id123", "name456", "location789");
206 a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
207 a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
208 a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
209 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pgp")));
210 testObject(a);
211}
Description of the source file, including location and type.
Definition MSData.hpp:55

References pwiz::data::ParamContainer::cvParams, MS_ionization_type, MS_m_z, MS_selected_ion_m_z, pwiz::data::ParamContainer::paramGroupPtrs, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testFileDescription()

void testFileDescription ( )

Definition at line 214 of file IOTest.cpp.

215{
218
219 SourceFilePtr sf(new SourceFile("1", "tiny1.RAW", "file://F:/data/Exp01"));
220 sf->cvParams.push_back(MS_Thermo_RAW_format);
221 sf->cvParams.push_back(MS_SHA_1);
222 a.sourceFilePtrs.push_back(sf);
223
224 Contact contact;
225 contact.cvParams.push_back(CVParam(MS_contact_name, "Darren"));
226 a.contacts.push_back(contact);
227
228 testObject(a);
229}
MS_Thermo_RAW_format
Thermo RAW format: Thermo Scientific RAW file format.
Definition cv.hpp:2298
MS_MSn_spectrum
MSn spectrum: MSn refers to multi-stage MS2 experiments designed to record product ion spectra where ...
Definition cv.hpp:2364
MS_SHA_1
SHA-1: SHA-1 (Secure Hash Algorithm-1) is a cryptographic hash function designed by the National Secu...
Definition cv.hpp:2316
MS_contact_name
contact name: Name of the contact person or organization.
Definition cv.hpp:2409
boost::shared_ptr< SourceFile > SourceFilePtr
Description of the source file, including location and type.
Definition MSData.hpp:76
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Structure allowing the use of a controlled (cvParam) or uncontrolled vocabulary (userParam),...
Definition MSData.hpp:80
Information pertaining to the entire mzML file (i.e. not specific to any part of the data set) is sto...
Definition MSData.hpp:85
std::vector< Contact > contacts
structure allowing the use of a controlled (cvParam) or uncontrolled vocabulary (userParam),...
Definition MSData.hpp:93
FileContent fileContent
this summarizes the different types of spectra that can be expected in the file. This is expected to ...
Definition MSData.hpp:87
std::vector< SourceFilePtr > sourceFilePtrs
list and descriptions of the source files this mzML document was generated or derived from.
Definition MSData.hpp:90

References pwiz::msdata::FileDescription::contacts, pwiz::data::ParamContainer::cvParams, pwiz::msdata::FileDescription::fileContent, MS_contact_name, MS_MSn_spectrum, MS_SHA_1, MS_Thermo_RAW_format, pwiz::msdata::FileDescription::sourceFilePtrs, and testObject().

Referenced by test().

◆ testSample()

void testSample ( )

Definition at line 232 of file IOTest.cpp.

233{
234 Sample a("id123", "name456");
235 a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
236 a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
237 a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
238 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pgp")));
239 testObject(a);
240}
Expansible description of the sample used to generate the dataset, named in sampleName.
Definition MSData.hpp:102

References pwiz::data::ParamContainer::cvParams, MS_ionization_type, MS_m_z, MS_selected_ion_m_z, pwiz::data::ParamContainer::paramGroupPtrs, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testComponent()

void testComponent ( )

Definition at line 243 of file IOTest.cpp.

244{
246 a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
247 a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
248 a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
249 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("pgp")));
250 testObject(a);
251}
@ ComponentType_Source
Definition MSData.hpp:124
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i....
Definition MSData.hpp:132

References pwiz::msdata::ComponentType_Source, pwiz::data::ParamContainer::cvParams, MS_ionization_type, MS_m_z, MS_selected_ion_m_z, pwiz::data::ParamContainer::paramGroupPtrs, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testComponentList()

void testComponentList ( )

Definition at line 254 of file IOTest.cpp.

255{
257 a.push_back(Component(MS_nanoelectrospray, 1));
258 a.push_back(Component(MS_quadrupole_ion_trap, 2));
259 a.push_back(Component(MS_electron_multiplier, 3));
260 testObject(a);
261}
MS_quadrupole_ion_trap
quadrupole ion trap: Quadrupole Ion Trap mass analyzer captures the ions in a three dimensional ion t...
Definition cv.hpp:546
MS_nanoelectrospray
nanoelectrospray: Electrospray ionization at a flow rate less than ~25 nL/min. Nanoelectrospray is sy...
Definition cv.hpp:1764
MS_electron_multiplier
electron multiplier: A device to amplify the current of a beam or packet of charged particles or phot...
Definition cv.hpp:1212
List with the different components used in the mass spectrometer. At least one source,...
Definition MSData.hpp:157

References MS_electron_multiplier, MS_nanoelectrospray, MS_quadrupole_ion_trap, and testObject().

Referenced by test().

◆ testSoftware()

void testSoftware ( )

Definition at line 264 of file IOTest.cpp.

265{
266 Software a;
267 a.id = "goober";
269 a.version = "4.20";
270 testObject(a);
271}
void set(CVID cvid, const std::string &value="", CVID units=CVID_Unknown)
set/add a CVParam (not recursive)
A piece of software.
Definition MSData.hpp:180
std::string id
an identifier for this software that is unique across all SoftwareTypes.
Definition MSData.hpp:182
std::string version
the software version.
Definition MSData.hpp:185

References pwiz::msdata::Software::id, MS_ionization_type, pwiz::data::ParamContainer::set(), testObject(), and pwiz::msdata::Software::version.

Referenced by test().

◆ testInstrumentConfiguration()

void testInstrumentConfiguration ( )

Definition at line 274 of file IOTest.cpp.

275{
277 a.id = "LCQ Deca";
278 a.cvParams.push_back(MS_LCQ_Deca);
279 a.cvParams.push_back(CVParam(MS_instrument_serial_number, 23433));
283 a.softwarePtr = SoftwarePtr(new Software("XCalibur"));
284 testObject(a);
285}
MS_instrument_serial_number
instrument serial number: Serial Number of the instrument.
Definition cv.hpp:2193
MS_LCQ_Deca
LCQ Deca: ThermoFinnigan LCQ Deca.
Definition cv.hpp:2271
boost::shared_ptr< Software > SoftwarePtr
Definition MSData.hpp:198
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition MSData.hpp:230
ComponentList componentList
list with the different components used in the mass spectrometer. At least one source,...
Definition MSData.hpp:235
std::string id
an identifier for this instrument configuration.
Definition MSData.hpp:232
SoftwarePtr softwarePtr
reference to a previously defined software element.
Definition MSData.hpp:238

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::data::ParamContainer::cvParams, pwiz::msdata::InstrumentConfiguration::id, MS_electron_multiplier, MS_instrument_serial_number, MS_LCQ_Deca, MS_nanoelectrospray, MS_quadrupole_ion_trap, pwiz::msdata::InstrumentConfiguration::softwarePtr, and testObject().

Referenced by test().

◆ testProcessingMethod()

void testProcessingMethod ( )

Definition at line 288 of file IOTest.cpp.

289{
291 a.order = 420;
292 a.cvParams.push_back(CVParam(MS_deisotoping, false));
293 a.cvParams.push_back(CVParam(MS_charge_deconvolution, false));
294 a.cvParams.push_back(CVParam(MS_peak_picking, true));
295 a.softwarePtr = SoftwarePtr(new Software("pwiz"));
296 testObject(a);
297}
MS_peak_picking
peak picking: Spectral peak processing conducted on the acquired data to convert profile data to cent...
Definition cv.hpp:369
MS_deisotoping
deisotoping: The removal of isotope peaks to represent the fragment ion as one data point and is comm...
Definition cv.hpp:363
MS_charge_deconvolution
charge deconvolution: The determination of the mass of an ion based on the mass spectral peaks that r...
Definition cv.hpp:366
Description of the default peak processing method. This element describes the base method used in the...
Definition MSData.hpp:255
int order
this attributes allows a series of consecutive steps to be placed in the correct order.
Definition MSData.hpp:257
SoftwarePtr softwarePtr
this attribute MUST reference the 'id' of the appropriate SoftwareType.
Definition MSData.hpp:260

References pwiz::data::ParamContainer::cvParams, MS_charge_deconvolution, MS_deisotoping, MS_peak_picking, pwiz::msdata::ProcessingMethod::order, pwiz::msdata::ProcessingMethod::softwarePtr, and testObject().

Referenced by test().

◆ testDataProcessing()

void testDataProcessing ( )

Definition at line 300 of file IOTest.cpp.

301{
303
304 a.id = "msdata processing";
305
306 ProcessingMethod pm1, pm2;
307
308 pm1.order = 420;
309 pm1.cvParams.push_back(CVParam(MS_deisotoping, false));
310 pm1.cvParams.push_back(CVParam(MS_charge_deconvolution, false));
311 pm1.cvParams.push_back(CVParam(MS_peak_picking, true));
312 pm1.softwarePtr = SoftwarePtr(new Software("msdata"));
313
314 pm2.order = 421;
315 pm2.userParams.push_back(UserParam("testing"));
316
317 a.processingMethods.push_back(pm1);
318 a.processingMethods.push_back(pm2);
319
320 testObject(a);
321}
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Description of the way in which a particular software was used.
Definition MSData.hpp:274
std::vector< ProcessingMethod > processingMethods
description of the default peak processing method(s). This element describes the base method used in ...
Definition MSData.hpp:279
std::string id
a unique identifier for this data processing that is unique across all DataProcessingTypes.
Definition MSData.hpp:276

References pwiz::data::ParamContainer::cvParams, pwiz::msdata::DataProcessing::id, MS_charge_deconvolution, MS_deisotoping, MS_peak_picking, pwiz::msdata::ProcessingMethod::order, pwiz::msdata::DataProcessing::processingMethods, pwiz::msdata::ProcessingMethod::softwarePtr, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testScanSettings()

void testScanSettings ( )

Definition at line 324 of file IOTest.cpp.

325{
326 ScanSettings a;
327
328 a.id = "as1";
329
330 Target t1, t2;
331
332 t1.set(MS_selected_ion_m_z, 200);
333 t2.userParams.push_back(UserParam("testing"));
334
335 a.targets.push_back(t1);
336 a.targets.push_back(t2);
337
338 a.sourceFilePtrs.push_back(SourceFilePtr(new SourceFile("sf1")));
339 a.sourceFilePtrs.push_back(SourceFilePtr(new SourceFile("sf2")));
340
341 testObject(a);
342}
Description of the acquisition settings of the instrument prior to the start of the run.
Definition MSData.hpp:207
std::vector< Target > targets
target list (or 'inclusion list') configured prior to the run.
Definition MSData.hpp:215
std::string id
a unique identifier for this acquisition setting.
Definition MSData.hpp:209
std::vector< SourceFilePtr > sourceFilePtrs
container for a list of source file references.
Definition MSData.hpp:212

References pwiz::msdata::ScanSettings::id, MS_selected_ion_m_z, pwiz::data::ParamContainer::set(), pwiz::msdata::ScanSettings::sourceFilePtrs, pwiz::msdata::ScanSettings::targets, testObject(), and pwiz::data::ParamContainer::userParams.

Referenced by test().

◆ testPrecursor()

void testPrecursor ( )

Definition at line 345 of file IOTest.cpp.

346{
347 Precursor a;
348
349 a.spectrumID = "scan=19";
353 a.selectedIons.resize(2);
354 a.selectedIons[0].set(MS_selected_ion_m_z, 445.34, MS_m_z);
355 a.selectedIons[1].set(MS_charge_state, 2);
358
359 testObject(a);
360
361 // TODO: fix this to test mzML 1.0 precursors;
362 // (requires fixing the framework to support testing different schema versions)
363}
MS_collision_induced_dissociation
collision-induced dissociation: The dissociation of an ion after collisional excitation....
Definition cv.hpp:747
MS_collision_energy
collision energy: Energy for an ion experiencing collision with a stationary gas particle resulting i...
Definition cv.hpp:411
MS_isolation_window_lower_offset
isolation window lower offset: The extent of the isolation window in m/z below the isolation window t...
Definition cv.hpp:3183
MS_charge_state
charge state: The charge state of the ion, single or multiple and positive or negatively charged.
Definition cv.hpp:396
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_isolation_window_upper_offset
isolation window upper offset: The extent of the isolation window in m/z above the isolation window t...
Definition cv.hpp:3186
The method of precursor ion selection and activation.
Definition MSData.hpp:312
std::vector< SelectedIon > selectedIons
this list of precursor ions that were selected.
Definition MSData.hpp:329
IsolationWindow isolationWindow
this element captures the isolation (or 'selection') window configured to isolate one or more precurs...
Definition MSData.hpp:326
Activation activation
the type and energy level used for activation.
Definition MSData.hpp:332
std::string spectrumID
reference to the id attribute of the spectrum from which the precursor was selected.
Definition MSData.hpp:323

References pwiz::msdata::Precursor::activation, pwiz::msdata::Precursor::isolationWindow, MS_charge_state, MS_collision_energy, MS_collision_induced_dissociation, MS_isolation_window_lower_offset, MS_isolation_window_target_m_z, MS_isolation_window_upper_offset, MS_m_z, MS_selected_ion_m_z, pwiz::msdata::Precursor::selectedIons, pwiz::data::ParamContainer::set(), pwiz::msdata::Precursor::spectrumID, and testObject().

Referenced by test().

◆ testProduct()

void testProduct ( )

Definition at line 366 of file IOTest.cpp.

367{
368 Product a;
369
373
374 testObject(a);
375}
product ion information
Definition MSData.hpp:348
IsolationWindow isolationWindow
this element captures the isolation (or 'selection') window configured to isolate one or more precurs...
Definition MSData.hpp:350

References pwiz::msdata::Product::isolationWindow, MS_isolation_window_lower_offset, MS_isolation_window_target_m_z, MS_isolation_window_upper_offset, MS_m_z, pwiz::data::ParamContainer::set(), and testObject().

Referenced by test().

◆ testScan()

void testScan ( )

Definition at line 378 of file IOTest.cpp.

379{
380 Scan a;
381
383 a.paramGroupPtrs.push_back(ParamGroupPtr(new ParamGroup("CommonMS1SpectrumParams")));
384 a.cvParams.push_back(CVParam(MS_scan_start_time, 5.890500, UO_minute));
385 a.cvParams.push_back(CVParam(MS_filter_string, "+ c NSI Full ms [ 400.00-1800.00]"));
386 a.scanWindows.push_back(ScanWindow(400.0, 1800.0, MS_m_z));
387
388 MSData dummy;
389 testObjectWithMSData(a, dummy);
390}
MS_filter_string
filter string: A string unique to Thermo instrument describing instrument settings for the scan.
Definition cv.hpp:2142
MS_scan_start_time
scan start time: The time that an analyzer started a scan, relative to the start of the MS run.
Definition cv.hpp:309
void testObjectWithMSData(const object_type &a, const MSData &msd)
Definition IOTest.cpp:68
boost::shared_ptr< InstrumentConfiguration > InstrumentConfigurationPtr
Definition MSData.hpp:250
std::vector< ParamGroupPtr > paramGroupPtrs
a collection of references to ParamGroups
Scan or acquisition from original raw file used to create this peak list, as specified in sourceFile.
Definition MSData.hpp:370
InstrumentConfigurationPtr instrumentConfigurationPtr
this attribute MUST reference the 'id' attribute of the appropriate instrument configuration.
Definition MSData.hpp:384
std::vector< ScanWindow > scanWindows
container for a list of select windows.
Definition MSData.hpp:387

References pwiz::data::ParamContainer::cvParams, pwiz::msdata::Scan::instrumentConfigurationPtr, MS_filter_string, MS_m_z, MS_scan_start_time, pwiz::data::ParamContainer::paramGroupPtrs, pwiz::msdata::Scan::scanWindows, testObjectWithMSData(), and UO_minute.

Referenced by test().

◆ testScanList()

void testScanList ( )

Definition at line 393 of file IOTest.cpp.

394{
395 ScanList a;
396 a.cvParams.push_back(MS_sum_of_spectra);
397
398 Scan a1;
399 a1.cvParams.push_back(MS_reflectron_on);
400
401 Scan a2;
402 a1.cvParams.push_back(MS_reflectron_off);
403
404 a.scans.push_back(a1);
405 a.scans.push_back(a2);
406
407 MSData dummy;
408 testObjectWithMSData(a, dummy);
409}
MS_reflectron_on
reflectron on: Reflectron is on.
Definition cv.hpp:636
MS_sum_of_spectra
sum of spectra: Spectra Sum.
Definition cv.hpp:2322
MS_reflectron_off
reflectron off: Reflectron is off.
Definition cv.hpp:633
List and descriptions of scans.
Definition MSData.hpp:396
std::vector< Scan > scans
Definition MSData.hpp:397

References pwiz::data::ParamContainer::cvParams, MS_reflectron_off, MS_reflectron_on, MS_sum_of_spectra, pwiz::msdata::ScanList::scans, and testObjectWithMSData().

Referenced by test().

◆ testBinaryDataArray() [1/2]

void testBinaryDataArray ( const BinaryDataEncoder::Config config)

Definition at line 412 of file IOTest.cpp.

413{
414 if (os_) *os_ << "testBinaryDataArray():\n";
415
417 for (int i=0; i<10; i++) a.data.push_back(i);
419
420 // write 'a' out to a stream
421
422 ostringstream oss;
423 XMLWriter writer(oss);
424 IO::write(writer, a, config);
425 if (os_) *os_ << oss.str() << endl;
426
427 // read 'b' in from stream
428
430 istringstream iss(oss.str());
431 IO::read(iss, b);
432
433 // compare 'a' and 'b'
434
436 if (diff && os_) *os_ << "diff:\n" << diff << endl;
438}
void push_back(const T &value)
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition MSData.hpp:288
The structure into which encoded binary data goes. Byte ordering is always little endian (Intel style...
Definition MSData.hpp:405
DataProcessingPtr dataProcessingPtr
this optional attribute may reference the 'id' attribute of the appropriate dataProcessing.
Definition MSData.hpp:407
pwiz::util::BinaryData< double > data
the binary data.
Definition MSData.hpp:410

References pwiz::msdata::BinaryDataArray::data, pwiz::msdata::BinaryDataArray::dataProcessingPtr, diff(), os_, pwiz::util::BinaryData< T >::push_back(), pwiz::msdata::IO::read(), unit_assert, and pwiz::msdata::IO::write().

◆ testBinaryDataArray() [2/2]

void testBinaryDataArray ( )

Definition at line 441 of file IOTest.cpp.

442{
444
447 testBinaryDataArray(config);
448
451 testBinaryDataArray(config);
452
453 //config.precision = BinaryDataEncoder::Precision_64;
454 //config.compression = BinaryDataEncoder::Compression_Zlib;
455 //testBinaryDataArray(config);
456}
void testBinaryDataArray()
Definition IOTest.cpp:441
encoding/decoding configuration

References pwiz::msdata::BinaryDataEncoder::Config::byteOrder, pwiz::msdata::BinaryDataEncoder::ByteOrder_LittleEndian, pwiz::msdata::BinaryDataEncoder::Config::precision, pwiz::msdata::BinaryDataEncoder::Precision_32, pwiz::msdata::BinaryDataEncoder::Precision_64, and testBinaryDataArray().

Referenced by test(), and testBinaryDataArray().

◆ testBinaryDataArrayExternalMetadata()

void testBinaryDataArrayExternalMetadata ( )

Definition at line 466 of file IOTest.cpp.

467{
468 // instantiate an MSData object with the binary array metadata held in a ParamGroup
469
470 MSData msd;
472 pg->id = "mz_params";
473 pg->cvParams.push_back(MS_m_z_array);
474 pg->cvParams.push_back(MS_64_bit_float);
475 pg->cvParams.push_back(MS_no_compression);
476 msd.paramGroupPtrs.push_back(pg);
477
478 istringstream is(bdaWithExternalMetadata);
479 BinaryDataArray bda;
480
481 // test read with MSData reference
482
483 IO::read(is, bda, &msd);
484
485 unit_assert(bda.data.size() == 15);
486 for (size_t i=0; i<15; i++)
487 unit_assert(bda.data[i] == i);
488}
MS_no_compression
no compression: No Compression.
Definition cv.hpp:2337
MS_64_bit_float
64-bit float: 64-bit precision little-endian floating point conforming to IEEE-754.
Definition cv.hpp:2175
MS_m_z_array
m/z array: A data array of m/z values.
Definition cv.hpp:2148
const char * bdaWithExternalMetadata
Definition IOTest.cpp:459
std::vector< ParamGroupPtr > paramGroupPtrs
container for a list of referenceableParamGroups
Definition MSData.hpp:865

References bdaWithExternalMetadata, pwiz::msdata::BinaryDataArray::data, MS_64_bit_float, MS_m_z_array, MS_no_compression, pwiz::msdata::MSData::paramGroupPtrs, pwiz::msdata::IO::read(), pwiz::util::BinaryData< T >::size(), and unit_assert.

Referenced by test().

◆ testSpectrum()

void testSpectrum ( )

Definition at line 491 of file IOTest.cpp.

492{
493 if (os_) *os_ << "testSpectrum():\n";
494
495 Spectrum a;
496
497 a.index = 123;
498 a.id = "goo";
499 a.defaultArrayLength = 666;
503 for (size_t i=0; i<a.defaultArrayLength; i++)
504 a.binaryDataArrayPtrs.back()->data.push_back(i);
505 a.binaryDataArrayPtrs.back()->set(MS_m_z_array);
507 for (size_t i=0; i<a.defaultArrayLength; i++)
508 a.binaryDataArrayPtrs.back()->data.push_back(i*2);
510 a.cvParams.push_back(MS_reflectron_on);
511 a.cvParams.push_back(MS_MSn_spectrum);
512
513 a.precursors.push_back(Precursor());
514 a.precursors.back().spectrumID = "19";
515 a.precursors.back().selectedIons.resize(1);
516 a.precursors.back().selectedIons[0].set(MS_selected_ion_m_z, 445.34, MS_m_z);
517 a.precursors.back().selectedIons[0].set(MS_charge_state, 2);
518 a.precursors.back().activation.set(MS_collision_induced_dissociation);
519 a.precursors.back().activation.set(MS_collision_energy, 35.00, UO_electronvolt);
520
521 a.products.push_back(Product());
522 a.products.back().isolationWindow.set(MS_ionization_type, "420");
523
524 a.scanList.scans.push_back(Scan());
525 Scan& scan = a.scanList.scans.back();
526 scan.set(MS_scan_start_time, 4.20);
527 scan.set(MS_filter_string, "doobie");
528
529 a.scanList.scans.push_back(Scan());
530 Scan& scan2 = a.scanList.scans.back();
531 scan2.set(MS_scan_start_time, 4.21);
532 scan2.set(MS_filter_string, "doo");
533
534 // write 'a' out to a stream
535
536 ostringstream oss;
537 XMLWriter writer(oss);
538 MSData dummy;
539 IO::write(writer, a, dummy);
540 if (os_) *os_ << oss.str() << endl;
541
542 // read 'b' in from stream
543
544 Spectrum b;
545 istringstream iss(oss.str());
546 IO::read(iss, b, IO::ReadBinaryData);
547 unit_assert(b.sourceFilePosition == 0); // not -1
548
549 // compare 'a' and 'b'
550
552 if (diff && os_) *os_ << "diff:\n" << diff << endl;
554
555 // test IgnoreBinaryData
556
557 Spectrum c;
558 iss.seekg(0);
559 IO::read(iss, c); // default = IgnoreBinaryData
561 unit_assert(c.sourceFilePosition == 0); // not -1
562
563 a.binaryDataArrayPtrs.clear();
564 diff(a, c);
566}
MS_intensity_array
intensity array: A data array of intensity values.
Definition cv.hpp:2151
UO_electronvolt
electronvolt: A non-SI unit of energy (eV) defined as the energy acquired by a single unbound electro...
Definition cv.hpp:14595
boost::shared_ptr< BinaryDataArray > BinaryDataArrayPtr
Definition MSData.hpp:417
The structure that captures the generation of a peak list (including the underlying acquisitions)
Definition MSData.hpp:506
SourceFilePtr sourceFilePtr
this attribute can optionally reference the 'id' of the appropriate sourceFile.
Definition MSData.hpp:514
std::vector< Product > products
list and descriptions of product ion information
Definition MSData.hpp:523
DataProcessingPtr dataProcessingPtr
this attribute can optionally reference the 'id' of the appropriate dataProcessing.
Definition MSData.hpp:511
size_t defaultArrayLength
default length of binary data arrays contained in this element.
Definition MSData.hpp:508
ScanList scanList
list of scans
Definition MSData.hpp:517
std::vector< BinaryDataArrayPtr > binaryDataArrayPtrs
list of binary data arrays.
Definition MSData.hpp:526
std::vector< Precursor > precursors
list and descriptions of precursors to the spectrum currently being described.
Definition MSData.hpp:520
boost::iostreams::stream_offset sourceFilePosition
for file-based MSData implementations, this attribute may refer to the spectrum's position in the fil...
Definition MSData.hpp:482
std::string id
a unique identifier for this spectrum. It should be expected that external files may use this identif...
Definition MSData.hpp:476
size_t index
the zero-based, consecutive index of the spectrum in the SpectrumList.
Definition MSData.hpp:473

References pwiz::msdata::Spectrum::binaryDataArrayPtrs, pwiz::data::ParamContainer::cvParams, pwiz::msdata::Spectrum::dataProcessingPtr, pwiz::msdata::Spectrum::defaultArrayLength, diff(), pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::SpectrumIdentity::index, MS_charge_state, MS_collision_energy, MS_collision_induced_dissociation, MS_filter_string, MS_intensity_array, MS_ionization_type, MS_m_z, MS_m_z_array, MS_MSn_spectrum, MS_reflectron_on, MS_scan_start_time, MS_selected_ion_m_z, os_, pwiz::msdata::Spectrum::precursors, pwiz::msdata::Spectrum::products, pwiz::msdata::IO::read(), pwiz::msdata::Spectrum::scanList, pwiz::msdata::ScanList::scans, pwiz::data::ParamContainer::set(), pwiz::msdata::SpectrumIdentity::sourceFilePosition, pwiz::msdata::Spectrum::sourceFilePtr, unit_assert, UO_electronvolt, and pwiz::msdata::IO::write().

Referenced by test().

◆ testChromatogram()

void testChromatogram ( )

Definition at line 569 of file IOTest.cpp.

570{
571 if (os_) *os_ << "testChromatogram():\n";
572
573 Chromatogram a;
574
575 a.index = 123;
576 a.id = "goo";
577 a.defaultArrayLength = 666;
580 for (size_t i=0; i<a.defaultArrayLength; i++)
581 a.binaryDataArrayPtrs.back()->data.push_back(i);
582 a.binaryDataArrayPtrs.back()->set(MS_time_array);
584 for (size_t i=0; i<a.defaultArrayLength; i++)
585 a.binaryDataArrayPtrs.back()->data.push_back(i*2);
587 a.cvParams.push_back(MS_total_ion_current_chromatogram); // TODO: fix when CV has appropriate terms
588
589 // write 'a' out to a stream
590
591 ostringstream oss;
592 XMLWriter writer(oss);
593 IO::write(writer, a);
594 if (os_) *os_ << oss.str() << endl;
595
596 // read 'b' in from stream
597
598 Chromatogram b;
599 istringstream iss(oss.str());
600 IO::read(iss, b, IO::ReadBinaryData);
601 unit_assert(b.sourceFilePosition == 0); // not -1
602
603 // compare 'a' and 'b'
604
606 if (diff && os_) *os_ << "diff:\n" << diff << endl;
608
609 // test IgnoreBinaryData
610
611 Chromatogram c;
612 iss.seekg(0);
613 IO::read(iss, c); // default = IgnoreBinaryData
615 unit_assert(c.sourceFilePosition == 0); // not -1
616
617 a.binaryDataArrayPtrs.clear();
618 diff(a, c);
620}
MS_total_ion_current_chromatogram
total ion current chromatogram: Chromatogram obtained by plotting the total ion current detected in e...
Definition cv.hpp:1107
MS_time_array
time array: A data array of relative time offset values from a reference time.
Definition cv.hpp:2439
A single chromatogram.
Definition MSData.hpp:578
DataProcessingPtr dataProcessingPtr
this attribute can optionally reference the 'id' of the appropriate dataProcessing.
Definition MSData.hpp:583
std::vector< BinaryDataArrayPtr > binaryDataArrayPtrs
list of binary data arrays.
Definition MSData.hpp:592
size_t defaultArrayLength
default length of binary data arrays contained in this element.
Definition MSData.hpp:580
std::string id
a unique identifier for this chromatogram. It should be expected that external files may use this ide...
Definition MSData.hpp:495
size_t index
the zero-based, consecutive index of the chromatogram in the ChromatogramList.
Definition MSData.hpp:492
boost::iostreams::stream_offset sourceFilePosition
for file-based MSData implementations, this attribute may refer to the chromatogram's position in the...
Definition MSData.hpp:498

References pwiz::msdata::Chromatogram::binaryDataArrayPtrs, pwiz::data::ParamContainer::cvParams, pwiz::msdata::Chromatogram::dataProcessingPtr, pwiz::msdata::Chromatogram::defaultArrayLength, diff(), pwiz::msdata::ChromatogramIdentity::id, pwiz::msdata::ChromatogramIdentity::index, MS_intensity_array, MS_time_array, MS_total_ion_current_chromatogram, os_, pwiz::msdata::IO::read(), pwiz::msdata::ChromatogramIdentity::sourceFilePosition, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ testSpectrumList()

void testSpectrumList ( )

Definition at line 623 of file IOTest.cpp.

624{
626
627 SpectrumPtr spectrum1(new Spectrum);
628 spectrum1->id = "goober";
629 spectrum1->index = 0;
630 spectrum1->defaultArrayLength = 666;
631 spectrum1->userParams.push_back(UserParam("description1"));
632
633 SpectrumPtr spectrum2(new Spectrum);
634 spectrum2->id = "raisinet";
635 spectrum2->index = 1;
636 spectrum2->defaultArrayLength = 667;
637 spectrum2->userParams.push_back(UserParam("description2"));
638
639 a.spectra.push_back(spectrum1);
640 a.spectra.push_back(spectrum2);
641 a.dp = DataProcessingPtr(new DataProcessing("dp"));
642
644}
void testObject_SpectrumList(const SpectrumList &a)
Definition IOTest.cpp:93
boost::shared_ptr< Spectrum > SpectrumPtr
Definition MSData.hpp:573
std::vector< SpectrumPtr > spectra
Definition MSData.hpp:718

References pwiz::msdata::SpectrumListSimple::dp, pwiz::msdata::SpectrumListSimple::spectra, and testObject_SpectrumList().

Referenced by test().

◆ testSpectrumListWithPositions()

void testSpectrumListWithPositions ( )

Definition at line 647 of file IOTest.cpp.

648{
649 if (os_) *os_ << "testSpectrumListWithPositions()\n ";
650
652
653 SpectrumPtr spectrum1(new Spectrum);
654 spectrum1->id = "goober";
655 spectrum1->index = 0;
656 spectrum1->defaultArrayLength = 666;
657 spectrum1->userParams.push_back(UserParam("description1"));
658
659 SpectrumPtr spectrum2(new Spectrum);
660 spectrum2->id = "raisinet";
661 spectrum2->index = 1;
662 spectrum2->defaultArrayLength = 667;
663 spectrum2->userParams.push_back(UserParam("description2"));
664
665 a.spectra.push_back(spectrum1);
666 a.spectra.push_back(spectrum2);
667
668 ostringstream oss;
669 XMLWriter writer(oss);
670 vector<stream_offset> positions;
671 MSData dummy;
672 IO::write(writer, a, dummy, BinaryDataEncoder::Config(), &positions);
673
674 if (os_)
675 {
676 copy(positions.begin(), positions.end(), ostream_iterator<stream_offset>(*os_, " "));
677 *os_ << endl << oss.str() << endl;
678 *os_ << "\n\n";
679 }
680
681 unit_assert(positions.size() == 2);
682 unit_assert(positions[0] == 27);
683 unit_assert(positions[1] == 179);
684}

References os_, pwiz::msdata::SpectrumListSimple::spectra, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ testSpectrumListWriteProgress()

void testSpectrumListWriteProgress ( )

Definition at line 722 of file IOTest.cpp.

723{
724 if (os_) *os_ << "testSpectrumListWriteProgress()\n ";
725
727
728 for (size_t i=0; i<11; i++)
729 {
730 SpectrumPtr spectrum(new Spectrum);
731 spectrum->id = "goober_" + lexical_cast<string>(i);
732 spectrum->index = i;
733 spectrum->defaultArrayLength = 666;
734 a.spectra.push_back(spectrum);
735 }
736
737 ostringstream oss;
738 XMLWriter writer(oss);
739
741 TestIterationListener& listener = *boost::static_pointer_cast<TestIterationListener>(listenerPtr);
743 registry.addListener(listenerPtr, 3); // callbacks: 0,2,5,8,10
744
745 MSData dummy;
746 IO::write(writer, a, dummy, BinaryDataEncoder::Config(), 0, &registry);
747
748 if (os_)
749 {
750 *os_ << "callback indices: ";
751 copy(listener.indices().begin(), listener.indices().end(),
752 ostream_iterator<size_t>(*os_, " "));
753 *os_ << "\n\n";
754 }
755
756 unit_assert(listener.indices().size() == 5);
757 unit_assert(listener.indices()[0] == 0);
758 unit_assert(listener.indices()[1] == 2);
759 unit_assert(listener.indices()[2] == 5);
760 unit_assert(listener.indices()[3] == 8);
761 unit_assert(listener.indices()[4] == 10);
762
763 // test #2, this time with cancel at index 6
764
766 TestIterationListener_WithCancel& cancelListener = *boost::static_pointer_cast<TestIterationListener_WithCancel>(cancelListenerPtr);
768 registry2.addListener(cancelListenerPtr, 3); // callbacks: 0,2, cancel at 5
769
770 ostringstream oss2;
771 XMLWriter writer2(oss2);
772 IO::write(writer2, a, dummy, BinaryDataEncoder::Config(), 0, &registry2);
773
774 if (os_)
775 {
776 *os_ << "callback indices: ";
777 copy(cancelListener.indices().begin(), cancelListener.indices().end(),
778 ostream_iterator<size_t>(*os_, " "));
779 *os_ << "\n\n";
780 }
781
782 unit_assert(cancelListener.indices().size() == 2);
783 unit_assert(cancelListener.indices()[0] == 0);
784 unit_assert(cancelListener.indices()[1] == 2);
785}
const vector< size_t > & indices() const
Definition IOTest.cpp:715
const vector< size_t > & indices() const
Definition IOTest.cpp:697
handles registration of IterationListeners and broadcast of update messages
void addListener(const IterationListenerPtr &listener, size_t iterationPeriod)
boost::shared_ptr< IterationListener > IterationListenerPtr

References pwiz::util::IterationListenerRegistry::addListener(), TestIterationListener::indices(), TestIterationListener_WithCancel::indices(), os_, pwiz::msdata::SpectrumListSimple::spectra, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ testChromatogramList()

void testChromatogramList ( )

Definition at line 788 of file IOTest.cpp.

789{
791
792 ChromatogramPtr chromatogram1(new Chromatogram);
793 chromatogram1->id = "goober";
794 chromatogram1->index = 0;
795 chromatogram1->defaultArrayLength = 666;
796
797 ChromatogramPtr chromatogram2(new Chromatogram);
798 chromatogram2->id = "raisinet";
799 chromatogram2->index = 1;
800 chromatogram2->defaultArrayLength = 667;
801
802 a.chromatograms.push_back(chromatogram1);
803 a.chromatograms.push_back(chromatogram2);
804 a.dp = DataProcessingPtr(new DataProcessing("dp"));
805
807}
void testObject_ChromatogramList(const ChromatogramList &a)
Definition IOTest.cpp:120
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition MSData.hpp:624
std::vector< ChromatogramPtr > chromatograms
Definition MSData.hpp:792

References pwiz::msdata::ChromatogramListSimple::chromatograms, pwiz::msdata::ChromatogramListSimple::dp, and testObject_ChromatogramList().

Referenced by test().

◆ testChromatogramListWithPositions()

void testChromatogramListWithPositions ( )

Definition at line 810 of file IOTest.cpp.

811{
812 if (os_) *os_ << "testChromatogramListWithPositions()\n ";
813
815
816 ChromatogramPtr chromatogram1(new Chromatogram);
817 chromatogram1->id = "goober";
818 chromatogram1->index = 0;
819 chromatogram1->defaultArrayLength = 666;
820
821 ChromatogramPtr chromatogram2(new Chromatogram);
822 chromatogram2->id = "raisinet";
823 chromatogram2->index = 1;
824 chromatogram2->defaultArrayLength = 667;
825
826 a.chromatograms.push_back(chromatogram1);
827 a.chromatograms.push_back(chromatogram2);
828
829 ostringstream oss;
830 XMLWriter writer(oss);
831 vector<stream_offset> positions;
832 IO::write(writer, a, BinaryDataEncoder::Config(), &positions);
833
834 if (os_)
835 {
836 copy(positions.begin(), positions.end(), ostream_iterator<stream_offset>(*os_, " "));
837 *os_ << endl << oss.str() << endl;
838 *os_ << "\n\n";
839 }
840
841 unit_assert(positions.size() == 2);
842 unit_assert(positions[0] == 31);
843 unit_assert(positions[1] == 113);
844}

References pwiz::msdata::ChromatogramListSimple::chromatograms, os_, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ testRun()

void testRun ( )

Definition at line 847 of file IOTest.cpp.

848{
849 if (os_) *os_ << "testRun():\n";
850
851 Run a;
852
853 a.id = "goober";
855 a.samplePtr = SamplePtr(new Sample("sample"));
856 a.startTimeStamp = "20 April 2004 4:20pm";
858
859 // spectrumList
860
861 shared_ptr<SpectrumListSimple> spectrumListSimple(new SpectrumListSimple);
862
863 SpectrumPtr spectrum1(new Spectrum);
864 spectrum1->id = "goober";
865 spectrum1->index = 0;
866 spectrum1->defaultArrayLength = 666;
867 spectrum1->userParams.push_back(UserParam("description1"));
868
869 SpectrumPtr spectrum2(new Spectrum);
870 spectrum2->id = "raisinet";
871 spectrum2->index = 1;
872 spectrum2->defaultArrayLength = 667;
873 spectrum2->userParams.push_back(UserParam("description2"));
874
875 spectrumListSimple->spectra.push_back(spectrum1);
876 spectrumListSimple->spectra.push_back(spectrum2);
877
878 a.spectrumListPtr = spectrumListSimple;
879
880 // chromatogramList
881
882 shared_ptr<ChromatogramListSimple> chromatogramListSimple(new ChromatogramListSimple);
883
884 ChromatogramPtr chromatogram1(new Chromatogram);
885 chromatogram1->id = "goober";
886 chromatogram1->index = 0;
887 chromatogram1->defaultArrayLength = 666;
888
889 ChromatogramPtr chromatogram2(new Chromatogram);
890 chromatogram2->id = "raisinet";
891 chromatogram2->index = 1;
892 chromatogram2->defaultArrayLength = 667;
893
894 chromatogramListSimple->chromatograms.push_back(chromatogram1);
895 chromatogramListSimple->chromatograms.push_back(chromatogram2);
896
897 a.chromatogramListPtr = chromatogramListSimple;
898
899 // write 'a' out to a stream
900
901 MSData dummy;
902
903 ostringstream oss;
904 XMLWriter writer(oss);
905 IO::write(writer, a, dummy);
906 if (os_) *os_ << oss.str() << endl;
907
908 // read 'b' in from stream, ignoring SpectrumList (default)
909
910 Run b;
911 istringstream iss(oss.str());
912 IO::read(iss, b, IO::IgnoreSpectrumList); // IO::IgnoreSpectrumList
913
914 // compare 'a' and 'b'
915
917 if (diff && os_) *os_ << "diff:\n" << diff << endl;
919 unit_assert(diff.a_b.spectrumListPtr.get());
920 unit_assert(diff.a_b.spectrumListPtr->size() == 1);
921 unit_assert(diff.a_b.spectrumListPtr->spectrum(0)->userParams.size() == 1);
922
923 // read 'c' in from stream, reading SpectrumList
924
925 Run c;
926 iss.seekg(0);
927 IO::read(iss, c, IO::ReadSpectrumList);
928
929 // compare 'a' and 'c'
930
931 diff(a,c);
932 if (diff && os_) *os_ << "diff:\n" << diff << endl;
934
935 // remove SpectrumList and ChromatogramList from a, and compare to b
936
937 a.spectrumListPtr.reset();
938 a.chromatogramListPtr.reset();
939 diff(a, b);
941}
boost::shared_ptr< Sample > SamplePtr
Definition MSData.hpp:118
A run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition MSData.hpp:810
SourceFilePtr defaultSourceFilePtr
default source file reference
Definition MSData.hpp:824
std::string id
a unique identifier for this run.
Definition MSData.hpp:812
std::string startTimeStamp
the optional start timestamp of the run, in UT.
Definition MSData.hpp:821
InstrumentConfigurationPtr defaultInstrumentConfigurationPtr
this attribute MUST reference the 'id' of the default instrument configuration. If a scan does not re...
Definition MSData.hpp:815
SamplePtr samplePtr
this attribute MUST reference the 'id' of the appropriate sample.
Definition MSData.hpp:818
ChromatogramListPtr chromatogramListPtr
all chromatograms for this run.
Definition MSData.hpp:830
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here....
Definition MSData.hpp:827

References pwiz::msdata::Run::chromatogramListPtr, pwiz::msdata::Run::defaultInstrumentConfigurationPtr, pwiz::msdata::Run::defaultSourceFilePtr, diff(), pwiz::msdata::Run::id, os_, pwiz::msdata::IO::read(), pwiz::msdata::Run::samplePtr, pwiz::msdata::Run::spectrumListPtr, pwiz::msdata::Run::startTimeStamp, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ initializeTestData()

void initializeTestData ( MSData msd)

Definition at line 944 of file IOTest.cpp.

945{
946 msd.accession = "test accession";
947 msd.id = "test id";
948
949 // cvList
950
951 msd.cvs.resize(1);
952 CV& cv = msd.cvs.front();
953 cv.URI = "http://psidev.sourceforge.net/ms/xml/mzdata/psi-ms.2.0.2.obo";
954 cv.id = "MS";
955 cv.fullName = "Proteomics Standards Initiative Mass Spectrometry Ontology";
956 cv.version = "2.0.2";
957
958 // fileDescription
959
961 fc.cvParams.push_back(MS_MSn_spectrum);
962 fc.userParams.push_back(UserParam("number of cats", "4"));
963
964 SourceFilePtr sfp(new SourceFile);
965 sfp->id = "1";
966 sfp->name = "tiny1.RAW";
967 sfp->location = "file://F:/data/Exp01";
968 sfp->cvParams.push_back(MS_Thermo_RAW_format);
969 sfp->cvParams.push_back(CVParam(MS_SHA_1,"71be39fb2700ab2f3c8b2234b91274968b6899b1"));
970 msd.fileDescription.sourceFilePtrs.push_back(sfp);
971
972 SourceFilePtr sfp_parameters(new SourceFile("sf_parameters", "parameters.par", "file:///C:/settings/"));
973 msd.fileDescription.sourceFilePtrs.push_back(sfp_parameters);
974
975 msd.fileDescription.contacts.resize(1);
976 Contact& contact = msd.fileDescription.contacts.front();
977 contact.cvParams.push_back(CVParam(MS_contact_name, "William Pennington"));
978 contact.cvParams.push_back(CVParam(MS_contact_address,
979 "Higglesworth University, 12 Higglesworth Avenue, 12045, HI, USA"));
980 contact.cvParams.push_back(CVParam(MS_contact_URL, "http://www.higglesworth.edu/"));
981 contact.cvParams.push_back(CVParam(MS_contact_email, "wpennington@higglesworth.edu"));
982
983 // paramGroupList
984
985 ParamGroupPtr pg1(new ParamGroup);
986 pg1->id = "CommonMS1SpectrumParams";
987 pg1->cvParams.push_back(MS_positive_scan);
988 msd.paramGroupPtrs.push_back(pg1);
989
990 ParamGroupPtr pg2(new ParamGroup);
991 pg2->id = "CommonMS2SpectrumParams";
992 pg2->cvParams.push_back(MS_positive_scan);
993 msd.paramGroupPtrs.push_back(pg2);
994
995 // sampleList
996
997 SamplePtr samplePtr(new Sample);
998 samplePtr->id = "1";
999 samplePtr->name = "Sample1";
1000 msd.samplePtrs.push_back(samplePtr);
1001
1002 // instrumentConfigurationList
1003
1004 InstrumentConfigurationPtr instrumentConfigurationPtr(new InstrumentConfiguration);
1005 instrumentConfigurationPtr->id = "LCQ Deca";
1006 instrumentConfigurationPtr->cvParams.push_back(MS_LCQ_Deca);
1007 instrumentConfigurationPtr->cvParams.push_back(CVParam(MS_instrument_serial_number,"23433"));
1008 instrumentConfigurationPtr->componentList.push_back(Component(MS_nanoelectrospray, 1));
1009 instrumentConfigurationPtr->componentList.push_back(Component(MS_quadrupole_ion_trap, 2));
1010 instrumentConfigurationPtr->componentList.push_back(Component(MS_electron_multiplier, 3));
1011
1012 SoftwarePtr softwareXcalibur(new Software);
1013 softwareXcalibur->id = "Xcalibur";
1014 softwareXcalibur->set(MS_Xcalibur);
1015 softwareXcalibur->version = "2.0.5";
1016 instrumentConfigurationPtr->softwarePtr = softwareXcalibur;
1017
1018 msd.instrumentConfigurationPtrs.push_back(instrumentConfigurationPtr);
1019
1020 // softwareList
1021
1022 SoftwarePtr softwareBioworks(new Software);
1023 softwareBioworks->id = "Bioworks";
1024 softwareBioworks->set(MS_Bioworks);
1025 softwareBioworks->version = "3.3.1 sp1";
1026
1027 SoftwarePtr software_pwiz(new Software);
1028 software_pwiz->id = "pwiz";
1029 software_pwiz->set(MS_pwiz);
1030 software_pwiz->version = "1.0";
1031
1032 msd.softwarePtrs.push_back(softwareBioworks);
1033 msd.softwarePtrs.push_back(software_pwiz);
1034 msd.softwarePtrs.push_back(softwareXcalibur);
1035
1036 // dataProcessingList
1037
1038 DataProcessingPtr dpXcalibur(new DataProcessing);
1039 dpXcalibur->id = "Xcalibur Processing";
1040
1041 ProcessingMethod procXcal;
1042 procXcal.order = 1;
1043 procXcal.softwarePtr = softwareXcalibur;
1044 procXcal.cvParams.push_back(CVParam(MS_deisotoping, false));
1045 procXcal.cvParams.push_back(CVParam(MS_charge_deconvolution, false));
1046 procXcal.cvParams.push_back(CVParam(MS_peak_picking, true));
1047
1048 dpXcalibur->processingMethods.push_back(procXcal);
1049
1050 DataProcessingPtr dp_msconvert(new DataProcessing);
1051 dp_msconvert->id = "pwiz conversion";
1052
1053 ProcessingMethod proc_msconvert;
1054 proc_msconvert.order = 2;
1055 proc_msconvert.softwarePtr = software_pwiz;
1056 proc_msconvert.cvParams.push_back(MS_Conversion_to_mzML);
1057
1058 dp_msconvert->processingMethods.push_back(proc_msconvert);
1059
1060 msd.dataProcessingPtrs.push_back(dpXcalibur);
1061 msd.dataProcessingPtrs.push_back(dp_msconvert);
1062
1063 ScanSettingsPtr as1(new ScanSettings("as1"));
1064 as1->sourceFilePtrs.push_back(sfp_parameters);
1065 Target t1;
1066 t1.set(MS_m_z, 1000);
1067 Target t2;
1068 t2.set(MS_m_z, 1200);
1069 as1->targets.push_back(t1);
1070 as1->targets.push_back(t2);
1071 msd.scanSettingsPtrs.push_back(as1);
1072
1073 // run
1074
1075 msd.run.id = "Exp01";
1076 msd.run.defaultInstrumentConfigurationPtr = instrumentConfigurationPtr;
1077 msd.run.samplePtr = samplePtr;
1078 msd.run.startTimeStamp = "2007-06-27T15:23:45.00035";
1079 msd.run.defaultSourceFilePtr = sfp;
1080
1081 shared_ptr<SpectrumListSimple> spectrumList(new SpectrumListSimple);
1082 msd.run.spectrumListPtr = spectrumList;
1083
1084 spectrumList->spectra.push_back(SpectrumPtr(new Spectrum));
1085 spectrumList->spectra.push_back(SpectrumPtr(new Spectrum));
1086
1087 Spectrum& s19 = *spectrumList->spectra[0];
1088 s19.id = "S19";
1089 s19.index = 0;
1090 s19.defaultArrayLength = 10;
1091 s19.cvParams.push_back(MS_MSn_spectrum);
1092 s19.set(MS_ms_level, 1);
1093 s19.cvParams.push_back(MS_centroid_spectrum);
1094 s19.cvParams.push_back(CVParam(MS_lowest_observed_m_z, 400.39));
1095 s19.cvParams.push_back(CVParam(MS_highest_observed_m_z, 1795.56));
1096 s19.cvParams.push_back(CVParam(MS_base_peak_m_z, 445.347));
1097 s19.cvParams.push_back(CVParam(MS_base_peak_intensity, 120053));
1098 s19.cvParams.push_back(CVParam(MS_total_ion_current, 1.66755e+007));
1099 s19.scanList.scans.push_back(Scan());
1100 Scan& s19scan = s19.scanList.scans.back();
1101 s19scan.instrumentConfigurationPtr = instrumentConfigurationPtr;
1102 s19scan.paramGroupPtrs.push_back(pg1);
1103 s19scan.cvParams.push_back(CVParam(MS_scan_start_time, 5.890500, UO_minute));
1104 s19scan.cvParams.push_back(CVParam(MS_filter_string, "+ c NSI Full ms [ 400.00-1800.00]"));
1105 s19scan.scanWindows.resize(1);
1106 ScanWindow& window = s19scan.scanWindows.front();
1107 window.cvParams.push_back(CVParam(MS_scan_window_lower_limit, 400.000000));
1108 window.cvParams.push_back(CVParam(MS_scan_window_upper_limit, 1800.000000));
1109
1111 s19_mz->dataProcessingPtr = dpXcalibur;
1112 s19_mz->cvParams.push_back(MS_m_z_array);
1113 s19_mz->data.resize(10);
1114 for (int i=0; i<10; i++)
1115 s19_mz->data[i] = i;
1116
1117 BinaryDataArrayPtr s19_intensity(new BinaryDataArray);
1118 s19_intensity->dataProcessingPtr = dpXcalibur;
1119 s19_intensity->cvParams.push_back(MS_intensity_array);
1120 s19_intensity->data.resize(10);
1121 for (int i=0; i<10; i++)
1122 s19_intensity->data[i] = 10-i;
1123
1124 s19.binaryDataArrayPtrs.push_back(s19_mz);
1125 s19.binaryDataArrayPtrs.push_back(s19_intensity);
1126
1127 Spectrum& s20 = *spectrumList->spectra[1];
1128 s20.id = "S20";
1129 s20.index = 1;
1130 s20.defaultArrayLength = 10;
1131
1132 s20.cvParams.push_back(MS_MSn_spectrum);
1133 s20.set(MS_ms_level, 2);
1134
1135 s20.cvParams.push_back(MS_centroid_spectrum);
1136 s20.cvParams.push_back(CVParam(MS_lowest_observed_m_z, 320.39));
1137 s20.cvParams.push_back(CVParam(MS_highest_observed_m_z, 1003.56));
1138 s20.cvParams.push_back(CVParam(MS_base_peak_m_z, 456.347));
1139 s20.cvParams.push_back(CVParam(MS_base_peak_intensity, 23433));
1140 s20.cvParams.push_back(CVParam(MS_total_ion_current, 1.66755e+007));
1141
1142 s20.precursors.resize(1);
1143 Precursor& precursor = s20.precursors.front();
1144 precursor.spectrumID= s19.id;
1145 precursor.selectedIons.resize(1);
1146 precursor.selectedIons[0].cvParams.push_back(CVParam(MS_selected_ion_m_z, 445.34));
1147 precursor.selectedIons[0].cvParams.push_back(CVParam(MS_charge_state, 2));
1149 precursor.activation.cvParams.push_back(CVParam(MS_collision_energy, 35.00, UO_electronvolt));
1150
1151 s20.scanList.scans.push_back(Scan());
1152 Scan& s20scan = s20.scanList.scans.back();
1153 s20scan.instrumentConfigurationPtr = instrumentConfigurationPtr;
1154 s20scan.paramGroupPtrs.push_back(pg2);
1155 s20scan.cvParams.push_back(CVParam(MS_scan_start_time, 5.990500, UO_minute));
1156 s20scan.cvParams.push_back(CVParam(MS_filter_string, "+ c d Full ms2 445.35@cid35.00 [ 110.00-905.00]"));
1157 s20scan.scanWindows.resize(1);
1158 ScanWindow& window2 = s20scan.scanWindows.front();
1159 window2.cvParams.push_back(CVParam(MS_scan_window_lower_limit, 110.000000));
1160 window2.cvParams.push_back(CVParam(MS_scan_window_upper_limit, 905.000000));
1161
1163 s20_mz->dataProcessingPtr = dpXcalibur;
1164 s20_mz->cvParams.push_back(MS_m_z_array);
1165 s20_mz->data.resize(10);
1166 for (int i=0; i<10; i++)
1167 s20_mz->data[i] = i;
1168
1169 BinaryDataArrayPtr s20_intensity(new BinaryDataArray);
1170 s20_intensity->dataProcessingPtr = dpXcalibur;
1171 s20_intensity->cvParams.push_back(MS_intensity_array);
1172 s20_intensity->data.resize(10);
1173 for (int i=0; i<10; i++)
1174 s20_intensity->data[i] = 10-i;
1175
1176 s20.binaryDataArrayPtrs.push_back(s20_mz);
1177 s20.binaryDataArrayPtrs.push_back(s20_intensity);
1178
1179 // chromatograms
1180
1181 shared_ptr<ChromatogramListSimple> chromatogramList(new ChromatogramListSimple);
1182 msd.run.chromatogramListPtr = chromatogramList;
1183
1184 chromatogramList->chromatograms.push_back(ChromatogramPtr(new Chromatogram));
1185
1186 Chromatogram& tic = *chromatogramList->chromatograms[0];
1187 tic.id = "tic";
1188 tic.index = 0;
1189 tic.defaultArrayLength = 10;
1191
1192 BinaryDataArrayPtr tic_time(new BinaryDataArray);
1193 tic_time->dataProcessingPtr = dp_msconvert;
1194 tic_time->cvParams.push_back(MS_time_array);
1195 tic_time->data.resize(10);
1196 for (int i=0; i<10; i++)
1197 tic_time->data[i] = i;
1198
1199 BinaryDataArrayPtr tic_intensity(new BinaryDataArray);
1200 tic_intensity->dataProcessingPtr = dp_msconvert;
1201 tic_intensity->cvParams.push_back(MS_intensity_array);
1202 tic_intensity->data.resize(10);
1203 for (int i=0; i<10; i++)
1204 tic_intensity->data[i] = 10-i;
1205
1206 tic.binaryDataArrayPtrs.push_back(tic_time);
1207 tic.binaryDataArrayPtrs.push_back(tic_intensity);
1208}
MS_contact_URL
contact URL: Uniform Resource Locator related to the contact person or organization.
Definition cv.hpp:2415
MS_highest_observed_m_z
highest observed m/z: Highest m/z value observed in the m/z array.
Definition cv.hpp:2187
MS_scan_window_lower_limit
scan window lower limit: The upper m/z bound of a mass spectrometer scan window.
Definition cv.hpp:2109
MS_Xcalibur
Xcalibur: Thermo Finnigan software for data acquisition and analysis.
Definition cv.hpp:2202
MS_lowest_observed_m_z
lowest observed m/z: Lowest m/z value observed in the m/z array.
Definition cv.hpp:2190
MS_scan_window_upper_limit
scan window upper limit: The lower m/z bound of a mass spectrometer scan window.
Definition cv.hpp:2106
MS_ms_level
ms level: Stages of ms achieved in a multi stage mass spectrometry experiment.
Definition cv.hpp:2139
MS_centroid_spectrum
centroid spectrum: Processing of profile data to produce spectra that contains discrete peaks of zero...
Definition cv.hpp:720
MS_Conversion_to_mzML
Conversion to mzML: Conversion of a file format to Proteomics Standards Initiative mzML file format.
Definition cv.hpp:2241
MS_contact_email
contact email: Email address of the contact person or organization.
Definition cv.hpp:2418
MS_total_ion_current
total ion current: The sum of all the separate ion currents carried by the ions of different m/z cont...
Definition cv.hpp:1407
MS_base_peak_intensity
base peak intensity: The intensity of the greatest peak in the mass spectrum.
Definition cv.hpp:2121
MS_base_peak_m_z
base peak m/z: M/z value of the signal of highest intensity in the mass spectrum.
Definition cv.hpp:2118
MS_pwiz
pwiz (ProteoWizard software): ProteoWizard software for data processing and analysis....
Definition cv.hpp:2508
MS_positive_scan
positive scan: Polarity of the scan is positive.
Definition cv.hpp:738
MS_contact_address
contact address: Postal address of the contact person or organization.
Definition cv.hpp:2412
MS_Bioworks
Bioworks: Thermo Finnigan software for data analysis of peptides and proteins.
Definition cv.hpp:2205
PWIZ_API_DECL const CV & cv(const std::string &prefix)
returns a CV object for the specified namespace (prefix); currently supported namespaces are: MS UO
boost::shared_ptr< ScanSettings > ScanSettingsPtr
Definition MSData.hpp:225
This summarizes the different types of spectra that can be expected in the file. This is expected to ...
Definition MSData.hpp:50
std::vector< ScanSettingsPtr > scanSettingsPtrs
list with the descriptions of the acquisition settings applied prior to the start of data acquisition...
Definition MSData.hpp:874
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition MSData.hpp:886
std::vector< SoftwarePtr > softwarePtrs
list and descriptions of software used to acquire and/or process the data in this mzML file.
Definition MSData.hpp:871
std::string accession
an optional accession number for the mzML document.
Definition MSData.hpp:852
std::string id
an optional id for the mzML document. It is recommended to use LSIDs when possible.
Definition MSData.hpp:855
FileDescription fileDescription
information pertaining to the entire mzML file (i.e. not specific to any part of the data set) is sto...
Definition MSData.hpp:862
std::vector< InstrumentConfigurationPtr > instrumentConfigurationPtrs
list and descriptions of instrument configurations.
Definition MSData.hpp:877
std::vector< SamplePtr > samplePtrs
list and descriptions of samples.
Definition MSData.hpp:868
std::vector< DataProcessingPtr > dataProcessingPtrs
list and descriptions of data processing applied to this data.
Definition MSData.hpp:880
std::vector< CV > cvs
container for one or more controlled vocabulary definitions.
Definition MSData.hpp:859

References pwiz::msdata::MSData::accession, pwiz::msdata::Precursor::activation, pwiz::msdata::Spectrum::binaryDataArrayPtrs, pwiz::msdata::Chromatogram::binaryDataArrayPtrs, pwiz::msdata::Run::chromatogramListPtr, pwiz::msdata::FileDescription::contacts, pwiz::cv::cv(), pwiz::data::ParamContainer::cvParams, pwiz::msdata::MSData::cvs, pwiz::msdata::MSData::dataProcessingPtrs, pwiz::msdata::Spectrum::defaultArrayLength, pwiz::msdata::Chromatogram::defaultArrayLength, pwiz::msdata::Run::defaultInstrumentConfigurationPtr, pwiz::msdata::Run::defaultSourceFilePtr, pwiz::msdata::FileDescription::fileContent, pwiz::msdata::MSData::fileDescription, pwiz::cv::CV::fullName, pwiz::cv::CV::id, pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::ChromatogramIdentity::id, pwiz::msdata::Run::id, pwiz::msdata::MSData::id, pwiz::msdata::SpectrumIdentity::index, pwiz::msdata::ChromatogramIdentity::index, pwiz::msdata::Scan::instrumentConfigurationPtr, pwiz::msdata::MSData::instrumentConfigurationPtrs, MS_base_peak_intensity, MS_base_peak_m_z, MS_Bioworks, MS_centroid_spectrum, MS_charge_deconvolution, MS_charge_state, MS_collision_energy, MS_collision_induced_dissociation, MS_contact_address, MS_contact_email, MS_contact_name, MS_contact_URL, MS_Conversion_to_mzML, MS_deisotoping, MS_electron_multiplier, MS_filter_string, MS_highest_observed_m_z, MS_instrument_serial_number, MS_intensity_array, MS_LCQ_Deca, MS_lowest_observed_m_z, MS_m_z, MS_m_z_array, MS_ms_level, MS_MSn_spectrum, MS_nanoelectrospray, MS_peak_picking, MS_positive_scan, MS_pwiz, MS_quadrupole_ion_trap, MS_scan_start_time, MS_scan_window_lower_limit, MS_scan_window_upper_limit, MS_selected_ion_m_z, MS_SHA_1, MS_Thermo_RAW_format, MS_time_array, MS_total_ion_current, MS_total_ion_current_chromatogram, MS_Xcalibur, pwiz::msdata::ProcessingMethod::order, pwiz::data::ParamContainer::paramGroupPtrs, pwiz::msdata::MSData::paramGroupPtrs, pwiz::msdata::Spectrum::precursors, pwiz::msdata::MSData::run, pwiz::msdata::Run::samplePtr, pwiz::msdata::MSData::samplePtrs, pwiz::msdata::Spectrum::scanList, pwiz::msdata::ScanList::scans, pwiz::msdata::MSData::scanSettingsPtrs, pwiz::msdata::Scan::scanWindows, pwiz::msdata::Precursor::selectedIons, pwiz::data::ParamContainer::set(), pwiz::msdata::ProcessingMethod::softwarePtr, pwiz::msdata::MSData::softwarePtrs, pwiz::msdata::FileDescription::sourceFilePtrs, pwiz::msdata::Precursor::spectrumID, pwiz::msdata::Run::spectrumListPtr, pwiz::msdata::Run::startTimeStamp, UO_electronvolt, UO_minute, pwiz::cv::CV::URI, pwiz::data::ParamContainer::userParams, and pwiz::cv::CV::version.

Referenced by testMSData().

◆ testMSData()

void testMSData ( )

Definition at line 1211 of file IOTest.cpp.

1212{
1213 if (os_) *os_ << "testMSData():\n";
1214
1215 MSData a;
1217
1218 // write 'a' out to a stream
1219
1220 ostringstream oss;
1221 XMLWriter writer(oss);
1222 IO::write(writer, a);
1223 if (os_) *os_ << oss.str() << endl;
1224
1225 // read 'b' in from stream, ignoring SpectrumList (default)
1226
1227 MSData b;
1228 istringstream iss(oss.str());
1229 IO::read(iss, b); // IO::IgnoreSpectrumList
1230
1231 // compare 'a' and 'b'
1232
1234 if (diff && os_) *os_ << "diff:\n" << diff << endl;
1236 unit_assert(diff.a_b.run.spectrumListPtr.get());
1237 unit_assert(diff.a_b.run.spectrumListPtr->size() == 1);
1238 unit_assert(diff.a_b.run.spectrumListPtr->spectrum(0)->userParams.size() == 1);
1239
1240 // read 'c' in from stream, reading SpectrumList
1241
1242 MSData c;
1243 iss.seekg(0);
1244 IO::read(iss, c, IO::ReadSpectrumList);
1245
1246 // compare 'a' and 'c'
1247
1248 diff(a,c);
1249 if (diff && os_) *os_ << "diff:\n" << diff << endl;
1250 unit_assert(!diff);
1251
1252 // remove SpectrumList and ChromatogramList from a, and compare to b
1253
1254 a.run.spectrumListPtr.reset();
1255 a.run.chromatogramListPtr.reset();
1256 diff(a, b);
1257 unit_assert(!diff);
1258}
void initializeTestData(MSData &msd)
Definition IOTest.cpp:944

References pwiz::msdata::Run::chromatogramListPtr, diff(), initializeTestData(), os_, pwiz::msdata::IO::read(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and pwiz::msdata::IO::write().

Referenced by test().

◆ test()

void test ( )

Definition at line 1261 of file IOTest.cpp.

1262{
1263 testCV();
1264 testUserParam();
1265 testCVParam();
1267 testNamedParamContainer<FileContent>();
1269 testNamedParamContainer<Contact>();
1271 testSample();
1272 testComponent();
1274 testSoftware();
1278 testNamedParamContainer<Target>();
1280 testNamedParamContainer<IsolationWindow>();
1281 testNamedParamContainer<SelectedIon>();
1282 testNamedParamContainer<Activation>();
1283 testPrecursor();
1284 testProduct();
1285 testNamedParamContainer<ScanWindow>();
1286 testScan();
1287 testScanList();
1290 testSpectrum();
1297 testRun();
1298 testMSData();
1299}
void testUserParam()
Definition IOTest.cpp:158
void testSample()
Definition IOTest.cpp:232
void testScanSettings()
Definition IOTest.cpp:324
void testSourceFile()
Definition IOTest.cpp:203
void testCVParam()
Definition IOTest.cpp:170
void testProcessingMethod()
Definition IOTest.cpp:288
void testPrecursor()
Definition IOTest.cpp:345
void testChromatogramList()
Definition IOTest.cpp:788
void testProduct()
Definition IOTest.cpp:366
void testBinaryDataArrayExternalMetadata()
Definition IOTest.cpp:466
void testRun()
Definition IOTest.cpp:847
void testSpectrumList()
Definition IOTest.cpp:623
void testComponent()
Definition IOTest.cpp:243
void testScan()
Definition IOTest.cpp:378
void testFileDescription()
Definition IOTest.cpp:214
void testChromatogramListWithPositions()
Definition IOTest.cpp:810
void testCV()
Definition IOTest.cpp:146
void testSpectrumListWithPositions()
Definition IOTest.cpp:647
void testInstrumentConfiguration()
Definition IOTest.cpp:274
void testComponentList()
Definition IOTest.cpp:254
void testSpectrumListWriteProgress()
Definition IOTest.cpp:722
void testSpectrum()
Definition IOTest.cpp:491
void testChromatogram()
Definition IOTest.cpp:569
void testDataProcessing()
Definition IOTest.cpp:300
void testScanList()
Definition IOTest.cpp:393
void testParamGroup()
Definition IOTest.cpp:180
void testSoftware()
Definition IOTest.cpp:264
void testMSData()
Definition IOTest.cpp:1211

References testBinaryDataArray(), testBinaryDataArrayExternalMetadata(), testChromatogram(), testChromatogramList(), testChromatogramListWithPositions(), testComponent(), testComponentList(), testCV(), testCVParam(), testDataProcessing(), testFileDescription(), testInstrumentConfiguration(), testMSData(), testParamGroup(), testPrecursor(), testProcessingMethod(), testProduct(), testRun(), testSample(), testScan(), testScanList(), testScanSettings(), testSoftware(), testSourceFile(), testSpectrum(), testSpectrumList(), testSpectrumListWithPositions(), testSpectrumListWriteProgress(), and testUserParam().

Referenced by main().

◆ main()

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

Definition at line 1302 of file IOTest.cpp.

1303{
1304 TEST_PROLOG_EX(argc, argv, "_MSData")
1305
1306 try
1307 {
1308 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
1309 test();
1310 if (os_) *os_ << "ok\n";
1311 }
1312 catch (exception& e)
1313 {
1314 TEST_FAILED(e.what())
1315 }
1316 catch (...)
1317 {
1318 TEST_FAILED("Caught unknown exception.")
1319 }
1320
1322}
void test()
Definition IOTest.cpp:1261
#define TEST_PROLOG_EX(argc, argv, suffix)
Definition unit.hpp:157
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177

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

Variable Documentation

◆ os_

ostream* os_ = 0

◆ bdaWithExternalMetadata

const char* bdaWithExternalMetadata
Initial value:
= "\
<binaryDataArray encodedLength=\"160\" arrayLength=\"15\"> \
<referenceableParamGroupRef ref=\"mz_params\"/> \
<binary>AAAAAAAAAAAAAAAAAADwPwAAAAAAAABAAAAAAAAACEAAAAAAAAAQQAAAAAAAABRAAAAAAAAAGEAAAAAAAAAcQAAAAAAAACBAAAAAAAAAIkAAAAAAAAAkQAAAAAAAACZAAAAAAAAAKEAAAAAAAAAqQAAAAAAAACxA</binary> \
</binaryDataArray>"

Definition at line 459 of file IOTest.cpp.

Referenced by testBinaryDataArrayExternalMetadata().