29 #ifndef CDPL_CHEM_RESONANCESTRUCTUREGENERATOR_HPP
30 #define CDPL_CHEM_RESONANCESTRUCTUREGENERATOR_HPP
34 #include <unordered_set>
37 #include <boost/iterator/indirect_iterator.hpp>
66 typedef std::vector<StructureDataPtr> StructureDataList;
85 std::size_t numCharges;
145 std::size_t atom1Index;
146 std::size_t atom2Index;
147 std::size_t bondIndex;
156 bool canShiftElectrons()
const;
158 std::size_t getNumBonds()
const;
160 std::size_t getBondIndex(std::size_t list_idx)
const;
162 std::size_t getAtomIndex(std::size_t list_idx)
const;
164 std::size_t getIndex()
const;
168 double getElectronegativity()
const;
170 bool isSP1Hybridized(
const StructureData& res_struct)
const;
172 bool checkValenceState(
const StructureData& res_struct,
long val_diff,
long charge_diff)
const;
174 bool octetRuleFulfilled(
const StructureData& res_struct)
const;
176 std::size_t countRepChargePairs(
const Util::LArray& charges)
const;
178 bool getVisitedFlag()
const;
180 void setVisitedFlag();
182 bool getInSmallRingFlag()
const;
184 void setInSmallRingFlag();
187 typedef std::vector<std::size_t> IndexArray;
193 std::size_t unprdElecCount;
194 std::size_t implHCount;
196 IndexArray bondIndices;
197 IndexArray atomIndices;
202 struct StructureDataPtrHashFunc
205 std::size_t operator()(
const StructureDataPtr& rs_ptr)
const;
208 struct StructureDataPtrCmpFunc
211 bool operator()(
const StructureDataPtr& rs_ptr1,
const StructureDataPtr& rs_ptr2)
const
213 return (rs_ptr1->getBondOrders() == rs_ptr2->getBondOrders() &&
214 rs_ptr1->getAtomCharges() == rs_ptr2->getAtomCharges());
218 typedef std::vector<AtomData> AtomDataArray;
219 typedef std::vector<const AtomData*> AtomDataPtrArray;
220 typedef std::vector<BondData> BondDataList;
221 typedef std::unordered_set<StructureDataPtr, StructureDataPtrHashFunc, StructureDataPtrCmpFunc> StructureDataSet;
223 void init(
const MolecularGraph& molgraph);
225 void createInputResStructData();
227 void extractResBonds();
228 void extractResBonds(AtomData& atom_data);
230 void genStartResStructs();
231 void genStartResStructs(std::size_t depth, std::size_t num_rep_chg_pairs);
233 std::size_t countRepChargePairs()
const;
235 void genOutputResStructs();
236 void genOutputResStructs(StructureData& res_struct, std::size_t depth, std::size_t con_idx,
237 std::size_t num_charges);
239 void postprocOutputResStructs();
241 void minimzeResStructProperty(std::size_t (ResonanceStructureGenerator::*prop_func)(
const StructureData&)
const);
243 std::size_t countOctetRuleViolations(
const StructureData& res_struct)
const;
244 std::size_t countSP1GeometryViolations(
const StructureData& res_struct)
const;
245 std::size_t count12ChargedCBonds(
const StructureData& res_struct)
const;
247 void modifyResStruct(StructureData& res_struct, std::size_t bond_idx, std::size_t atom1_idx, std::size_t atom2_idx,
248 long bond_order_diff,
long atom1_chg_diff,
long atom2_chg_diff)
const;
250 StructureDataPtr copyResStructPtr(
const StructureDataPtr& res_struct_ptr);
251 StructureDataPtr copyResStruct(
const StructureData& res_struct);
253 StructureDataCache resStructDataCache;
254 bool minOctRuleViolations;
255 bool minSP1GeomViolations;
256 bool minCBond12Charges;
257 std::size_t chargeCountWin;
259 std::size_t maxNumGenStructs;
260 const MolecularGraph* molGraph;
261 AtomDataArray atomData;
262 AtomDataPtrArray resAtoms;
263 BondDataList resBonds;
264 StructureData inputResStruct;
265 StructureDataList startResStructs;
266 StructureDataSet workingResStructs;
267 StructureDataList outputResStructs;
268 StructureDataList tmpOutputResStructs;
271 std::size_t minNumRepChargePairs;
272 std::size_t minNumCharges;
277 #endif // CDPL_CHEM_RESONANCESTRUCTUREGENERATOR_HPP