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
|
/****************************************************************************
* Copyright (C) 2009-2013 GGA Software Services LLC
*
* This file is part of Indigo toolkit.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 3 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
***************************************************************************/
#ifndef __molecule_inchi_layers_h__
#define __molecule_inchi_layers_h__
#include "base_cpp/array.h"
#include "base_cpp/exception.h"
#include "molecule/molecule_inchi_utils.h"
namespace indigo {
class Molecule;
class Output;
class MoleculeStereocenters;
// Namespace with layers
// Each layers are independent and contains all
// nessesary information
namespace MoleculeInChILayers
{
// Abtract layer
class AbstractLayer
{
public:
AbstractLayer ();
virtual ~AbstractLayer () {};
// Method for constructing internal layer information
void construct (Molecule &mol);
DECL_ERROR;
protected:
Molecule& _getMolecule ();
virtual void _construct () {};
private:
Molecule *_mol;
};
// Main layer formula
class MainLayerFormula : public AbstractLayer
{
public:
void printFormula (Array<char> &result);
static int compareComponentsAtomsCountNoH (MainLayerFormula &comp1,
MainLayerFormula &comp2);
static int compareComponentsTotalHydrogensCount (MainLayerFormula &comp1,
MainLayerFormula &comp2);
protected:
virtual void _construct ();
private:
Array<int> _atoms_count;
void _printAtom (Output &output, int label) const;
void _collectAtomsCount ();
};
// Main layer connections
class MainLayerConnections : public AbstractLayer
{
public:
void printConnectionTable (Array<char> &result);
int compareMappings (const MoleculeInChIUtils::Mapping &m1,
const MoleculeInChIUtils::Mapping &m2);
static int compareComponentsConnectionTables (MainLayerConnections &comp1,
MainLayerConnections &comp2);
protected:
virtual void _construct ();
private:
Array<int> _connection_table;
void _linearizeConnectionTable ();
};
// Layer with hydrogens
class HydrogensLayer : public AbstractLayer
{
public:
static int compareComponentsHydrogens (HydrogensLayer &comp1,
HydrogensLayer &comp2);
bool checkAutomorphism (const Array<int> &mapping);
int compareMappings (MoleculeInChIUtils::Mapping &m1,
MoleculeInChIUtils::Mapping &m2);
void print (Array<char> &result);
protected:
virtual void _construct ();
private:
// Number of immobile hydrogens for each atom
Array<int> _per_atom_immobile;
// Atom indices in the 'mol' to avoid vertexBegin/vertexEnd iterations
// when comparing components
Array<int> _atom_indices;
// TODO: Mobile hydrogens, fixed hydrogens
};
// Cis-trans stereochemistry
class CisTransStereochemistryLayer : public AbstractLayer
{
public:
void print (Array<char> &result);
bool checkAutomorphism (const Array<int> &mapping);
int compareMappings (const MoleculeInChIUtils::Mapping &m1,
const MoleculeInChIUtils::Mapping &m2);
static int compareComponents (CisTransStereochemistryLayer &comp1,
CisTransStereochemistryLayer &comp2);
protected:
virtual void _construct ();
private:
Array<int> bond_is_cis_trans;
};
// Tetrahedral stereochemistry
class TetrahedralStereochemistryLayer : public AbstractLayer
{
public:
void print (Array<char> &result);
void printEnantiomers (Array<char> &result);
bool checkAutomorphism (const Array<int> &mapping);
int compareMappings (const MoleculeInChIUtils::Mapping &m1,
const MoleculeInChIUtils::Mapping &m2);
static int compareComponentsEnantiomers (TetrahedralStereochemistryLayer &comp1,
TetrahedralStereochemistryLayer &comp2);
static int compareComponents (TetrahedralStereochemistryLayer &comp1,
TetrahedralStereochemistryLayer &comp2);
private:
int _getMappingSign (const MoleculeStereocenters &stereocenters,
const MoleculeInChIUtils::Mapping *m, int index);
int _getFirstSign ();
};
};
}
#endif // __molecule_inchi_layers_h__
|