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;
Definition of the class CDPL::Util::Array.
Definition of the type CDPL::Util::BitSet.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Util::ObjectPool.
Atom.
Definition: Atom.hpp:52
MolecularGraph.
Definition: MolecularGraph.hpp:52
Definition: ResonanceStructureGenerator.hpp:73
const Util::LArray & getAtomCharges() const
const Util::STArray & getBondOrders() const
ResonanceStructureGenerator.
Definition: ResonanceStructureGenerator.hpp:58
std::shared_ptr< ResonanceStructureGenerator > SharedPointer
Definition: ResonanceStructureGenerator.hpp:69
ConstStructureDataIterator begin() const
ResonanceStructureGenerator(const ResonanceStructureGenerator &gen)
void minimizeOctetRuleViolations(bool minimize)
bool octetRuleViolationsMinimized() const
Util::BitSet & getOctetRuleCheckAtomTypes()
void setChargeCountWindow(std::size_t win_size)
std::size_t getMaxNumGeneratedStructures() const
ConstStructureDataIterator getStructureDataEnd() const
ConstStructureDataIterator end() const
ResonanceStructureGenerator & operator=(const ResonanceStructureGenerator &gen)
const StructureData & getStructureData(std::size_t idx) const
ResonanceStructureGenerator()
Constructs the ResonanceStructureGenerator instance.
boost::indirect_iterator< StructureDataList::const_iterator, const StructureData > ConstStructureDataIterator
Definition: ResonanceStructureGenerator.hpp:70
bool sp1GeometryViolationsMinimized() const
ConstStructureDataIterator getStructureDataBegin() const
const Util::BitSet & getOctetRuleCheckAtomTypes() const
void generate(const MolecularGraph &molgraph)
Generates all unique resonanceStructures of the molecular graph molgraph.
bool carbonBond12ChargesMinimized() const
std::size_t getChargeCountWindow() const
void minimizeCarbonBond12Charges(bool minimize)
virtual ~ResonanceStructureGenerator()
Definition: ResonanceStructureGenerator.hpp:95
void setMaxNumGeneratedStructures(std::size_t max_num)
void minimizeSP1GeometryViolations(bool minimize)
std::size_t getNumStructures() const
std::shared_ptr< ObjectType > SharedObjectPointer
Definition: ObjectPool.hpp:65
CDPL_CHEM_API unsigned int getType(const Atom &atom)
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
Array< long > LArray
An array of unsigned integers of type long.
Definition: Array.hpp:572
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.