ProteoWizard
Classes | Functions
Reader_Thermo_Test.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "Reader_Thermo.hpp"
#include "pwiz/utility/misc/VendorReaderTestHarness.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

struct  IsRawFile
 

Functions

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

Function Documentation

◆ main()

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

Definition at line 43 of file Reader_Thermo_Test.cpp.

44 {
45  TEST_PROLOG(argc, argv)
46 
47  #if defined(PWIZ_READER_THERMO) && !defined(PWIZ_READER_THERMO_TEST_ACCEPT_ONLY)
48  const bool testAcceptOnly = false;
49  #else
50  const bool testAcceptOnly = true;
51  #endif
52 
53  try
54  {
55  #ifdef PWIZ_READER_THERMO
56 
57  using namespace pwiz::msdata;
58  using namespace pwiz::msdata::detail;
59  using namespace pwiz::msdata::detail::Thermo;
60  using namespace pwiz::cv;
61  using namespace pwiz::util;
62 
63  // test that all instrument types are handled by translation functions (skipping the 'Unknown' type)
64  bool allInstrumentTestsPassed = true;
65  for (int i=0; i < (int) InstrumentModelType_Count; ++i)
66  {
67  InstrumentModelType model = (InstrumentModelType) i;
68 
69  try
70  {
72 
73  Component dummySource;
74  vector<InstrumentConfiguration> configurations = createInstrumentConfigurations(dummySource, model);
75 
76  switch (model)
77  {
78  case InstrumentModelType_Tempus_TOF:
79  case InstrumentModelType_Element_2:
80  case InstrumentModelType_Element_XR:
81  case InstrumentModelType_Element_GD:
82  case InstrumentModelType_Delta_Plus_Advantage:
83  case InstrumentModelType_Delta_Plus_XP:
84  case InstrumentModelType_Neptune:
85  case InstrumentModelType_Triton:
86  unit_assert(configurations.empty());
87  break;
88 
89  default:
90  unit_assert(!configurations.empty());
91  break;
92  }
93 
94  // test for ionization types for this instrument
95  vector<IonizationType> ionizationTypes = getIonSourcesForInstrumentModel(model);
96 
97  switch (model)
98  {
99  case InstrumentModelType_Element_XR:
100  case InstrumentModelType_Element_2:
101  case InstrumentModelType_Delta_Plus_Advantage:
102  case InstrumentModelType_Delta_Plus_XP:
103  case InstrumentModelType_Neptune:
104  case InstrumentModelType_Tempus_TOF:
105  case InstrumentModelType_Triton:
106  case InstrumentModelType_MAT253:
107  case InstrumentModelType_MAT900XP:
108  case InstrumentModelType_MAT900XP_Trap:
109  case InstrumentModelType_MAT95XP:
110  case InstrumentModelType_MAT95XP_Trap:
111  case InstrumentModelType_Surveyor_PDA:
112  case InstrumentModelType_Accela_PDA:
113  unit_assert(ionizationTypes.empty());
114  break;
115 
116  default:
117  unit_assert(!ionizationTypes.empty());
118  break;
119  }
120 
121  // test for mass analyzer types for this instrument
122  vector<MassAnalyzerType> massAnalyzerTypes = getMassAnalyzersForInstrumentModel(model);
123 
124  switch (model)
125  {
126  case InstrumentModelType_Element_XR:
127  case InstrumentModelType_Element_2:
128  case InstrumentModelType_Element_GD:
129  case InstrumentModelType_Delta_Plus_Advantage:
130  case InstrumentModelType_Delta_Plus_XP:
131  case InstrumentModelType_Neptune:
132  case InstrumentModelType_Triton:
133  case InstrumentModelType_Surveyor_PDA:
134  case InstrumentModelType_Accela_PDA:
135  unit_assert(massAnalyzerTypes.empty());
136  break;
137 
138  default:
139  unit_assert(!massAnalyzerTypes.empty());
140  break;
141  }
142 
143  // test for detector types for this instrument
144  vector<DetectorType> detectorTypes = getDetectorsForInstrumentModel(model);
145 
146  switch (model)
147  {
148  case InstrumentModelType_Element_GD:
149  case InstrumentModelType_Element_XR:
150  case InstrumentModelType_Element_2:
151  case InstrumentModelType_Delta_Plus_Advantage:
152  case InstrumentModelType_Delta_Plus_XP:
153  case InstrumentModelType_Neptune:
154  case InstrumentModelType_Tempus_TOF:
155  case InstrumentModelType_Triton:
156  case InstrumentModelType_MAT253:
157  case InstrumentModelType_MAT900XP:
158  case InstrumentModelType_MAT900XP_Trap:
159  case InstrumentModelType_MAT95XP:
160  case InstrumentModelType_MAT95XP_Trap:
161  unit_assert(detectorTypes.empty());
162  break;
163 
164  default:
165  unit_assert(!detectorTypes.empty());
166  break;
167  }
168 
169  // test for translation of scan filter mass analyzer type to real mass analyzer type
170  BOOST_FOREACH(MassAnalyzerType realType, massAnalyzerTypes)
171  {
172  bool hasCorrespondingScanFilterType = false;
173  for (int j=0; j < (int) ScanFilterMassAnalyzerType_Count; ++j)
174  if (convertScanFilterMassAnalyzer((ScanFilterMassAnalyzerType) j, model) == realType)
175  hasCorrespondingScanFilterType = true;
176  unit_assert(hasCorrespondingScanFilterType);
177  }
178  }
179  catch (runtime_error& e)
180  {
181  cerr << "Unit test failed for instrument model " << lexical_cast<string>(model) << ":\n" << e.what() << endl;
182  allInstrumentTestsPassed = false;
183  }
184  }
185 
186  unit_assert(allInstrumentTestsPassed);
187  #endif
188 
189  bool requireUnicodeSupport = true;
192  pwiz::util::testReader(reader, testArgs, testAcceptOnly, requireUnicodeSupport, IsRawFile(), config);
193 
194  config.peakPicking = true;
195  pwiz::util::testReader(reader, testArgs, testAcceptOnly, requireUnicodeSupport, IsRawFile(), config);
196 
197  #ifdef PWIZ_READER_THERMO
198  // CONSIDER: do this test in VendorReaderTestHarness for all vendor readers?
199  ::SetThreadLocale(LANG_TURKISH);
200  pwiz::util::testReader(reader, testArgs, testAcceptOnly, requireUnicodeSupport, IsRawFile(), config);
201  #endif
202  }
203  catch (exception& e)
204  {
205  TEST_FAILED(e.what())
206  }
207  catch (...)
208  {
209  TEST_FAILED("Caught unknown exception.")
210  }
211 
213 }

