ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
utility
chemistry
Chemistry.hpp
Go to the documentation of this file.
1
//
2
// $Id: Chemistry.hpp 2778 2011-06-14 16:08:39Z chambm $
3
//
4
//
5
// Original author: Darren Kessner <darren@proteowizard.org>
6
//
7
// Copyright 2006 Louis Warschaw Prostate Cancer Center
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
#ifndef _CHEMISTRY_HPP_
25
#define _CHEMISTRY_HPP_
26
27
28
#include "
pwiz/utility/misc/Export.hpp
"
29
#include <iosfwd>
30
#include <string>
31
#include <vector>
32
#include "
pwiz/utility/misc/virtual_map.hpp
"
33
#include <boost/shared_ptr.hpp>
34
35
36
namespace
pwiz {
37
namespace
chemistry {
38
39
40
/// the mass of a proton in unified atomic mass units
41
const
double
Proton
= 1.00727646688;
42
43
/// the mass of a neutron in unified atomic mass units
44
const
double
Neutron
= 1.00866491560;
45
46
/// the mass of an electron in unified atomic mass units
47
const
double
Electron
= 0.00054857991;
48
49
50
/// struct for holding isotope information
51
struct
PWIZ_API_DECL
MassAbundance
52
{
53
double
mass
;
54
double
abundance
;
55
56
MassAbundance
(
double
m = 0,
double
a = 0)
57
: mass(m), abundance(a)
58
{}
59
60
bool
operator==
(
const
MassAbundance
& that)
const
;
61
bool
operator!=
(
const
MassAbundance
& that)
const
;
62
};
63
64
65
/// struct for holding isotope distribution
66
typedef
std::vector<MassAbundance>
MassDistribution
;
67
68
69
PWIZ_API_DECL
std::ostream&
operator<<
(std::ostream& os,
const
MassAbundance
& ma);
70
PWIZ_API_DECL
std::ostream&
operator<<
(std::ostream& os,
const
MassDistribution
& md);
71
72
73
/// scope for declarations related to elements
74
namespace
Element {
75
76
77
/// enumeration of the elements
78
enum
PWIZ_API_DECL
Type
79
{
80
C
,
H
,
O
,
N
,
S
,
P
,
81
He
,
Li
,
Be
,
B
,
F
,
Ne
,
82
Na
,
Mg
,
Al
,
Si
,
Cl
,
Ar
,
K
,
Ca
,
83
Sc
,
Ti
,
V
,
Cr
,
Mn
,
Fe
,
Co
,
Ni
,
Cu
,
Zn
,
84
Ga
,
Ge
,
As
,
Se
,
Br
,
Kr
,
Rb
,
Sr
,
Y
,
Zr
,
85
Nb
,
Mo
,
Tc
,
Ru
,
Rh
,
Pd
,
Ag
,
Cd
,
In
,
Sn
,
86
Sb
,
Te
,
I
,
Xe
,
Cs
,
Ba
,
La
,
Ce
,
Pr
,
Nd
,
87
Pm
,
Sm
,
Eu
,
Gd
,
Tb
,
Dy
,
Ho
,
Er
,
Tm
,
Yb
,
88
Lu
,
Hf
,
Ta
,
W
,
Re
,
Os
,
Ir
,
Pt
,
Au
,
Hg
,
89
Tl
,
Pb
,
Bi
,
Po
,
At
,
Rn
,
Fr
,
Ra
,
Ac
,
Th
,
90
Pa
,
U
,
Np
,
Pu
,
Am
,
Cm
,
Bk
,
Cf
,
Es
,
Fm
,
91
Md
,
No
,
Lr
,
Rf
,
Db
,
Sg
,
Bh
,
Hs
,
Mt
,
Uun
,
92
Uuu
,
Uub
,
Uuq
, Uuh
93
};
94
95
96
PWIZ_API_DECL
std::ostream&
operator<<
(std::ostream& os,
Type
type);
97
98
99
/// class for obtaining information about elements
100
namespace
Info
101
{
102
103
104
struct
PWIZ_API_DECL
Record
105
{
106
Type
type
;
107
std::string
symbol
;
108
int
atomicNumber
;
109
double
atomicWeight
;
110
MassAbundance
monoisotope
;
/// the most abundant isotope
111
MassDistribution
isotopes
;
112
};
113
114
/// retrieve the record for an element
115
PWIZ_API_DECL
const
Record
&
record
(
Type
type);
116
117
/// retrieve the record for an element
118
PWIZ_API_DECL
const
Record
&
record
(
const
std::string& symbol);
119
120
121
}
// namespace Info
122
123
124
PWIZ_API_DECL
std::ostream&
operator<<
(std::ostream& os,
const
Info::Record
&
record
);
125
126
127
}
// namespace Element
128
129
130
class
CompositionMap;
131
132
/// class to represent a chemical formula
133
class
PWIZ_API_DECL
Formula
134
{
135
public
:
136
137
/// formula string given by symbol/count pairs, e.g. water: "H2 O1" (whitespace optional)
138
Formula
(
const
std::string& formula =
""
);
139
Formula
(
const
char
* formula);
140
Formula
(
const
Formula
& formula);
141
const
Formula
& operator=(
const
Formula
& formula);
142
~
Formula
();
143
144
double
monoisotopicMass()
const
;
145
double
molecularWeight()
const
;
146
std::string formula()
const
;
147
148
/// access to the Element's count in the formula
149
int
operator[](
Element::Type
e
)
const
;
150
int
& operator[](
Element::Type
e);
151
152
// direct access to the map, for iteration
153
typedef
std::map<Element::Type, int>
Map
;
154
Map
data()
const
;
155
156
// operations
157
Formula
&
operator+=
(
const
Formula
& that);
158
Formula
&
operator-=
(
const
Formula
& that);
159
Formula
&
operator*=
(
int
scalar);
160
161
/// formulas are equal iff their elemental compositions are equal
162
bool
operator==
(
const
Formula
& that)
const
;
163
bool
operator!=
(
const
Formula
& that)
const
;
164
165
private
:
166
class
Impl;
167
boost::shared_ptr<Impl>
impl_
;
168
};
169
170
171
PWIZ_API_DECL
Formula
operator+
(
const
Formula
& a,
const
Formula
& b);
172
PWIZ_API_DECL
Formula
operator-
(
const
Formula
& a,
const
Formula
& b);
173
PWIZ_API_DECL
Formula
operator*
(
const
Formula
& a,
int
scalar);
174
PWIZ_API_DECL
Formula
operator*
(
int
scalar,
const
Formula
& a);
175
176
177
/// output a Formula
178
PWIZ_API_DECL
std::ostream&
operator<<
(std::ostream& os,
const
Formula
& formula);
179
180
181
}
// namespace chemistry
182
}
// namespace pwiz
183
184
185
#endif // _CHEMISTRY_HPP_
Generated on Mon Nov 26 2012 18:05:49 for ProteoWizard by
1.8.1.1