RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
TargetMatch.h
Go to the documentation of this file.
1//
2// Copyright (C) 2014 Novartis Institutes for BioMedical Research
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#pragma once
12#include <vector>
13#include <boost/dynamic_bitset.hpp>
14#include "FMCS.h"
15#include "MatchTable.h"
16
17namespace RDKit {
18namespace FMCS {
20 bool Empty{true};
21 size_t MatchedAtomSize{0};
22 size_t MatchedBondSize{0};
23 std::vector<unsigned int> TargetAtomIdx;
24 std::vector<unsigned int> TargetBondIdx;
25 boost::dynamic_bitset<> VisitedTargetBonds;
26 boost::dynamic_bitset<> VisitedTargetAtoms; // for checking rings
27 public:
29 TargetMatch(const TargetMatch& src) { *this = src; }
31 Empty = src.Empty;
32 if (!Empty) {
33 MatchedAtomSize = src.MatchedAtomSize;
34 MatchedBondSize = src.MatchedBondSize;
35 TargetAtomIdx = src.TargetAtomIdx;
36 TargetBondIdx = src.TargetBondIdx;
37 VisitedTargetBonds = src.VisitedTargetBonds;
38 VisitedTargetAtoms = src.VisitedTargetAtoms;
39 }
40 return *this;
41 }
42 bool empty() const { return Empty; }
43 void clear() {
44 Empty = true;
45
46 TargetAtomIdx.clear();
47 TargetBondIdx.clear();
48 VisitedTargetBonds.clear();
49 VisitedTargetAtoms.clear();
50 }
51 void init(const Seed& seed, const match_V_t& match, const ROMol& query,
52 const Target& target) {
53 TargetAtomIdx.clear();
54 TargetAtomIdx.resize(query.getNumAtoms(), NotSet);
55 TargetBondIdx.clear();
56 TargetBondIdx.resize(query.getNumBonds(), NotSet);
57 VisitedTargetBonds.resize(target.Molecule->getNumBonds());
58 VisitedTargetAtoms.resize(target.Molecule->getNumAtoms());
59 VisitedTargetBonds.reset();
60 VisitedTargetAtoms.reset();
61
62 MatchedAtomSize = match.size();
63 for (const auto& m : match) {
64 TargetAtomIdx[seed.MoleculeFragment.Atoms.at(m.first)->getIdx()] =
65 m.second;
66 VisitedTargetAtoms.set(m.second);
67 }
68
70 for (const auto bond : seed.MoleculeFragment.Bonds) {
71 unsigned int i = bond->getBeginAtomIdx();
72 unsigned int j = bond->getEndAtomIdx();
73 unsigned int ti = TargetAtomIdx.at(i);
74 unsigned int tj = TargetAtomIdx.at(j);
75 const auto tb = target.Molecule->getBondBetweenAtoms(ti, tj);
76 if (tb) {
78 TargetBondIdx[bond->getIdx()] = tb->getIdx(); // add
79 VisitedTargetBonds.set(tb->getIdx());
80 }
81 }
82 Empty = false;
83 }
84};
85} // namespace FMCS
86} // namespace RDKit
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
unsigned int getNumAtoms() const
returns our number of atoms
Definition ROMol.h:421
const unsigned int NotSet
std::vector< std::pair< FMCS::Graph::vertex_descriptor, FMCS::Graph::vertex_descriptor > > match_V_t
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
std::vector< unsigned int > TargetAtomIdx
Definition TargetMatch.h:23
TargetMatch(const TargetMatch &src)
Definition TargetMatch.h:29
TargetMatch & operator=(const TargetMatch &src)
Definition TargetMatch.h:30
std::vector< unsigned int > TargetBondIdx
Definition TargetMatch.h:24
boost::dynamic_bitset VisitedTargetAtoms
Definition TargetMatch.h:26
boost::dynamic_bitset VisitedTargetBonds
Definition TargetMatch.h:25
void init(const Seed &seed, const match_V_t &match, const ROMol &query, const Target &target)
Definition TargetMatch.h:51