ProteoWizard
SpectrumInfoTest.cpp
Go to the documentation of this file.
1 //
2 // $Id$
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 "SpectrumInfo.hpp"
28 #include <cstring>
29 
30 
31 using namespace pwiz::util;
32 using namespace pwiz::cv;
33 using namespace pwiz::msdata;
34 
35 
36 ostream* os_ = 0;
37 const double epsilon_ = 1e-6;
38 
39 
40 void test()
41 {
42  if (os_) *os_ << "test()\n";
43 
44  MSData tiny;
46 
47  SpectrumInfo info;
48  info.update(*tiny.run.spectrumListPtr->spectrum(0));
49 
50  unit_assert(info.index == 0);
51  unit_assert(info.id == "scan=19");
52  unit_assert(info.scanNumber == 19);
54  unit_assert(info.msLevel == 1);
56  unit_assert_equal(info.mzLow, 400.39, epsilon_);
57  unit_assert_equal(info.mzHigh, 1795.56, epsilon_);
58  unit_assert(info.precursors.empty());
59 
60  info.update(*tiny.run.spectrumListPtr->spectrum(0), true);
61  unit_assert(info.data.size() == 15);
62 
63  info.update(*tiny.run.spectrumListPtr->spectrum(0), false);
64  unit_assert(info.data.size() == 0);
65  unit_assert(info.data.capacity() == 0);
66 
67  info.update(*tiny.run.spectrumListPtr->spectrum(1), true);
68  unit_assert(info.index == 1);
69  unit_assert(info.id == "scan=20");
70  unit_assert(info.scanNumber == 20);
72  unit_assert(info.msLevel == 2);
74  unit_assert_equal(info.mzLow, 320.39, epsilon_);
75  unit_assert_equal(info.mzHigh, 1003.56, epsilon_);
76  unit_assert(info.precursors.size() == 1);
77  unit_assert(info.precursors[0].index == 0);
78  unit_assert_equal(info.precursors[0].mz, 445.34, epsilon_);
79  unit_assert_equal(info.precursors[0].intensity, 120053, epsilon_);
80  unit_assert(info.precursors[0].charge == 2);
81  unit_assert(info.data.size() == 10);
82 
83  info.clearBinaryData();
84  unit_assert(info.data.size() == 0);
85  unit_assert(info.data.capacity() == 0);
86 
87  if (os_) *os_ << "ok\n";
88 }
89 
90 
91 int main(int argc, char* argv[])
92 {
93  TEST_PROLOG(argc, argv)
94 
95  try
96  {
97  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
98  test();
99  }
100  catch (exception& e)
101  {
102  TEST_FAILED(e.what())
103  }
104  catch (...)
105  {
106  TEST_FAILED("Caught unknown exception.")
107  }
108 
110 }
111 
pwiz::msdata::SpectrumInfo
simple structure for holding Spectrum info
Definition: SpectrumInfo.hpp:37
examples.hpp
unit_assert_equal
#define unit_assert_equal(x, y, epsilon)
Definition: unit.hpp:99
pwiz::cv
Definition: cv.hpp:108
MS_QIT
MS_QIT
QIT (quadrupole ion trap): Quadrupole Ion Trap mass analyzer captures the ions in a three dimensional...
Definition: cv.hpp:552
test
void test()
Definition: SpectrumInfoTest.cpp:40
pwiz::msdata::SpectrumInfo::massAnalyzerType
CVID massAnalyzerType
Definition: SpectrumInfo.hpp:53
pwiz::msdata::SpectrumInfo::index
size_t index
Definition: SpectrumInfo.hpp:50
pwiz::msdata::MSData::run
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition: MSData.hpp:886
pwiz::msdata::SpectrumInfo::msLevel
int msLevel
Definition: SpectrumInfo.hpp:55
pwiz::msdata
Definition: DemuxTypes.hpp:27
main
int main(int argc, char *argv[])
Definition: SpectrumInfoTest.cpp:91
pwiz::msdata::SpectrumInfo::retentionTime
double retentionTime
Definition: SpectrumInfo.hpp:57
pwiz::msdata::SpectrumInfo::id
std::string id
Definition: SpectrumInfo.hpp:51
pwiz::msdata::SpectrumInfo::clearBinaryData
void clearBinaryData()
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
SpectrumInfo.hpp
Std.hpp
pwiz::msdata::SpectrumInfo::mzLow
double mzLow
Definition: SpectrumInfo.hpp:59
pwiz::identdata::examples::initializeTiny
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
pwiz::msdata::SpectrumInfo::scanNumber
int scanNumber
Definition: SpectrumInfo.hpp:52
os_
ostream * os_
Definition: SpectrumInfoTest.cpp:36
pwiz::msdata::Run::spectrumListPtr
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here....
Definition: MSData.hpp:827
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
epsilon_
const double epsilon_
Definition: SpectrumInfoTest.cpp:37
pwiz::msdata::SpectrumInfo::precursors
std::vector< PrecursorInfo > precursors
Definition: SpectrumInfo.hpp:66
pwiz::msdata::MSData
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:849
pwiz::msdata::SpectrumInfo::mzHigh
double mzHigh
Definition: SpectrumInfo.hpp:60
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
pwiz::msdata::SpectrumInfo::data
std::vector< MZIntensityPair > data
Definition: SpectrumInfo.hpp:68
pwiz::msdata::SpectrumInfo::update
void update(const Spectrum &spectrum, bool getBinaryData=false)