ProteoWizard
PeakFamilyDetectorFTTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: PeakFamilyDetectorFTTest.cpp 4129 2012-11-20 00:05:37Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2008 Spielberg Family Center for Applied Proteomics
8 // Cedars-Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #include "PeakFamilyDetectorFT.hpp"
27 
28 using namespace pwiz::util;
29 using namespace pwiz::analysis;
30 using namespace pwiz::data;
31 using namespace pwiz::data::peakdata;
32 using namespace pwiz;
33 using namespace pwiz::msdata;
34 
35 
36 ostream* os_ = 0;
37 
38 
39 extern double peakFamilyDetectorFTTestData_[];
41 
42 
43 void test()
44 {
45  // instantiate PeakFamilyDetectorFT
46 
48  config.log = os_;
49  config.cp = CalibrationParameters::thermo_FT();
50  PeakFamilyDetectorFT detector(config);
51 
52  // detect
53 
54  vector<PeakFamily> result;
55  const MZIntensityPair* begin =
56  reinterpret_cast<const MZIntensityPair*>(&peakFamilyDetectorFTTestData_[0]);
58 
59  detector.detect(begin, end, result);
60 
61  if (os_)
62  {
63  *os_ << setprecision(10) << "result: " << result.size() << endl;
64  copy(result.begin(), result.end(), ostream_iterator<PeakFamily>(*os_, "\n"));
65  }
66 
67  unit_assert(result.size() == 1);
68  unit_assert_equal(result[0].mzMonoisotopic, 810.4148, .005);
69 }
70 
71 
72 int main(int argc, char* argv[])
73 {
74  TEST_PROLOG(argc, argv)
75 
76  try
77  {
78  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
79  if (os_) *os_ << "PeakFamilyDetectorFTTest\n";
80  test();
81  }
82  catch (exception& e)
83  {
84  TEST_FAILED(e.what())
85  }
86  catch (...)
87  {
88  TEST_FAILED("Caught unknown exception.")
89  }
90 
92 }
93