ProteoWizard
pwiz
utility
chemistry
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
24
#include "
IsotopeEnvelopeEstimator.hpp
"
25
#include "
IsotopeCalculator.hpp
"
26
#include "
pwiz/utility/misc/unit.hpp
"
27
#include "
pwiz/utility/misc/Std.hpp
"
28
#include <cstring>
29
30
31
using namespace
pwiz::util
;
32
using namespace
pwiz::chemistry
;
33
34
35
ostream*
os_
= 0;
36
37
38
void
testInstantiationWithNull
()
39
{
40
try
41
{
42
IsotopeEnvelopeEstimator::Config
config;
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
55
void
test
()
56
{
57
const
double
abundanceCutoff = .01;
58
const
double
massPrecision = .1;
59
IsotopeCalculator
isotopeCalculator(abundanceCutoff, massPrecision);
60
61
IsotopeEnvelopeEstimator::Config
config;
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
74
int
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"
;
82
testInstantiationWithNull
();
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
94
TEST_EPILOG
95
}
96
pwiz::chemistry::IsotopeEnvelopeEstimator::isotopeEnvelope
MassDistribution isotopeEnvelope(double mass) const
os_
ostream * os_
Definition:
IsotopeEnvelopeEstimatorTest.cpp:35
testInstantiationWithNull
void testInstantiationWithNull()
Definition:
IsotopeEnvelopeEstimatorTest.cpp:38
pwiz::chemistry::IsotopeEnvelopeEstimator
Class used for calculating a theoretical isotope envelope for a given mass, based on an estimate of t...
Definition:
IsotopeEnvelopeEstimator.hpp:43
main
int main(int argc, char *argv[])
Definition:
IsotopeEnvelopeEstimatorTest.cpp:74
test
void test()
Definition:
IsotopeEnvelopeEstimatorTest.cpp:55
pwiz::util
Definition:
almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition:
unit.hpp:183
pwiz::chemistry::IsotopeCalculator
Definition:
IsotopeCalculator.hpp:38
Std.hpp
pwiz::chemistry::IsotopeEnvelopeEstimator::Config::isotopeCalculator
const IsotopeCalculator * isotopeCalculator
Definition:
IsotopeEnvelopeEstimator.hpp:54
pwiz::chemistry
Definition:
Chemistry.hpp:37
TEST_FAILED
#define TEST_FAILED(x)
Definition:
unit.hpp:177
pwiz::chemistry::IsotopeEnvelopeEstimator::Config
Definition:
IsotopeEnvelopeEstimator.hpp:47
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition:
unit.hpp:175
IsotopeCalculator.hpp
unit.hpp
IsotopeEnvelopeEstimator.hpp
Generated by
1.8.18