11 #ifndef _RESONANCE_H__
12 #define _RESONANCE_H__
17 #include <boost/unordered_map.hpp>
27 typedef std::map<unsigned int, BondElectrons *>
ConjBondMap;
29 typedef std::vector<ConjElectrons *>
CEVect;
31 typedef std::vector<std::uint8_t>
ConjFP;
32 typedef boost::unordered_map<std::size_t, ConjElectrons *>
CEMap;
38 ALLOW_INCOMPLETE_OCTETS = (1 << 0),
41 ALLOW_CHARGE_SEPARATION = (1 << 1),
44 KEKULE_ALL = (1 << 2),
49 UNCONSTRAINED_CATIONS = (1 << 3),
53 UNCONSTRAINED_ANIONS = (1 << 4)
70 unsigned int maxStructs = 1000);
77 unsigned int flags()
const {
return d_flags; }
83 int getBondConjGrpIdx(
unsigned int bi)
const;
86 int getAtomConjGrpIdx(
unsigned int ai)
const;
92 void setNumThreads(
int numThreads = 1);
102 unsigned int length();
113 void moveTo(
unsigned int idx);
121 ROMol *operator[](
unsigned int idx);
124 typedef struct CEPerm {
126 std::vector<unsigned int> v;
128 unsigned int d_nConjGrp;
129 unsigned int d_length;
130 unsigned int d_flags;
131 unsigned int d_maxStructs;
133 unsigned int d_numThreads;
136 void buildCEMap(
CEMap &ceMap,
unsigned int conjGrpIdx);
138 std::vector<int> d_bondConjGrpIdx;
139 std::vector<int> d_atomConjGrpIdx;
140 std::vector<unsigned int> d_enumIdx;
142 ResonanceMolSupplier(
const ResonanceMolSupplier &);
143 ResonanceMolSupplier &operator=(
const ResonanceMolSupplier &);
144 void mainLoop(
unsigned int ti,
unsigned int nt);
145 void assignConjGrpIdx();
148 void prepEnumIdxVect();
149 void idxToCEPerm(
unsigned int idx, std::vector<unsigned int> &c)
const;
150 void setResonanceMolSupplierLength();
151 void storeCEMap(
CEMap &ceMap,
unsigned int conjGrpIdx);
152 void enumerateNbArrangements(
CEMap &ceMap,
CEMap &ceMapTmp);
153 void pruneStructures(
CEMap &ceMap);
154 void assignBondsFormalChargesHelper(ROMol &mol,
155 std::vector<unsigned int> &c)
const;
156 ROMol *assignBondsFormalCharges(std::vector<unsigned int> &c)
const;
157 static bool cePermCompare(
const CEPerm *a,
const CEPerm *b);