1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
#ifndef __elements_h__
#define __elements_h__
#include "base_cpp/red_black.h"
#include "base_cpp/tlscont.h"
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4251)
#endif
namespace indigo
{
class Scanner;
enum
{
ELEM_MIN = 1,
ELEM_H = 1,
ELEM_He,
ELEM_Li,
ELEM_Be,
ELEM_B,
ELEM_C,
EL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Uut
ELEM_Fl,
ELEM_Mc, // ELEM_Uup
ELEM_Lv,
ELEM_Ts, // ELEM_Uus
ELEM_Og, // ELEM_Uuo
ELEM_MAX,
ELEM_PSEUDO, // pseudoatom
ELEM_RSITE, // 'R' atom
ELEM_TEMPLATE, // template
ELEM_ATTPOINT // attachment point
};
enum
{
RADICAL_SINGLET = 1,
RADICAL_DOUBLET = 2,
RADICAL_TRIPLET = 3
};
class DLLEXPORT Element
{
public:
DECL_ERROR;
static const char* toString(int element);
static int fromString(const char* name);
static int fromString2(const char* name);
static int fromChar(char c);
static int fromTwoChars(char c1, char c2);
static int fromTwoChars2(char c1, char c2);
static int radicalElectrons(int radical);
static int radicalOrbitals(int radical);
static bool calcValence(int elem, int charge, int radical, int conn, int& valence, int& hyd, bool to_throw);
static int calcValenceOfAromaticAtom(int elem, int charge, int n_arom, int min_conn);
static int calcValenceMinusHyd(int elem, int charge, int radical, int conn);
// Calculate maximum number of single bonds that
// can be attached to specified atom.
static int getMaximumConnectivity(int elem, int charge, int radical, bool use_d_orbital);
static int orbitals(int elem, bool use_d_orbital);
static int electrons(int elem, int charge);
static int group(int element);
static int period(int period);
static int read(Scanner& scanner);
static bool isHalogen(int element);
// Returns isotope that has weight most close to the atomic weight
static int getDefaultIsotope(int element);
// Return most abundant isotope
static int getMostAbundantIsotope(int element);
static double getRelativeIsotopicMass(int element, int isotope);
static double getStandardAtomicWeight(int element);
static bool getIsotopicComposition(int element, int isotope, double& res);
static void getMinMaxIsotopeIndex(int element, int& min, int& max);
static bool canBeAromatic(int element);
static Array<int>& tautomerHeteroatoms();
private:
Element();
static Element _instance;
void _initAllPeriodic();
void _initPeriodic(int element, const char* name, int period, int group);
void _setStandardAtomicWeightIndex(int element, int index);
void _addElementIsotope(int element, int isotope, double mass, double isotopic_composition);
void _initAllIsotopes();
void _initDefaultIsotopes();
void _initAromatic();
RedBlackStringMap<int> _map;
Array<int> _halogens;
Array<int> _tau_heteroatoms; // Appear in tautomer chains
// Per-element physical parameters
struct _Parameters
{
char name[3];
int group;
int period;
int natural_isotope_index; // Can be ElementIsotope::NATURAL or anything else
// Isotope with mass most close to the atomic weight
int default_isotope;
// Isotope with highest mole fraction
int most_abundant_isotope;
// Minimum and maximum isotope index
int min_isotope_index, max_isotope_index;
bool can_be_aromatic;
};
Array<_Parameters> _element_parameters;
// Isotopes mass key
struct DLLEXPORT _IsotopeKey
{
int element;
int isotope; // Can be equal to NATURAL
// Pseudoisotope value for weighted sum of the
// atomic masses of all the isotopes for specified element
enum
{
NATURAL = -1,
UNINITIALIZED = -2
};
_IsotopeKey(int element, int isotope);
bool operator<(const _IsotopeKey& right) const;
};
struct _IsotopeValue
{
_IsotopeValue(double mass, double isotopic_composition);
// Isotope mass
double mass;
// Mole fraction of the various isotopes
double isotopic_composition;
};
RedBlackMap<_IsotopeKey, _IsotopeValue> _isotope_parameters_map;
};
} // namespace indigo
#ifdef _WIN32
#pragma warning(pop)
#endif
#endif
|