29 #ifndef CDPL_CHEM_CANONICALNUMBERINGCALCULATOR_HPP
30 #define CDPL_CHEM_CANONICALNUMBERINGCALCULATOR_HPP
75 static constexpr
unsigned int DEF_ATOM_PROPERTY_FLAGS =
83 static constexpr
unsigned int DEF_BOND_PROPERTY_FLAGS =
190 typedef std::vector<Edge*> EdgeList;
192 typedef std::vector<std::uint64_t> ConnectionTable;
200 void processNewSolution();
202 int testNewSolution();
204 void buildConnectionTable(ConnectionTable& ctab)
const;
205 void appendAtomConfigs(ConnectionTable& ctab);
206 void appendBondConfigs(ConnectionTable& ctab);
213 AtomNode* allocNode(
Calculator* calculator,
const Atom* atom, std::uint64_t label, std::size_t
id);
215 Edge* allocEdge(
const Calculator* calculator,
const Bond* bond, std::uint64_t label,
216 AtomNode* nbr_node, std::size_t
id);
222 typedef EdgeList::const_iterator EdgeIterator;
226 void init(
Calculator* calculator,
const Atom* atom, std::uint64_t label, std::size_t
id);
228 const Atom* getAtom()
const;
230 void addEdge(Edge* edge);
232 std::uint64_t getLabel()
const;
234 void setLabel(std::uint64_t label);
235 void setNewLabel(std::size_t label);
239 std::size_t getID()
const;
243 std::size_t getNumEdges()
const;
245 EdgeIterator getEdgesBegin()
const;
246 EdgeIterator getEdgesEnd()
const;
248 void appendConnectivityData(ConnectionTable& ctab)
const;
249 void appendBondConfigData(ConnectionTable& ctab)
const;
250 void appendAtomConfigData(ConnectionTable& ctab);
252 bool involvedInStereocenter();
254 bool isEquivalent(
const AtomNode* node)
const;
255 bool isNonEquivalent(
const AtomNode* node)
const;
257 void addToEquivalenceSet(
const AtomNode* node);
258 void addToNonEquivalenceSet(
const AtomNode* node);
260 static bool terminalAndOnCommonNonStereoNode(
const AtomNode* node1,
const AtomNode* node2);
269 bool initConfigurationData();
273 std::uint64_t initialLabel;
275 std::size_t newLabel;
280 bool hasConfiguration;
281 bool configDataValid;
282 bool partOfStereocenter;
283 bool partOfStereocenterValid;
292 void init(
const Calculator* calculator,
const Bond* bond, std::uint64_t label,
293 AtomNode* nbr_node, std::size_t
id);
295 void appendBondData(ConnectionTable&)
const;
296 void appendConfigurationData(
const AtomNode* node, ConnectionTable& ctab);
298 AtomNode* getNeighborNode()
const;
300 bool representsStereoBond(
const AtomNode* node);
302 std::size_t getID()
const;
311 bool initConfigurationData(
const AtomNode* node);
319 bool hasConfiguration;
320 bool configDataValid;
323 typedef std::pair<const Fragment*, const ConnectionTable*> CanonComponentInfo;
325 struct ComponentCmpFunc
328 bool operator()(
const CanonComponentInfo&,
const CanonComponentInfo&)
const;
331 typedef std::pair<AtomNode*, std::uint64_t> NodeLabelingState;
332 typedef std::vector<NodeLabelingState> NodeLabelingStack;
333 typedef std::vector<AtomNode*> NodeList;
334 typedef std::vector<ConnectionTable> ConnectionTableList;
335 typedef std::vector<CanonComponentInfo> CanonComponentList;
341 unsigned int atomPropertyFlags;
342 unsigned int bondPropertyFlags;
343 HydrogenCountFunction hCountFunc;
344 bool foundStereogenicAtoms;
345 bool foundStereogenicBonds;
350 NodeList equivNodeStack;
351 NodeLabelingStack nodeLabelingStack;
352 ConnectionTableList compConnectionTables;
353 ConnectionTableList levelConnectionTables;
354 ConnectionTable testConnectionTable;
355 NodeList minNodeList;
356 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:58
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
Computes canonical atom numberings for molecular graphs using McKay's algorithm.
Definition: CanonicalNumberingCalculator.hpp:68
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 class used to store user-defined functions or function objects for the re...
Definition: CanonicalNumberingCalculator.hpp:90
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 data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
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 the molecular graph molgraph accordi...
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:578
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.
Definition: CanonicalNumberingCalculator.hpp:263
bool operator()(const AtomNode *, const AtomNode *) const
Definition: CanonicalNumberingCalculator.hpp:305
bool operator()(const Edge *, const Edge *) const