33 #ifndef CDPL_CHEM_CANONICALNUMBERINGCALCULATOR_HPP
34 #define CDPL_CHEM_CANONICALNUMBERINGCALCULATOR_HPP
79 static constexpr
unsigned int DEF_ATOM_PROPERTY_FLAGS =
87 static constexpr
unsigned int DEF_BOND_PROPERTY_FLAGS =
189 typedef std::vector<Edge*> EdgeList;
191 typedef std::vector<std::uint64_t> ConnectionTable;
199 void processNewSolution();
201 int testNewSolution();
203 void buildConnectionTable(ConnectionTable& ctab)
const;
204 void appendAtomConfigs(ConnectionTable& ctab);
205 void appendBondConfigs(ConnectionTable& ctab);
212 AtomNode* allocNode(
Calculator* calculator,
const Atom* atom, std::uint64_t label, std::size_t
id);
214 Edge* allocEdge(
const Calculator* calculator,
const Bond* bond, std::uint64_t label,
215 AtomNode* nbr_node, std::size_t
id);
221 typedef EdgeList::const_iterator EdgeIterator;
225 void init(
Calculator* calculator,
const Atom* atom, std::uint64_t label, std::size_t
id);
227 const Atom* getAtom()
const;
229 void addEdge(Edge* edge);
231 std::uint64_t getLabel()
const;
233 void setLabel(std::uint64_t label);
234 void setNewLabel(std::size_t label);
238 std::size_t getID()
const;
242 std::size_t getNumEdges()
const;
244 EdgeIterator getEdgesBegin()
const;
245 EdgeIterator getEdgesEnd()
const;
247 void appendConnectivityData(ConnectionTable& ctab)
const;
248 void appendBondConfigData(ConnectionTable& ctab)
const;
249 void appendAtomConfigData(ConnectionTable& ctab);
251 bool involvedInStereocenter();
253 bool isEquivalent(
const AtomNode* node)
const;
254 bool isNonEquivalent(
const AtomNode* node)
const;
256 void addToEquivalenceSet(
const AtomNode* node);
257 void addToNonEquivalenceSet(
const AtomNode* node);
259 static bool terminalAndOnCommonNonStereoNode(
const AtomNode* node1,
const AtomNode* node2);
268 bool initConfigurationData();
272 std::uint64_t initialLabel;
274 std::size_t newLabel;
279 bool hasConfiguration;
280 bool configDataValid;
281 bool partOfStereocenter;
282 bool partOfStereocenterValid;
291 void init(
const Calculator* calculator,
const Bond* bond, std::uint64_t label,
292 AtomNode* nbr_node, std::size_t
id);
294 void appendBondData(ConnectionTable&)
const;
295 void appendConfigurationData(
const AtomNode* node, ConnectionTable& ctab);
297 AtomNode* getNeighborNode()
const;
299 bool representsStereoBond(
const AtomNode* node);
301 std::size_t getID()
const;
310 bool initConfigurationData(
const AtomNode* node);
318 bool hasConfiguration;
319 bool configDataValid;
322 typedef std::pair<const Fragment*, const ConnectionTable*> CanonComponentInfo;
324 struct ComponentCmpFunc
327 bool operator()(
const CanonComponentInfo&,
const CanonComponentInfo&)
const;
330 typedef std::pair<AtomNode*, std::uint64_t> NodeLabelingState;
331 typedef std::vector<NodeLabelingState> NodeLabelingStack;
332 typedef std::vector<AtomNode*> NodeList;
333 typedef std::vector<ConnectionTable> ConnectionTableList;
334 typedef std::vector<CanonComponentInfo> CanonComponentList;
340 unsigned int atomPropertyFlags;
341 unsigned int bondPropertyFlags;
342 HydrogenCountFunction hCountFunc;
343 bool foundStereogenicAtoms;
344 bool foundStereogenicBonds;
349 NodeList equivNodeStack;
350 NodeLabelingStack nodeLabelingStack;
351 ConnectionTableList compConnectionTables;
352 ConnectionTableList levelConnectionTables;
353 ConnectionTable testConnectionTable;
354 NodeList minNodeList;
355 CanonComponentList canonComponentList;
Definition of class CDPL::Util::Array.
Declaration of type CDPL::Util::BitSet.
Definition of constants in namespace CDPL::Chem::BondPropertyFlag.
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 constants in namespace CDPL::Chem::AtomPropertyFlag.
Definition of class CDPL::Util::ObjectStack.
Definition of the type CDPL::Chem::StereoDescriptor.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Calculation of canonical atom numberings for molecular graphs using McKay's algorithm.
Definition: CanonicalNumberingCalculator.hpp:72
void setHydrogenCountFunction(const HydrogenCountFunction &func)
Specifies a function for the retrieval of the hydrogen count of an atom.
void setAtomPropertyFlags(unsigned int flags)
Allows to specify the set of atomic properties that has to be considered by the canonical numering al...
const HydrogenCountFunction & getHydrogenCountFunction()
Returns the function used for the retrieval of the hydrogen count of an atom.
unsigned int getBondPropertyFlags() const
Returns the set of bond properties that gets considered by the canonical numbering algorithm.
unsigned int getAtomPropertyFlags() const
Returns the set of atomic properties that gets considered by the canonical numbering algorithm.
std::function< std::size_t(const Atom &, const MolecularGraph &)> HydrogenCountFunction
Type of the generic functor used to retrieve the (implicit + explicit) hydrogen count of an atom.
Definition: CanonicalNumberingCalculator.hpp:93
CanonicalNumberingCalculator & operator=(const CanonicalNumberingCalculator &)=delete
CanonicalNumberingCalculator()
Constructs the CanonicalNumberingCalculator instance.
CanonicalNumberingCalculator(const CanonicalNumberingCalculator &)=delete
CanonicalNumberingCalculator(const MolecularGraph &molgraph, Util::STArray &numbering)
Constructs the CanonicalNumberingCalculator instance and performs a canonical numbering of the atoms ...
void calculate(const MolecularGraph &molgraph, Util::STArray &numbering)
Performs a canonical numbering of the atoms in the molecular graph molgraph.
void setBondPropertyFlags(unsigned int flags)
Allows to specify the set of bond properties that has to be considered by the canonical numering algo...
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Data structure for the storage and retrieval of stereochemical information about atoms and bonds.
Definition: StereoDescriptor.hpp:102
constexpr unsigned int FORMAL_CHARGE
Specifies the formal charge of an atom.
Definition: Chem/AtomPropertyFlag.hpp:73
constexpr unsigned int H_COUNT
Specifies the hydrogen count of an atom.
Definition: Chem/AtomPropertyFlag.hpp:78
constexpr unsigned int AROMATICITY
Specifies the membership of an atom in aromatic rings.
Definition: Chem/AtomPropertyFlag.hpp:93
constexpr unsigned int ISOTOPE
Specifies the isotopic mass of an atom.
Definition: Chem/AtomPropertyFlag.hpp:68
constexpr unsigned int CONFIGURATION
Specifies the configuration of a stereogenic atom.
Definition: Chem/AtomPropertyFlag.hpp:98
constexpr unsigned int TYPE
Specifies the generic type or element of an atom.
Definition: Chem/AtomPropertyFlag.hpp:63
constexpr unsigned int AROMATICITY
Specifies the membership of a bond in aromatic rings.
Definition: BondPropertyFlag.hpp:73
constexpr unsigned int ORDER
Specifies the order of a bond.
Definition: BondPropertyFlag.hpp:63
constexpr unsigned int CONFIGURATION
Specifies the steric configuration of a double bond.
Definition: BondPropertyFlag.hpp:78
CDPL_CHEM_API void canonicalize(MolecularGraph &molgraph, const AtomCompareFunction &func, bool atoms=true, bool atom_nbrs=true, bool bonds=true, bool bond_atoms=false)
Reorders the atoms (and optionally their neighbors and bonds) of molgraph according to a user-supplie...
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:575
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.
Definition: CanonicalNumberingCalculator.hpp:262
bool operator()(const AtomNode *, const AtomNode *) const
Definition: CanonicalNumberingCalculator.hpp:304
bool operator()(const Edge *, const Edge *) const