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
|
/****************************************************************************
* 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_pi_systems_matcher__
#define __molecule_pi_systems_matcher__
#include "base_cpp/array.h"
#include "base_cpp/reusable_obj_array.h"
#include "base_cpp/tlscont.h"
#include "base_cpp/exception.h"
#include "molecule/molecule.h"
#include "molecule/query_molecule.h"
#include "molecule/molecule_electrons_localizer.h"
#include "graph/graph_decomposer.h"
namespace indigo {
class Molecule;
class MoleculePiSystemsMatcher
{
public:
MoleculePiSystemsMatcher (Molecule &target);
bool isAtomInPiSystem (int atom);
bool isBondInPiSystem (int bond);
bool checkEmbedding (QueryMolecule &query, const int *mapping);
void copyLocalization (Molecule &target);
DECL_ERROR;
private:
// Returns number of pi-systems
int _initMarks (void);
void _markAtomsFirst ();
void _markUnstablePiSystems (Array<bool> &pi_system_used);
void _markVerticesInPiSystemsWithCycles ();
void _markVerticesInUnusedPiSystems (Array<bool> &pi_system_used);
void _markVerticesInSingleAtomPiSystem (int n_pi_systems);
void _calculatePiSystemsSizes (int n_pi_systems, Array<int> &sizes);
void _copyPiSystemsIdFromDecomposer ();
void _extractPiSystem (int pi_system_index);
void _findPiSystemLocalization (int pool_id);
bool _fixAtoms (QueryMolecule &query, const int *mapping);
bool _fixBonds (QueryMolecule &query, const int *mapping);
bool _findMatching ();
bool _findMatchingForPiSystem (int pool_id);
void _markMappedPiSystems (QueryMolecule &query, const int *mapping);
bool _canAtomBeInPiSystem (int v);
void _calcConnectivity (Molecule &mol, Array<int> &conn);
enum { _NOT_IN_PI_SYSTEM = -3, _UNKNOWN = -2, _IN_AROMATIC = -1 };
Molecule &_target;
Obj<GraphDecomposer> _decomposer;
CP_DECL;
TL_CP_DECL(Array<int>, _atom_pi_system_idx);
struct _Pi_System
{
Molecule pi_system;
Array<int> inv_mapping, mapping;
Obj<MoleculeElectronsLocalizer> localizer;
struct Localizations
{
int double_bonds, primary_lp, seconary_lp;
};
Array<Localizations> localizations;
bool pi_system_mapped;
bool initialized;
void clear ();
};
TL_CP_DECL(ReusableObjArray<_Pi_System>, _pi_systems);
TL_CP_DECL(Array<int>, _connectivity);
};
}
#endif // __molecule_pi_systems_matcher__
|