RDKit: ReactionFingerprints.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ReactionFingerprints.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014, Novartis Institutes for BioMedical Research Inc.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following
13 // disclaimer in the documentation and/or other materials provided
14 // with the distribution.
15 // * Neither the name of Novartis Institutes for BioMedical Research Inc.
16 // nor the names of its contributors may be used to endorse or promote
17 // products derived from this software without specific prior written
18 // permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //
32 #ifndef RD_REACTIONFINGERPRINTS_H
33 #define RD_REACTIONFINGERPRINTS_H
34
35 #include <DataStructs/SparseIntVect.h>
36 #include <DataStructs/ExplicitBitVect.h>
37
38 namespace RDKit {
39
40 class ChemicalReaction;
41
42 enum FingerprintType {
43 AtomPairFP = 1,
44 TopologicalTorsion,
45 MorganFP,
46 RDKitFP,
47 PatternFP
48 };
49
50 //! A struct for storing parameters to manipulate
51 //! the calculation of fingerprints of chemical reactions
52 /*!
53 Different parameters can be chosen to influence the generation
54 of chemical reaction fingerprints. Generally different setting
55 should be used for structural or difference fingerprints.
56
57 \param includeAgents include the agents of a reaction for fingerprint
58 generation
59 \param bitRatioAgents in structural fingerprints it determines the
60 ratio of bits of
61 the agents in the fingerprint
62 \param nonAgentWeight in difference fingerprints weight factor for
63 reactants and products
64 compared to agents
65 \param agentWeight if agents are included, agents could be weighted
66 compared to reactants
67 and products in difference fingerprints
68 \param fpSize number of bits of the fingerprint
69 \param fpType kind of fingerprint used, e.g AtompairFP. Be
70 aware that only AtompairFP,
71 TopologicalTorsion and MorganFP were supported in
72 the difference fingerprint.
73 */
74 struct ReactionFingerprintParams {
75 ReactionFingerprintParams()
76 : includeAgents(false),
77 bitRatioAgents(0.2),
78 nonAgentWeight(10),
79 agentWeight(1),
80 fpSize(2048),
81 fpType(AtomPairFP) {}
82
83 ReactionFingerprintParams(bool includeAgents, double bitRatioAgents,
84 unsigned int nonAgentWeight, int agentWeight,
85 unsigned int fpSize, FingerprintType fpType)
86 : includeAgents(includeAgents),
87 bitRatioAgents(bitRatioAgents),
88 nonAgentWeight(nonAgentWeight),
89 agentWeight(agentWeight),
90 fpSize(fpSize),
91 fpType(fpType) {}
92
93 bool includeAgents;
94 double bitRatioAgents;
95 unsigned int nonAgentWeight;
96 int agentWeight;
97 unsigned int fpSize;
98 FingerprintType fpType;
99 };
100
101 const ReactionFingerprintParams DefaultStructuralFPParams(true, 0.2, 1, 1, 4096,
102 PatternFP);
103 const ReactionFingerprintParams DefaultDifferenceFPParams(true, 0.0, 10, 1,
104 2048, AtomPairFP);
105
106 //! Generates a structural fingerprint for a reaction
107 //! to use in screening
108 /*!
109 A structural fingerprint is generated as an ExplicitBitVect to use for
110 searching
111 e.g. substructure in reactions. By default the fingerprint is generated as
112 4096 BitVect
113 using a PatternFP for reactants and products and tentatively agents which
114 were finally concatenated
115
116 \param rxn: the reaction to be fingerprinted
117 \param params: specific settings to manipulate fingerprint generation
118
119 \return the reaction fingerprint, as an ExplicitBitVect
120
121 <b>Notes:</b>
122 - the caller is responsible for <tt>delete</tt>ing the result
123 */
124 ExplicitBitVect *StructuralFingerprintChemReaction(
125 const ChemicalReaction &rxn,
126 const ReactionFingerprintParams &params = DefaultStructuralFPParams);
127
128 //! Generates a difference fingerprint for a reaction
129 //! to use in similarity search of reactions
130 /*!
131 A difference fingerprint is generated as a SparseIntVect to use for
132 similarity search of reactions. By default the fingerprint is generated as
133 2048 bit
134 hashed fingerprint subtracting AtompairFP of the reactants from the products'
135 AtompairFP
136 and tentatively the agent AtompairFP is added
137
138 \param rxn: the reaction to be fingerprinted
139 \param params: specific settings to manipulate fingerprint generation
140
141 \return the reaction fingerprint, as an SparseIntVec
142
143 <b>Notes:</b>
144 - the caller is responsible for <tt>delete</tt>ing the result
145 */
146 SparseIntVect<boost::uint32_t> *DifferenceFingerprintChemReaction(
147 const ChemicalReaction &rxn,
148 const ReactionFingerprintParams &params = DefaultDifferenceFPParams);
149 }
150
151 #endif
RDKit::DifferenceFingerprintChemReaction
SparseIntVect< boost::uint32_t > * DifferenceFingerprintChemReaction(const ChemicalReaction &rxn, const ReactionFingerprintParams &params=DefaultDifferenceFPParams)
RDKit::DefaultStructuralFPParams
const ReactionFingerprintParams DefaultStructuralFPParams(true, 0.2, 1, 1, 4096, PatternFP)
RDKit::ReactionFingerprintParams::bitRatioAgents
double bitRatioAgents
Definition: ReactionFingerprints.h:94
RDKit::TopologicalTorsion
Definition: ReactionFingerprints.h:44
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition: Reaction.h:116
RDKit::DefaultDifferenceFPParams
const ReactionFingerprintParams DefaultDifferenceFPParams(true, 0.0, 10, 1, 2048, AtomPairFP)
RDKit::ReactionFingerprintParams
Definition: ReactionFingerprints.h:74
RDKit::ReactionFingerprintParams::includeAgents
bool includeAgents
Definition: ReactionFingerprints.h:93
ExplicitBitVect.h
RDKit::PatternFP
Definition: ReactionFingerprints.h:47
RDKit::FingerprintType
FingerprintType
Definition: ReactionFingerprints.h:42
RDKit::RDKitFP
Definition: ReactionFingerprints.h:46
RDKit::AtomPairFP
Definition: ReactionFingerprints.h:43
RDKit::ReactionFingerprintParams::ReactionFingerprintParams
ReactionFingerprintParams(bool includeAgents, double bitRatioAgents, unsigned int nonAgentWeight, int agentWeight, unsigned int fpSize, FingerprintType fpType)
Definition: ReactionFingerprints.h:83
RDKit::MorganFP
Definition: ReactionFingerprints.h:45
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::ReactionFingerprintParams::nonAgentWeight
unsigned int nonAgentWeight
Definition: ReactionFingerprints.h:95
SparseIntVect.h
RDKit::SparseIntVect
a class for efficiently storing sparse vectors of ints
Definition: SparseIntVect.h:27
ExplicitBitVect
a class for bit vectors that are densely occupied
Definition: ExplicitBitVect.h:28
RDKit::ReactionFingerprintParams::fpType
FingerprintType fpType
Definition: ReactionFingerprints.h:98
RDKit::ReactionFingerprintParams::fpSize
unsigned int fpSize
Definition: ReactionFingerprints.h:97
RDKit::ReactionFingerprintParams::agentWeight
int agentWeight
Definition: ReactionFingerprints.h:96
RDKit::StructuralFingerprintChemReaction
ExplicitBitVect * StructuralFingerprintChemReaction(const ChemicalReaction &rxn, const ReactionFingerprintParams &params=DefaultStructuralFPParams)
RDKit::ReactionFingerprintParams::ReactionFingerprintParams
ReactionFingerprintParams()
Definition: ReactionFingerprints.h:75