29 #ifndef CDPL_CHEM_RESONANCESTRUCTUREGENERATOR_HPP
30 #define CDPL_CHEM_RESONANCESTRUCTUREGENERATOR_HPP
34 #include <unordered_set>
37 #include <boost/iterator/indirect_iterator.hpp>
71 typedef std::vector<StructureDataPtr> StructureDataList;
108 std::size_t numCharges;
256 std::size_t atom1Index;
257 std::size_t atom2Index;
258 std::size_t bondIndex;
267 bool canShiftElectrons()
const;
269 std::size_t getNumBonds()
const;
271 std::size_t getBondIndex(std::size_t list_idx)
const;
273 std::size_t getAtomIndex(std::size_t list_idx)
const;
275 std::size_t getIndex()
const;
279 double getElectronegativity()
const;
281 bool isSP1Hybridized(
const StructureData& res_struct)
const;
283 bool checkValenceState(
const StructureData& res_struct,
long val_diff,
long charge_diff)
const;
285 bool octetRuleFulfilled(
const StructureData& res_struct)
const;
287 std::size_t countRepChargePairs(
const Util::LArray& charges)
const;
289 bool getVisitedFlag()
const;
291 void setVisitedFlag();
293 bool getInSmallRingFlag()
const;
295 void setInSmallRingFlag();
298 typedef std::vector<std::size_t> IndexArray;
304 std::size_t unprdElecCount;
305 std::size_t implHCount;
307 IndexArray bondIndices;
308 IndexArray atomIndices;
313 struct StructureDataPtrHashFunc
316 std::size_t operator()(
const StructureDataPtr& rs_ptr)
const;
319 struct StructureDataPtrCmpFunc
322 bool operator()(
const StructureDataPtr& rs_ptr1,
const StructureDataPtr& rs_ptr2)
const
324 return (rs_ptr1->getBondOrders() == rs_ptr2->getBondOrders() &&
325 rs_ptr1->getAtomCharges() == rs_ptr2->getAtomCharges());
329 typedef std::vector<AtomData> AtomDataArray;
330 typedef std::vector<const AtomData*> AtomDataPtrArray;
331 typedef std::vector<BondData> BondDataList;
332 typedef std::unordered_set<StructureDataPtr, StructureDataPtrHashFunc, StructureDataPtrCmpFunc> StructureDataSet;
334 void init(
const MolecularGraph& molgraph);
336 void createInputResStructData();
338 void extractResBonds();
339 void extractResBonds(AtomData& atom_data);
341 void genStartResStructs();
342 void genStartResStructs(std::size_t depth, std::size_t num_rep_chg_pairs);
344 std::size_t countRepChargePairs()
const;
346 void genOutputResStructs();
347 void genOutputResStructs(StructureData& res_struct, std::size_t depth, std::size_t con_idx,
348 std::size_t num_charges);
350 void postprocOutputResStructs();
352 void minimzeResStructProperty(std::size_t (ResonanceStructureGenerator::*prop_func)(
const StructureData&)
const);
354 std::size_t countOctetRuleViolations(
const StructureData& res_struct)
const;
355 std::size_t countSP1GeometryViolations(
const StructureData& res_struct)
const;
356 std::size_t count12ChargedCBonds(
const StructureData& res_struct)
const;
358 void modifyResStruct(StructureData& res_struct, std::size_t bond_idx, std::size_t atom1_idx, std::size_t atom2_idx,
359 long bond_order_diff,
long atom1_chg_diff,
long atom2_chg_diff)
const;
361 StructureDataPtr copyResStructPtr(
const StructureDataPtr& res_struct_ptr);
362 StructureDataPtr copyResStruct(
const StructureData& res_struct);
364 StructureDataCache resStructDataCache;
365 bool minOctRuleViolations;
366 bool minSP1GeomViolations;
367 bool minCBond12Charges;
368 std::size_t chargeCountWin;
370 std::size_t maxNumGenStructs;
371 const MolecularGraph* molGraph;
372 AtomDataArray atomData;
373 AtomDataPtrArray resAtoms;
374 BondDataList resBonds;
375 StructureData inputResStruct;
376 StructureDataList startResStructs;
377 StructureDataSet workingResStructs;
378 StructureDataList outputResStructs;
379 StructureDataList tmpOutputResStructs;
382 std::size_t minNumRepChargePairs;
383 std::size_t minNumCharges;
Definition of class CDPL::Util::Array.
Declaration of 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 class CDPL::Util::ObjectPool.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:58
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
Data structure storing formal atom charges and bond orders that define a single resonance structure.
Definition: ResonanceStructureGenerator.hpp:88
const Util::LArray & getAtomCharges() const
Returns the formal atom charges of this resonance structure.
const Util::STArray & getBondOrders() const
Returns the bond orders of this resonance structure.
Enumerates the resonance structures of a molecular graph by redistributing π-electrons across conjuga...
Definition: ResonanceStructureGenerator.hpp:63
std::shared_ptr< ResonanceStructureGenerator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated ResonanceStructureGenerator insta...
Definition: ResonanceStructureGenerator.hpp:77
ConstStructureDataIterator begin() const
Returns a constant iterator pointing to the beginning of the generated const StructureData records.
ResonanceStructureGenerator(const ResonanceStructureGenerator &gen)
Constructs a copy of the ResonanceStructureGenerator instance gen.
void minimizeOctetRuleViolations(bool minimize)
Specifies whether resonance structures violating the octet rule shall be filtered out.
bool octetRuleViolationsMinimized() const
Tells whether octet rule violations are minimized.
Util::BitSet & getOctetRuleCheckAtomTypes()
Returns the bit mask of atom types subjected to the octet rule check during violation minimization.
void setChargeCountWindow(std::size_t win_size)
Sets the maximum allowed difference between the lowest and highest total absolute formal atom charge ...
std::size_t getMaxNumGeneratedStructures() const
Returns the upper limit on the number of resonance structures generated per molecular graph.
ConstStructureDataIterator getStructureDataEnd() const
Returns a constant iterator pointing to the end of the generated const StructureData records.
ConstStructureDataIterator end() const
Returns a constant iterator pointing to the end of the generated const StructureData records.
ResonanceStructureGenerator & operator=(const ResonanceStructureGenerator &gen)
Replaces the state of this generator by a copy of the state of gen.
const StructureData & getStructureData(std::size_t idx) const
Returns the resonance structure record at index idx.
ResonanceStructureGenerator()
Constructs the ResonanceStructureGenerator instance.
boost::indirect_iterator< StructureDataList::const_iterator, const StructureData > ConstStructureDataIterator
A constant random access iterator used to iterate over the generated const StructureData records.
Definition: ResonanceStructureGenerator.hpp:82
bool sp1GeometryViolationsMinimized() const
Tells whether sp-hybridization geometry violations are minimized.
ConstStructureDataIterator getStructureDataBegin() const
Returns a constant iterator pointing to the beginning of the generated const StructureData records.
const Util::BitSet & getOctetRuleCheckAtomTypes() const
Returns the bit mask of atom types subjected to the octet rule check during violation minimization.
void generate(const MolecularGraph &molgraph)
Generates all unique resonance structures of the molecular graph molgraph.
bool carbonBond12ChargesMinimized() const
Tells whether 1,2-charge separations on adjacent carbon atoms are minimized.
std::size_t getChargeCountWindow() const
Returns the configured total absolute formal atom charge count window size.
void minimizeCarbonBond12Charges(bool minimize)
Specifies whether resonance structures with 1,2-charge separations on adjacent carbon atoms shall be ...
virtual ~ResonanceStructureGenerator()
Virtual destructor.
Definition: ResonanceStructureGenerator.hpp:125
void setMaxNumGeneratedStructures(std::size_t max_num)
Sets the upper limit on the number of resonance structures generated per molecular graph.
void minimizeSP1GeometryViolations(bool minimize)
Specifies whether resonance structures with sp-hybridization geometry violations shall be filtered ou...
std::size_t getNumStructures() const
Returns the number of generated resonance structures.
std::shared_ptr< ObjectType > SharedObjectPointer
A smart pointer to a borrowed object that returns the object to the pool on destruction.
Definition: ObjectPool.hpp:71
CDPL_CHEM_API unsigned int getType(const Atom &atom)
Returns the value of the Chem::AtomProperty::TYPE property of the atom atom.
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:578
Array< long > LArray
Array storing integers of type long.
Definition: Array.hpp:583
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.