ProteoWizard
Functions | Variables
LegacyAdapterTest.cpp File Reference
#include "LegacyAdapter.hpp"
#include "pwiz/data/common/CVTranslator.hpp"
#include "TextWriter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testModelAndManufacturer ()
 
void testIonisation ()
 
void testAnalyzer ()
 
void testDetector ()
 
void testInstrumentConfiguration ()
 
void testSoftware ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

§ testModelAndManufacturer()

void testModelAndManufacturer ( )

Definition at line 43 of file LegacyAdapterTest.cpp.

References pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::manufacturer(), pwiz::msdata::LegacyAdapter_Instrument::manufacturerAndModel(), pwiz::msdata::LegacyAdapter_Instrument::model(), os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

44 {
45  if (os_) *os_ << "testModelAndManufacturer()\n";
46 
47  InstrumentConfiguration instrumentConfiguration;
48  CVTranslator cvTranslator;
49  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
50 
51  unit_assert(instrumentConfiguration.cvParams.empty() && instrumentConfiguration.userParams.empty());
52 
53  adapter.manufacturerAndModel("dummy", "LTQ-FT");
54  if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
55  << "model: " << adapter.model() << endl;
56  unit_assert(instrumentConfiguration.cvParams.size() == 1);
57  unit_assert(instrumentConfiguration.userParams.empty());
58  unit_assert(adapter.manufacturer() == "Thermo Scientific");
59  unit_assert(adapter.model() == "LTQ FT");
60 
61  adapter.manufacturerAndModel("doobie", "420");
62  if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
63  << "model: " << adapter.model() << endl;
64  unit_assert(instrumentConfiguration.cvParams.empty());
65  unit_assert(instrumentConfiguration.userParams.size() == 2);
66  unit_assert(adapter.manufacturer() == "doobie");
67  unit_assert(adapter.model() == "420");
68 
69  adapter.manufacturerAndModel("dummy", "LTQ-FT");
70  if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
71  << "model: " << adapter.model() << endl;
72  unit_assert(instrumentConfiguration.cvParams.size() == 1);
73  unit_assert(instrumentConfiguration.userParams.empty());
74  unit_assert(adapter.manufacturer() == "Thermo Scientific");
75  unit_assert(adapter.model() == "LTQ FT");
76 }
translates text to CV terms
interface for legacy access to Instrument
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition: MSData.hpp:228
ostream * os_
#define unit_assert(x)
Definition: unit.hpp:85

§ testIonisation()

void testIonisation ( )

Definition at line 79 of file LegacyAdapterTest.cpp.

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Source, pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::ionisation(), os_, pwiz::msdata::ComponentList::source(), unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

80 {
81  InstrumentConfiguration instrumentConfiguration;
82  instrumentConfiguration.componentList.push_back(Component(ComponentType_Source, 2));
83  CVTranslator cvTranslator;
84  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
85 
86  adapter.ionisation(" esi\t");
87  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
88  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
89  unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
90  unit_assert(adapter.ionisation() == "electrospray ionization");
91 
92  adapter.ionisation("goober");
93  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
94  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.empty());
95  unit_assert(instrumentConfiguration.componentList.source(0).userParams.size() == 1);
96  unit_assert(adapter.ionisation() == "goober");
97 
98  adapter.ionisation(" Electrospray-Ionization");
99  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
100  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
101  unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
102  unit_assert(adapter.ionisation() == "electrospray ionization");
103 }
ComponentList componentList
list with the different components used in the mass spectrometer. At least one source, one mass analyzer and one detector need to be specified.
Definition: MSData.hpp:234
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:130
translates text to CV terms
interface for legacy access to Instrument
Component & source(size_t index)
returns the source component with ordinal <index+1>
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition: MSData.hpp:228
ostream * os_
#define unit_assert(x)
Definition: unit.hpp:85

§ testAnalyzer()

void testAnalyzer ( )

Definition at line 106 of file LegacyAdapterTest.cpp.

References pwiz::msdata::LegacyAdapter_Instrument::analyzer(), pwiz::msdata::ComponentList::analyzer(), pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Analyzer, pwiz::data::ParamContainer::cvParams, os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

107 {
108  InstrumentConfiguration instrumentConfiguration;
109  instrumentConfiguration.componentList.push_back(Component(ComponentType_Analyzer, 2));
110  CVTranslator cvTranslator;
111  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
112 
113  adapter.analyzer("IT");
114  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
115  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
116  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
117  unit_assert(adapter.analyzer() == "ion trap");
118 
119  adapter.analyzer("goober");
120  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
121  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.empty());
122  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.size() == 1);
123  unit_assert(adapter.analyzer() == "goober");
124 
125  adapter.analyzer(" qit");
126  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
127  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
128  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
129  unit_assert(adapter.analyzer() == "quadrupole ion trap");
130 }
ComponentList componentList
list with the different components used in the mass spectrometer. At least one source, one mass analyzer and one detector need to be specified.
Definition: MSData.hpp:234
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:130
translates text to CV terms
interface for legacy access to Instrument
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250
Component & analyzer(size_t index)
returns the analyzer component with ordinal <index+1>
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition: MSData.hpp:228
ostream * os_
#define unit_assert(x)
Definition: unit.hpp:85

