ProteoWizard
IsotopeEnvelopeEstimatorTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2007 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
25#include "IsotopeCalculator.hpp"
28#include <cstring>
29
30
31using namespace pwiz::util;
32using namespace pwiz::chemistry;
33
34
35ostream* os_ = 0;
36
37
39{
40 try
41 {
43 IsotopeEnvelopeEstimator estimator(config);
44 }
45 catch (...)
46 {
47 if (os_) *os_ << "Null IsotopeCalculator* check ok.\n";
48 return;
49 }
50
51 throw runtime_error("Failed to check for null IsotopeCalculator*.");
52}
53
54
55void test()
56{
57 const double abundanceCutoff = .01;
58 const double massPrecision = .1;
59 IsotopeCalculator isotopeCalculator(abundanceCutoff, massPrecision);
60
62 config.isotopeCalculator = &isotopeCalculator;
63
64 IsotopeEnvelopeEstimator estimator(config);
65
66 if (os_)
67 for (int mass=100; mass<=3000; mass+=100)
68 *os_ << mass << ":\n" << estimator.isotopeEnvelope(mass) << endl;
69
70 // TODO: external verification of these estimates
71}
72
73
74int main(int argc, char* argv[])
75{
76 TEST_PROLOG(argc, argv)
77
78 try
79 {
80 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
81 if (os_) *os_ << "IsotopeEnvelopeEstimatorTest\n";
83 test();
84 }
85 catch (exception& e)
86 {
87 TEST_FAILED(e.what())
88 }
89 catch (...)
90 {
91 TEST_FAILED("Caught unknown exception.")
92 }
93
95}
96
int main(int argc, char *argv[])
void testInstantiationWithNull()
Class used for calculating a theoretical isotope envelope for a given mass, based on an estimate of t...
MassDistribution isotopeEnvelope(double mass) const
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175