File: RascalDetails.h

package info (click to toggle)
rdkit 202503.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 220,160 kB
  • sloc: cpp: 399,240; python: 77,453; ansic: 25,517; java: 8,173; javascript: 4,005; sql: 2,389; yacc: 1,565; lex: 1,263; cs: 1,081; makefile: 580; xml: 229; fortran: 183; sh: 105
file content (95 lines) | stat: -rw-r--r-- 3,537 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// Copyright (C) David Cosgrove 2023
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//

#include <RDGeneral/export.h>
#ifndef RDKIT_RASCAL_DETAILS_H
#define RDKIT_RASCAL_DETAILS_H

#include <map>

#include <GraphMol/RascalMCES/RascalOptions.h>
#include <GraphMol/RascalMCES/RascalResult.h>
namespace RDKit {
class ROMol;

namespace RascalMCES {

struct RascalClusterOptions;

namespace details {

struct ClusNode {
  std::shared_ptr<RascalResult> d_res;
  double d_sim;
  unsigned int d_mol1Num, d_mol2Num;
};

RDKIT_RASCALMCES_EXPORT double tier1Sim(
    const RDKit::ROMol &mol1, const RDKit::ROMol &mol2,
    std::map<int, std::vector<std::pair<int, int>>> &degSeqs1,
    std::map<int, std::vector<std::pair<int, int>>> &degSeqs2);

RDKIT_RASCALMCES_EXPORT double tier2Sim(
    const ROMol &mol1, const ROMol &mol2,
    const std::map<int, std::vector<std::pair<int, int>>> &degSeqs1,
    const std::map<int, std::vector<std::pair<int, int>>> &degSeqs2,
    const std::vector<unsigned int> &bondLabels1,
    const std::vector<unsigned int> &bondLabels2);

RDKIT_RASCALMCES_EXPORT void getBondLabels(
    const RDKit::ROMol &mol1, const RDKit::ROMol &mol2,
    const RascalOptions &opts, std::vector<unsigned int> &bondLabels1,
    std::vector<unsigned int> &bondLabels2);

std::vector<std::vector<ClusNode>> buildProximityGraph(
    const std::vector<std::shared_ptr<ROMol>> &mols,
    const RascalClusterOptions &clusOpts);

RDKIT_RASCALMCES_EXPORT bool resultCompare(const RascalResult &res1,
                                           const RascalResult &res2);

RDKIT_RASCALMCES_EXPORT void extractClique(
    const std::vector<unsigned int> &clique,
    const std::vector<std::pair<int, int>> &vtxPairs, bool swapped,
    std::vector<std::pair<int, int>> &bondMatches);

// do some simple cleaning of the SMARTS, to make it more user-friendly.
RDKIT_RASCALMCES_EXPORT void cleanSmarts(std::string &smarts,
                                         const std::string &equivalentAtoms);

// Primarily for debugging, these write out the corresponding bonds/atoms
// in Python list format, for ease of cut/paste into a highlighted image
// creation.
RDKIT_RASCALMCES_EXPORT void printBondMatches(const RascalResult &res,
                                              std::ostream &os);

RDKIT_RASCALMCES_EXPORT void printAtomMatches(const RascalResult &res,
                                              std::ostream &os);

// This prints out the scores in the order they are used in resultCompare.
RDKIT_RASCALMCES_EXPORT void printScores(const RascalResult &res,
                                         std::ostream &os);

// Calculate the Johnson similarity between the two molecules using the given
// bondMatches.  It's the fraction of the 2 molecules that are in common,
// somewhat akin to the tanimoto - the square of the number of atoms plus
// number of bonds in the MCES divided by the product of the sums of the number
// of atoms and bonds in the 2 molecules.
// It has nothing to do with lying UK politicians.
RDKIT_RASCALMCES_EXPORT double johnsonSimilarity(
    const std::vector<std::pair<int, int>> &bondMatches,
    const std::vector<std::pair<int, int>> &atomMatches,
    const RDKit::ROMol &mol1, const RDKit::ROMol &mol2);

}  // namespace details

}  // namespace RascalMCES
}  // namespace RDKit
#endif  // RDKIT_RASCAL_MCES_H