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:229
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  CVTranslator cvTranslator;
83  LegacyAdapter_Instrument adapterEmpty(instrumentConfiguration, cvTranslator);
84  unit_assert(adapterEmpty.ionisation() == "Unknown"); // Empty component list is legal
85  instrumentConfiguration.componentList.push_back(Component(ComponentType_Source, 2));
86  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
87  unit_assert(adapter.ionisation() == "Unknown"); // Empty component list is legal
88 
89  adapter.ionisation(" esi\t");
90  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
91  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
92  unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
93  unit_assert(adapter.ionisation() == "electrospray ionization");
94 
95  adapter.ionisation("goober");
96  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
97  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.empty());
98  unit_assert(instrumentConfiguration.componentList.source(0).userParams.size() == 1);
99  unit_assert(adapter.ionisation() == "goober");
100 
101  adapter.ionisation(" Electrospray-Ionization");
102  if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
103  unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
104  unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
105  unit_assert(adapter.ionisation() == "electrospray ionization");
106 }
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:235
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:131
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:229
ostream * os_
#define unit_assert(x)
Definition: unit.hpp:85

◆ testAnalyzer()

void testAnalyzer ( )

Definition at line 109 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().

110 {
111  InstrumentConfiguration instrumentConfiguration;
112  CVTranslator cvTranslator;
113  LegacyAdapter_Instrument adapterEmpty(instrumentConfiguration, cvTranslator);
114  unit_assert(adapterEmpty.analyzer() == "Unknown"); // Empty component list is legal
115  instrumentConfiguration.componentList.push_back(Component(ComponentType_Analyzer, 2));
116  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
117  unit_assert(adapter.analyzer() == "Unknown"); // Empty component list is legal
118 
119  adapter.analyzer("IT");
120  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
121  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
122  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
123  unit_assert(adapter.analyzer() == "ion trap");
124 
125  adapter.analyzer("goober");
126  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
127  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.empty());
128  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.size() == 1);
129  unit_assert(adapter.analyzer() == "goober");
130 
131  adapter.analyzer(" qit");
132  if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
133  unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
134  unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
135  unit_assert(adapter.analyzer() == "quadrupole ion trap");
136 }
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:235
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:131
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:229
ostream * os_
#define unit_assert(x)
Definition: unit.hpp:85

◆ testDetector()

void testDetector ( )

Definition at line 139 of file LegacyAdapterTest.cpp.

References pwiz::msdata::LegacyAdapter_Instrument::analyzer(), 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().

140 {
141  InstrumentConfiguration instrumentConfiguration;
142  CVTranslator cvTranslator;
143  LegacyAdapter_Instrument adapterEmpty(instrumentConfiguration, cvTranslator);
144  unit_assert(adapterEmpty.analyzer() == "Unknown"); // Empty component list is legal
145  instrumentConfiguration.componentList.push_back(Component(ComponentType_Detector, 3));
146  LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
147  unit_assert(adapter.analyzer() == "Unknown"); // Empty component list is legal
148 
149  adapter.detector("emt");
150  if (os_) *os_ << "detector: " << adapter.detector() << endl;
151  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
152  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
153  unit_assert(adapter.detector() == "electron multiplier tube");
154 
155  adapter.detector("goober");
156  if (os_) *os_ << "detector: " << adapter.detector() << endl;
157  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.empty());
158  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.size() == 1);
159  unit_assert(adapter.detector() == "goober");
160 
161  adapter.detector(" Electron Multiplier ");
162  if (os_) *os_ << "detector: " << adapter.detector() << endl;
163  unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
164  unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
165  unit_assert(adapter.detector() == "electron multiplier");
166 }
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:235
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:131
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:229
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 169 of file LegacyAdapterTest.cpp.

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

Referenced by test().

170 {
172  testIonisation();
173  testAnalyzer();
174  testDetector();
175 }
void testDetector()
void testModelAndManufacturer()
void testAnalyzer()
void testIonisation()

◆ testSoftware()

void testSoftware ( )

Definition at line 178 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().

179 {
180  SoftwarePtr software(new Software("abcd"));
181  MSData msd;
182  CVTranslator cvTranslator;
183  LegacyAdapter_Software adapter(software, msd, cvTranslator);
184 
185  adapter.name(" XcaLibur ");
186  if (os_) *os_ << "software name: " << adapter.name() << endl;
187  CVParam softwareParam = software->cvParamChild(MS_software);
188  unit_assert(softwareParam.cvid == MS_Xcalibur);
189  unit_assert(adapter.name() == "Xcalibur");
190 
191  adapter.name("goober");
192  if (os_) *os_ << "software name: " << adapter.name() << endl;
193  softwareParam = software->cvParamChild(MS_software);
194  unit_assert(softwareParam.cvid == CVID_Unknown);
195  unit_assert(adapter.name() == "goober");
196 
197  adapter.version("4.20");
198  if (os_) *os_ << "software version: " << adapter.version() << endl;
199  unit_assert(adapter.version() == "4.20");
200 
201  //adapter.type("acquisition");
202  //if (os_) *os_ << "software type: " << adapter.type() << endl;
203  //unit_assert(adapter.type() == "acquisition");
204 
205  adapter.type("analysis");
206  if (os_) *os_ << "software type: " << adapter.type() << endl;
207  unit_assert(adapter.type() == "analysis");
208 }
boost::shared_ptr< Software > SoftwarePtr
Definition: MSData.hpp:198
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:2199
A piece of software.
Definition: MSData.hpp:179
CVID_Unknown
Definition: cv.hpp:114
ostream * os_
MS_Xcalibur
Xcalibur: Thermo Finnigan software for data acquisition and analysis.
Definition: cv.hpp:2202
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:849
#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 211 of file LegacyAdapterTest.cpp.

References testInstrumentConfiguration(), and testSoftware().

Referenced by main().

212 {
214  testSoftware();
215 }
void testInstrumentConfiguration()
void testSoftware()

◆ main()

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

Definition at line 218 of file LegacyAdapterTest.cpp.

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

219 {
220  TEST_PROLOG(argc, argv)
221 
222  try
223  {
224  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
225  test();
226  }
227  catch (exception& e)
228  {
229  TEST_FAILED(e.what())
230  }
231  catch (...)
232  {
233  TEST_FAILED("Caught unknown exception.")
234  }
235 
237 }
void test()
#define TEST_EPILOG
Definition: unit.hpp:183
#define TEST_FAILED(x)
Definition: unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
ostream * os_

Variable Documentation

◆ os_

ostream* os_ = 0