References pwiz::msdata::detail::Thermo::createInstrumentConfigurations(), CVID_Unknown, pwiz::util::ReaderTestConfig::peakPicking, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, pwiz::util::testReader(), pwiz::msdata::detail::Thermo::translateAsInstrumentModel(), and unit_assert.

pwiz::cv
Definition: cv.hpp:108
pwiz::msdata::detail::Thermo::translateAsInstrumentModel
PWIZ_API_DECL CVID translateAsInstrumentModel(InstrumentModelType instrumentModelType)
pwiz::util::ReaderTestConfig
Definition: VendorReaderTestHarness.hpp:44
pwiz::msdata
Definition: DemuxTypes.hpp:27
pwiz::msdata::detail
Definition: ChromatogramList_ABI.hpp:35
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
CVID_Unknown
CVID_Unknown
Definition: cv.hpp:114
pwiz::util::ReaderTestConfig::peakPicking
bool peakPicking
Definition: VendorReaderTestHarness.hpp:48
pwiz::msdata::Component
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i....
Definition: MSData.hpp:131
pwiz::msdata::detail::Thermo::createInstrumentConfigurations
PWIZ_API_DECL std::vector< InstrumentConfiguration > createInstrumentConfigurations(RawFile &rawfile)
pwiz::msdata::Reader_Thermo
Definition: Reader_Thermo.hpp:35
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
pwiz::msdata::detail::Thermo
Definition: Reader_Thermo_Detail.hpp:37
IsRawFile
Definition: Reader_Thermo_Test.cpp:35
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
pwiz::util::testReader
PWIZ_API_DECL int testReader(const pwiz::msdata::Reader &reader, const std::vector< std::string > &args, bool testAcceptOnly, bool requireUnicodeSupport, const TestPathPredicate &isPathTestable, const ReaderTestConfig &config=ReaderTestConfig())
A common test harness for vendor readers;.