ProteoWizard
SpectrumList_IonMobility_Test.cpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumList_IonMobility_Test.cpp 9810 2016-06-13 21:41:53Z pcbrefugee $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6 //
7 // Copyright 2016 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
28 #include "boost/foreach_field.hpp"
29 
30 using namespace pwiz::util;
31 using namespace pwiz::cv;
32 using namespace pwiz::msdata;
33 using namespace pwiz::analysis;
34 
35 ostream* os_ = 0;
36 
37 void test(const string& filepath, const ReaderList& readerList)
38 {
39  MSDataFile msd(filepath, &readerList);
40  const double EPSILON = 1e-4;
41 
42  if (bal::ends_with(filepath, "ImsSynth_Chrom.d"))
43  {
45  ostringstream failedTests;
46  unit_assert_equal_to_stream(242.55569, slim.driftTimeToCCS(32.62, 922.01, 1), EPSILON, failedTests);
47  unit_assert_equal_to_stream(195.69509, slim.driftTimeToCCS(25.78, 400.1755, 1), EPSILON, failedTests);
48  unit_assert_equal_to_stream(243.57694, slim.driftTimeToCCS(31.55, 254.0593, 1), EPSILON, failedTests);
49  unit_assert_equal_to_stream(202.32441, slim.driftTimeToCCS(26.98, 622.0291, 1), EPSILON, failedTests);
50  unit_assert_equal_to_stream(254.05743, slim.driftTimeToCCS(33.92, 609.2808, 1), EPSILON, failedTests);
51  unit_assert_equal_to_stream(172.09947, slim.driftTimeToCCS(22.38, 294.1601, 1), EPSILON, failedTests);
52  if (!failedTests.str().empty())
53  throw runtime_error(failedTests.str());
54  }
55 }
56 
57 
58 void parseArgs(const vector<string>& args, vector<string>& rawpaths)
59 {
60  for (size_t i = 1; i < args.size(); ++i)
61  {
62  if (args[i] == "-v") os_ = &cout;
63  else if (bal::starts_with(args[i], "--")) continue;
64  else rawpaths.push_back(args[i]);
65  }
66 }
67 
68 
69 int main(int argc, char* argv[])
70 {
71  TEST_PROLOG(argc, argv)
72 
73  try
74  {
75  vector<string> args(argv, argv+argc);
76  vector<string> rawpaths;
77  parseArgs(args, rawpaths);
78 
79  ExtendedReaderList readerList;
80 
81  BOOST_FOREACH(const string& filepath, rawpaths)
82  {
83  test(filepath, readerList);
84  }
85  }
86  catch (exception& e)
87  {
88  TEST_FAILED(e.what())
89  }
90  catch (...)
91  {
92  TEST_FAILED("Caught unknown exception.")
93  }
94 
96 }
SpectrumList implementation that provides access to vendor-specific ion mobility functions.
void test(const string &filepath, const ReaderList &readerList)
#define TEST_EPILOG
Definition: unit.hpp:182
Reader container (composite pattern).
Definition: Reader.hpp:134
#define unit_assert_equal_to_stream(x, y, epsilon, os)
Definition: unit.hpp:102
default ReaderList, extended to include vendor readers
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
MSData object plus file I/O.
Definition: MSDataFile.hpp:40
int main(int argc, char *argv[])
virtual double driftTimeToCCS(double driftTime, double mz, int charge) const
returns collisional cross-section associated with the drift time (specified in milliseconds) ...
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
void parseArgs(const vector< string > &args, vector< string > &rawpaths)
Definition: cv.hpp:91