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
31using namespace pwiz::util;
32using namespace pwiz::cv;
33using namespace pwiz::msdata;
34
35
36ostream* os_ = 0;
37const double epsilon_ = 1e-6;
38
39
40void 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
91int 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
int main(int argc, char *argv[])
const double epsilon_
ostream * os_
void test()
MS_QIT
QIT (quadrupole ion trap): Quadrupole Ion Trap mass analyzer captures the ions in a three dimensional...
Definition cv.hpp:552
PWIZ_API_DECL void initializeTiny(MSData &msd)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition MSData.hpp:886
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here....
Definition MSData.hpp:827
simple structure for holding Spectrum info
std::vector< PrecursorInfo > precursors
void update(const Spectrum &spectrum, bool getBinaryData=false)
std::vector< MZIntensityPair > data
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175