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 
17 #include "../Descriptor.h"
18 #include "../Edge.h"
19 #include "../Node.h"
20 #include "../Sort.h"
21 #include "Pairlist.h"
22 
23 namespace RDKit {
24 namespace CIPLabeler {
25 
26 class CIPMol;
27 
28 namespace {
29 template <typename T>
30 inline int three_way_comparison(const T &x, const T &y) {
31  return x < y ? -1 : (x == y ? 0 : 1);
32 }
33 } // namespace
34 
35 class SequenceRule {
36  public:
38 
39  virtual ~SequenceRule();
40 
41  Descriptor getBondLabel(const Edge *edge) const;
42 
43  int getComparision(const Edge *a, const Edge *b) const;
44 
45  virtual int getComparision(const Edge *a, const Edge *b, bool deep) const;
46 
47  virtual const Sort *getSorter() const;
48 
49  int recursiveCompare(const Edge *a, const Edge *b) const;
50 
51  void setSorter(const Sort *sorter);
52 
53  Priority sort(const Node *node, std::vector<Edge *> &edges, bool deep) const;
54 
55  Priority sort(const Node *node, std::vector<Edge *> &edges) const;
56 
57  virtual int compare(const Edge *a, const Edge *b) const = 0;
58 
59  protected:
60  std::unique_ptr<const Sort> dp_sorter = nullptr;
61 
62  private:
63  bool areUpEdges(Node *aNode, Node *bNode, Edge *aEdge, Edge *bEdge) const;
64 };
65 
66 } // namespace CIPLabeler
67 } // 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:60
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