§ testDetector()

void testDetector ( )

Definition at line 133 of file LegacyAdapterTest.cpp.

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Detector, pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::detector(), pwiz::msdata::ComponentList::detector(), os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

134 {
135  InstrumentConfiguration instrumentConfiguration;
136  instrumentConfiguration.componentList.push_back(Component(ComponentType_Detector, 3));
137  CVTranslator cvTranslator;
138  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
139 
140  adapter.detector("emt");
141  if (os_) *os_ << "detector: " << adapter.detector() << endl;
142  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
143  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
144  unit_assert(adapter.detector() == "electron multiplier tube");
145 
146  adapter.detector("goober");
147  if (os_) *os_ << "detector: " << adapter.detector() << endl;
148  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.empty());
149  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.size() == 1);
150  unit_assert(adapter.detector() == "goober");
151 
152  adapter.detector(" Electron Multiplier ");
153  if (os_) *os_ << "detector: " << adapter.detector() << endl;
154  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
155  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
156  unit_assert(adapter.detector() == "electron multiplier");
157 }
ComponentList componentList
list with the different components used in the mass spectrometer. At least one source, one mass analyzer and one detector need to be specified.
Definition: MSData.hpp:234
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:130
translates text to CV terms
interface for legacy access to Instrument
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition: MSData.hpp:228
ostream * os_
Component & detector(size_t index)
returns the detector component with ordinal <index+1>
#define unit_assert(x)
Definition: unit.hpp:85

§ testInstrumentConfiguration()

void testInstrumentConfiguration ( )

Definition at line 160 of file LegacyAdapterTest.cpp.

References testAnalyzer(), testDetector(), testIonisation(), and testModelAndManufacturer().

Referenced by test().

161 {
163  testIonisation();
164  testAnalyzer();
165  testDetector();
166 }
void testDetector()
void testModelAndManufacturer()
void testAnalyzer()
void testIonisation()

§ testSoftware()

void testSoftware ( )

Definition at line 169 of file LegacyAdapterTest.cpp.

References pwiz::data::CVParam::cvid, CVID_Unknown, MS_software, MS_Xcalibur, pwiz::msdata::LegacyAdapter_Software::name(), os_, pwiz::msdata::LegacyAdapter_Software::type(), unit_assert, and pwiz::msdata::LegacyAdapter_Software::version().

Referenced by test().

170 {
171  SoftwarePtr software(new Software("abcd"));
172  MSData msd;
173  CVTranslator cvTranslator;
174  LegacyAdapter_Software adapter(software, msd, cvTranslator);
175 
176  adapter.name(" XcaLibur ");
177  if (os_) *os_ << "software name: " << adapter.name() << endl;
178  CVParam softwareParam = software->cvParamChild(MS_software);
179  unit_assert(softwareParam.cvid == MS_Xcalibur);
180  unit_assert(adapter.name() == "Xcalibur");
181 
182  adapter.name("goober");
183  if (os_) *os_ << "software name: " << adapter.name() << endl;
184  softwareParam = software->cvParamChild(MS_software);
185  unit_assert(softwareParam.cvid == CVID_Unknown);
186  unit_assert(adapter.name() == "goober");
187 
188  adapter.version("4.20");
189  if (os_) *os_ << "software version: " << adapter.version() << endl;
190  unit_assert(adapter.version() == "4.20");
191 
192  //adapter.type("acquisition");
193  //if (os_) *os_ << "software type: " << adapter.type() << endl;
194  //unit_assert(adapter.type() == "acquisition");
195 
196  adapter.type("analysis");
197  if (os_) *os_ << "software type: " << adapter.type() << endl;
198  unit_assert(adapter.type() == "analysis");
199 }
boost::shared_ptr< Software > SoftwarePtr
Definition: MSData.hpp:197
translates text to CV terms
interface for legacy access to Software
MS_software
software: Software related to the recording or transformation of spectra.
Definition: cv.hpp:2047
A piece of software.
Definition: MSData.hpp:178
CVID_Unknown
Definition: cv.hpp:97
ostream * os_
MS_Xcalibur
Xcalibur: Thermo Finnigan software for data acquisition and analysis.
Definition: cv.hpp:2050
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85
represents a tag-value pair, where the tag comes from the controlled vocabulary
Definition: ParamTypes.hpp:44

§ test()

void test ( )

Definition at line 202 of file LegacyAdapterTest.cpp.

References testInstrumentConfiguration(), and testSoftware().

Referenced by main().

203 {
205  testSoftware();
206 }
void testInstrumentConfiguration()
void testSoftware()

§ main()

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

Definition at line 209 of file LegacyAdapterTest.cpp.

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

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 }
void test()
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
ostream * os_

Variable Documentation

§ os_

ostream* os_ = 0