RDKit
Open-source cheminformatics and machine learning.
SequenceRule.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright (C) 2020 Schrödinger, LLC
4 //
5 // @@ All Rights Reserved @@
6 // This file is part of the RDKit.
7 // The contents are covered by the terms of the BSD license
8 // which is included in the file license.txt, found at the root
9 // of the RDKit source tree.
10 //
11 #pragma once
12 
13 #include <stdexcept>
14 #include <memory>
15 #include <vector>
16 #include "../CIPLabeler.h"
17 
18 #include "../Descriptor.h"
19 #include "../Edge.h"
20 #include "../Node.h"
21 #include "../Sort.h"
22 #include "Pairlist.h"
23 
24 namespace RDKit {
25 namespace CIPLabeler {
26 
27 class CIPMol;
28 
29 namespace {
30 template <typename T>
31 inline int three_way_comparison(const T &x, const T &y) {
32  return x < y ? -1 : (x == y ? 0 : 1);
33 }
34 } // namespace
35 
36 class SequenceRule {
37  public:
39 
40  virtual ~SequenceRule();
41 
42  Descriptor getBondLabel(const Edge *edge) const;
43 
44  int getComparision(const Edge *a, const Edge *b) const;
45 
46  virtual int getComparision(const Edge *a, const Edge *b, bool deep) const;
47 
48  virtual const Sort *getSorter() const;
49 
50  int recursiveCompare(const Edge *a, const Edge *b) const;
51 
52  void setSorter(const Sort *sorter);
53 
54  Priority sort(const Node *node, std::vector<Edge *> &edges, bool deep) const;
55 
56  Priority sort(const Node *node, std::vector<Edge *> &edges) const;
57 
58  virtual int compare(const Edge *a, const Edge *b) const = 0;
59 
60  protected:
61  std::unique_ptr<const Sort> dp_sorter = nullptr;
62 
63  private:
64  bool areUpEdges(Node *aNode, Node *bNode, Edge *aEdge, Edge *bEdge) const;
65 };
66 
67 } // namespace CIPLabeler
68 } // namespace RDKit
int recursiveCompare(const Edge *a, const Edge *b) const
int getComparision(const Edge *a, const Edge *b) const
Descriptor getBondLabel(const Edge *edge) const
virtual int getComparision(const Edge *a, const Edge *b, bool deep) const
std::unique_ptr< const Sort > dp_sorter
Definition: SequenceRule.h:61
virtual int compare(const Edge *a, const Edge *b) const =0
Priority sort(const Node *node, std::vector< Edge * > &edges, bool deep) const
Priority sort(const Node *node, std::vector< Edge * > &edges) const
void setSorter(const Sort *sorter)
virtual const Sort * getSorter() const
Std stuff.
Definition: Abbreviations.h:19