RDKit: ReactionParser.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
ReactionParser.h
Go to the documentation of this file.
1//
2// Copyright (c) 2007-2024, Novartis Institutes for BioMedical Research Inc.
3// and other RDKit contributors
4//
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions are
9// met:
10//
11// * Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// * Redistributions in binary form must reproduce the above
14// copyright notice, this list of conditions and the following
15// disclaimer in the documentation and/or other materials provided
16// with the distribution.
17// * Neither the name of Novartis Institutes for BioMedical Research Inc.
18// nor the names of its contributors may be used to endorse or promote
19// products derived from this software without specific prior written
20// permission.
21//
22// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33//
34
35#include <RDGeneral/export.h>
36#ifndef RD_REACTIONPARSER_H_21Aug2006
37#define RD_REACTIONPARSER_H_21Aug2006
38
39#include <string>
40#include <fstream>
41#include <map>
42#include <sstream>
43#include <utility>
44#include <boost/format.hpp>
45#include <RDGeneral/BadFileException.h>
46#include <RDGeneral/FileParseException.h>
47#include <GraphMol/FileParsers/FileParsers.h>
48#include <GraphMol/SmilesParse/SmilesWrite.h>
49
50namespace RDKit {
51class ROMol;
52class ChemicalReaction;
53
54//! used to indicate an error in parsing reaction data
55 class RDKIT_CHEMREACTIONS_EXPORT ChemicalReactionParserException
56 : public std::exception {
57 public:
58 //! construct with an error message
59 explicit ChemicalReactionParserException(const char *msg) : _msg(msg) {}
60 //! construct with an error message
61 explicit ChemicalReactionParserException(std::string msg)
62 : _msg(std::move(msg)) {}
63 //! get the error message
64 const char *what() const noexcept override { return _msg.c_str(); }
65 ~ChemicalReactionParserException() noexcept override = default;
66
67 private:
68 std::string _msg;
69};
70
71namespace v2 {
72 namespace ReactionParser {
73 struct RDKIT_CHEMREACTIONS_EXPORT ReactionSmartsParserParams {
74 bool sanitize = false; /**< sanitize the molecules after building them */
75 std::map<std::string, std::string>
76 replacements; /**< allows SMILES "macros" */
77 bool allowCXSMILES = true; /**< recognize and parse CXSMILES*/
78 bool strictCXSMILES =
79 true; /**< throw an exception if the CXSMILES parsing fails */
80};
81 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction> ReactionFromSmarts(
82 const std::string &smarts,
83 const ReactionSmartsParserParams &params = ReactionSmartsParserParams());
84
85 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction> ReactionFromSmiles(
86 const std::string &smarts,
87 const ReactionSmartsParserParams &params = ReactionSmartsParserParams());
88} // namespace ReactionParser
89} // namespace v2
90
91 inline namespace v1 {
92//---------------------------------------------------------------------------
93//! \name Reaction SMARTS/SMILES Support
94//! @{
95
96//! Parse a string containing "Reaction SMARTS" into a ChemicalReaction
97/*!
98 Our definition of Reaction SMARTS is something that looks a lot like reaction
99 SMILES, except that SMARTS queries are allowed on the reactant side and that
100 atom-map numbers are required (at least for now)
101
102 \param text the SMARTS to convert
103
104 \param replacements a string->string map of replacement strings. \see
105 SmilesToMol for more information about replacements
106
107 \param useSmiles if set, the SMILES parser will be used instead of the
108 SMARTS parserfor the individual components
109
110 \param allowCXSMILES if set, any CXSMILES extensions present will be
111 parsed, otherwise it will be ignored
112 */
113 inline ChemicalReaction *RxnSmartsToChemicalReaction(
114 const std::string &text,
115 std::map<std::string, std::string> *replacements = nullptr,
116 bool useSmiles = false, bool allowCXSMILES = true) {
117 v2::ReactionParser::ReactionSmartsParserParams params;
118 if (replacements) {
119 params.replacements = *replacements;
120 }
121 params.allowCXSMILES = allowCXSMILES;
122 if (useSmiles) {
123 return v2::ReactionParser::ReactionFromSmiles(text, params).release();
124 } else {
125 return v2::ReactionParser::ReactionFromSmarts(text, params).release();
126 }
127}
128} // namespace v1
129//! returns the reaction SMARTS for a reaction
130 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmarts(
131 const ChemicalReaction &rxn, const SmilesWriteParams &params);
132//! \overload
133 inline std::string ChemicalReactionToRxnSmarts(const ChemicalReaction &rxn) {
134 SmilesWriteParams params;
135 params.canonical = false;
136 return ChemicalReactionToRxnSmarts(rxn, params);
137}
138
139//! returns the reaction SMILES for a reaction
140 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmiles(
141 const ChemicalReaction &rxn,
142 const SmilesWriteParams &params = SmilesWriteParams());
143//! \overload
144 inline std::string ChemicalReactionToRxnSmiles(const ChemicalReaction &rxn,
145 bool canonical) {
146 SmilesWriteParams params;
147 params.canonical = canonical;
148 return ChemicalReactionToRxnSmiles(rxn, params);
149}
150
151//! returns the reaction SMARTS for a reaction with CX extension
152 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToCXRxnSmarts(
153 const ChemicalReaction &rxn, const SmilesWriteParams &params,
154 std::uint32_t flags = SmilesWrite::CXSmilesFields::CX_ALL);
155//! \overload
156 inline std::string ChemicalReactionToCXRxnSmarts(const ChemicalReaction &rxn) {
157 SmilesWriteParams params;
158 params.canonical = false;
159 return ChemicalReactionToCXRxnSmarts(rxn, params);
160}
161
162//! returns the reaction SMILES for a reaction with CX extension
163 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToCXRxnSmiles(
164 const ChemicalReaction &rxn, const SmilesWriteParams &params,
165 std::uint32_t flags = SmilesWrite::CXSmilesFields::CX_ALL);
166//! \overload
167 inline std::string ChemicalReactionToCXRxnSmiles(const ChemicalReaction &rxn,
168 bool canonical = true) {
169 SmilesWriteParams params;
170 params.canonical = canonical;
171 return ChemicalReactionToCXRxnSmiles(rxn, params);
172}
173//! @}
174
175//---------------------------------------------------------------------------
176//! \name Reaction Mol Support
177//! @{
178
179//! Parse a ROMol into a ChemicalReaction, RXN role must be set before
180/*!
181 Alternative to build a reaction from a molecule (fragments) which have RXN
182 roles set as atom properties: common_properties::molRxnRole (1=reactant,
183 2=product, 3=agent)
184
185 \param mol ROMol with RXN roles set
186 */
187 RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction *RxnMolToChemicalReaction(
188 const ROMol &mol);
189
190//! returns a ROMol with RXN roles used to describe the reaction
191 RDKIT_CHEMREACTIONS_EXPORT ROMol *ChemicalReactionToRxnMol(
192 const ChemicalReaction &rxn);
193//! @}
194
195//---------------------------------------------------------------------------
196//! \name MDL rxn Support
197//! @{
198namespace v2 {
199namespace ReactionParser {
200
201 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction>
202ReactionFromRxnBlock(const std::string &rxnBlock,
203 const FileParsers::MolFileParserParams &params =
204 FileParsers::MolFileParserParams());
205 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction>
206ReactionFromRxnFile(const std::string &fileName,
207 const FileParsers::MolFileParserParams &params =
208 FileParsers::MolFileParserParams());
209 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction>
210ReactionFromRxnDataStream(std::istream &rxnStream, unsigned int &line,
211 const FileParsers::MolFileParserParams &params =
212 FileParsers::MolFileParserParams());
213
214} // namespace ReactionParser
215} // namespace v2
216inline namespace v1 {
217//! Parse a text block in MDL rxn format into a ChemicalReaction
218 inline ChemicalReaction *RxnBlockToChemicalReaction(const std::string &rxnBlock,
219 bool sanitize = false,
220 bool removeHs = false,
221 bool strictParsing = true) {
222 v2::FileParsers::MolFileParserParams params;
223 params.sanitize = sanitize;
224 params.removeHs = removeHs;
225 params.strictParsing = strictParsing;
226 return v2::ReactionParser::ReactionFromRxnBlock(rxnBlock, params).release();
227}
228//! Parse a file in MDL rxn format into a ChemicalReaction
229 inline ChemicalReaction *RxnFileToChemicalReaction(const std::string &fileName,
230 bool sanitize = false,
231 bool removeHs = false,
232 bool strictParsing = true) {
233 v2::FileParsers::MolFileParserParams params;
234 params.sanitize = sanitize;
235 params.removeHs = removeHs;
236 params.strictParsing = strictParsing;
237 return v2::ReactionParser::ReactionFromRxnFile(fileName, params).release();
238}
239//! Parse a text stream in MDL rxn format into a ChemicalReaction
240 inline ChemicalReaction *RxnDataStreamToChemicalReaction(
241 std::istream &rxnStream, unsigned int &line, bool sanitize = false,
242 bool removeHs = false, bool strictParsing = true) {
243 v2::FileParsers::MolFileParserParams params;
244 params.sanitize = sanitize;
245 params.removeHs = removeHs;
246 params.strictParsing = strictParsing;
247 return v2::ReactionParser::ReactionFromRxnDataStream(rxnStream, line, params)
248 .release();
249}
250} // namespace v1
251//! returns an rxn block for a reaction
252/*!
253 \param rxn chemical reaction
254
255 \param separateAgents flag to decide if agents are put in a separate block,
256 otherwise they are included in the reactants block
257 (default)
258
259 \param forceV3000 flag to cause the V3000 format to be used instead of
260 V2000
261 */
262 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnBlock(
263 const ChemicalReaction &rxn, bool separateAgents = false,
264 bool forceV3000 = false);
265//! returns an V3000 rxn block for a reaction
266/*!
267 \param rxn chemical reaction
268
269 \param separateAgents flag to decide if agents are put in a separate block,
270 otherwise they are included in the reactants block
271 (default)
272*/
273 RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToV3KRxnBlock(
274 const ChemicalReaction &rxn, bool separateAgents = false);
275
276//! @}
277
278//---------------------------------------------------------------------------
279//! \name PNG Support
280//! @{
281
282//! Tags used for PNG metadata
283 namespace PNGData {
284 RDKIT_CHEMREACTIONS_EXPORT extern const std::string rxnSmilesTag;
285 RDKIT_CHEMREACTIONS_EXPORT extern const std::string rxnSmartsTag;
286 RDKIT_CHEMREACTIONS_EXPORT extern const std::string rxnRxnTag;
287 RDKIT_CHEMREACTIONS_EXPORT extern const std::string rxnPklTag;
288} // namespace PNGData
289
290namespace v2 {
291namespace ReactionParser {
292
293//! \brief constructs a ChemicalReaction from the metadata in a PNG stream
294/*!
295
296Looks through the metadata in the PNG to find the first tag that matches one
297of the tags in \c RDKit::PNGData. A reaction is constructed from this chunk.
298
299Throws a \c FileParseException if no suitable tag is found.
300
301 */
302 RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr<ChemicalReaction>
303ReactionFromPNGStream(std::istream &pngStream);
304//! \brief constructs a ChemicalReaction from the metadata in a PNG string
305//! See \c PNGStreamToChemicalReaction() for more details
306 inline std::unique_ptr<ChemicalReaction> ReactionFromPNGString(
307 const std::string &data) {
308 std::stringstream inStream(data);
309 return ReactionFromPNGStream(inStream);
310};
311//! \brief constructs a ChemicalReaction from the metadata in a PNG file
312//! See \c PNGStreamToChemicalReaction() for more details
313 inline std::unique_ptr<ChemicalReaction> ReactionFromPNGFile(
314 const std::string &fname) {
315 std::ifstream inStream(fname.c_str(), std::ios::binary);
316 if (!inStream || (inStream.bad())) {
317 throw BadFileException((boost::format("Bad input file %s") % fname).str());
318 }
319 return ReactionFromPNGStream(inStream);
320};
321} // namespace ReactionParser
322} // namespace v2
323
324inline namespace v1 {
325//! \brief constructs a ChemicalReaction from the metadata in a PNG stream
326/*!
327
328Looks through the metadata in the PNG to find the first tag that matches one
329of the tags in \c RDKit::PNGData. A reaction is constructed from this chunk.
330
331Throws a \c FileParseException if no suitable tag is found.
332
333The caller is responsible for the returned pointer.
334
335 */
336 inline ChemicalReaction *PNGStreamToChemicalReaction(std::istream &pngStream) {
337 return v2::ReactionParser::ReactionFromPNGStream(pngStream).release();
338}
339//! \brief constructs a ChemicalReaction from the metadata in a PNG string
340//! See \c PNGStreamToChemicalReaction() for more details
341 inline ChemicalReaction *PNGStringToChemicalReaction(const std::string &data) {
342 return v2::ReactionParser::ReactionFromPNGString(data).release();
343}
344//! \brief constructs a ChemicalReaction from the metadata in a PNG file
345//! See \c PNGStreamToChemicalReaction() for more details
346 inline ChemicalReaction *PNGFileToChemicalReaction(const std::string &fname) {
347 return v2::ReactionParser::ReactionFromPNGFile(fname).release();
348}
349} // namespace v1
350
351//! \brief adds metadata for a ChemicalReaction to the data from a PNG stream.
352//! The modified PNG data is returned.
353/*!
354
355 \param rxn the reaction to add
356 \param iStream the stream to read from
357 \param includePkl include a reaction pickle
358 \param includeSmiles include reaction SMILES for the reaction
359 \param includeSmarts include reaction SMARTS for the reaction
360 \param includeRxn include an RXN block for the reaction
361
362*/
363 RDKIT_CHEMREACTIONS_EXPORT std::string addChemicalReactionToPNGStream(
364 const ChemicalReaction &rxn, std::istream &iStream, bool includePkl = true,
365 bool includeSmiles = true, bool includeSmarts = false,
366 bool includeRxn = false);
367//! \brief adds metadata for a ChemicalReaction to the data from a PNG string.
368//! See addChemicalReactionToPNGStream() for more details.
369 inline std::string addChemicalReactionToPNGString(const ChemicalReaction &rxn,
370 const std::string &pngString,
371 bool includePkl = true,
372 bool includeSmiles = true,
373 bool includeSmarts = false,
374 bool includeRxn = false) {
375 std::stringstream inStream(pngString);
376 return addChemicalReactionToPNGStream(
377 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
378}
379//! \brief adds metadata for a ChemicalReaction to the data from a PNG string.
380//! See addChemicalReactionToPNGStream() for more details.
381 inline std::string addChemicalReactionToPNGFile(const ChemicalReaction &rxn,
382 const std::string &fname,
383 bool includePkl = true,
384 bool includeSmiles = true,
385 bool includeSmarts = false,
386 bool includeRxn = false) {
387 std::ifstream inStream(fname.c_str(), std::ios::binary);
388 return addChemicalReactionToPNGStream(
389 rxn, inStream, includePkl, includeSmiles, includeSmarts, includeRxn);
390}
391//! @}
392
393 inline std::unique_ptr<ChemicalReaction> operator""_rxnsmarts(const char *text,
394 size_t len) {
395 std::string sma(text, len);
396 std::unique_ptr<ChemicalReaction> ptr;
397 try {
398 ptr = v2::ReactionParser::ReactionFromSmarts(sma);
399 } catch (...) {
400 ptr = nullptr;
401 }
402 return ptr;
403}
404 inline std::unique_ptr<ChemicalReaction> operator""_rxnsmiles(const char *text,
405 size_t len) {
406 std::string sma(text, len);
407 std::unique_ptr<ChemicalReaction> ptr;
408 try {
409 ptr = v2::ReactionParser::ReactionFromSmiles(sma);
410 } catch (...) {
411 ptr = nullptr;
412 }
413 return ptr;
414}
415
416//---------------------------------------------------------------------------
417//! \name CDXML rxn Support
418///@{
419
420//! Parse text in CDXML rxn format into a vector of ChemicalReactions
421 RDKIT_CHEMREACTIONS_EXPORT std::vector<std::unique_ptr<ChemicalReaction>>
422CDXMLToChemicalReactions(const std::string &rxnBlock, bool sanitize = false,
423 bool removeHs = false);
424//! Parse a file in CDXML rxn format into a vector of ChemicalReactions
425 RDKIT_CHEMREACTIONS_EXPORT std::vector<std::unique_ptr<ChemicalReaction>>
426CDXMLFileToChemicalReactions(const std::string &fileName, bool sanitize = false,
427 bool removeHs = false);
428//! Parse a text stream in CDXML rxn format into a vector of ChemicalReactions
429 RDKIT_CHEMREACTIONS_EXPORT std::vector<std::unique_ptr<ChemicalReaction>>
430CDXMLDataStreamToChemicalReactions(std::istream &rxnStream,
431 bool sanitize = false,
432 bool removeHs = false);
433
434} // namespace RDKit
435#endif
BadFileException.h
FileParseException.h
FileParsers.h
SmilesWrite.h
RDKit::BadFileException
used by various file parsing classes to indicate a bad file
Definition BadFileException.h:22
RDKit::ChemicalReactionParserException::what
const char * what() const noexcept override
get the error message
Definition ReactionParser.h:64
RDKit::ChemicalReactionParserException::ChemicalReactionParserException
ChemicalReactionParserException(std::string msg)
construct with an error message
Definition ReactionParser.h:61
RDKit::ChemicalReactionParserException::~ChemicalReactionParserException
~ChemicalReactionParserException() noexcept override=default
RDKit::ChemicalReactionParserException::ChemicalReactionParserException
ChemicalReactionParserException(const char *msg)
construct with an error message
Definition ReactionParser.h:59
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition Reaction.h:121
RDKit::ROMol
Definition ROMol.h:199
export.h
RDKIT_CHEMREACTIONS_EXPORT
#define RDKIT_CHEMREACTIONS_EXPORT
Definition export.h:57
RDKit::PNGData
Tags used for PNG metadata.
Definition ReactionParser.h:283
RDKit::PNGData::rxnRxnTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnRxnTag
RDKit::PNGData::rxnSmilesTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnSmilesTag
RDKit::PNGData::rxnSmartsTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnSmartsTag
RDKit::PNGData::rxnPklTag
RDKIT_CHEMREACTIONS_EXPORT const std::string rxnPklTag
RDKit::v1
Definition ReactionParser.h:91
RDKit::v1::RxnSmartsToChemicalReaction
ChemicalReaction * RxnSmartsToChemicalReaction(const std::string &text, std::map< std::string, std::string > *replacements=nullptr, bool useSmiles=false, bool allowCXSMILES=true)
Parse a string containing "Reaction SMARTS" into a ChemicalReaction.
Definition ReactionParser.h:113
RDKit::v1::RxnBlockToChemicalReaction
ChemicalReaction * RxnBlockToChemicalReaction(const std::string &rxnBlock, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a text block in MDL rxn format into a ChemicalReaction.
Definition ReactionParser.h:218
RDKit::v1::RxnDataStreamToChemicalReaction
ChemicalReaction * RxnDataStreamToChemicalReaction(std::istream &rxnStream, unsigned int &line, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a text stream in MDL rxn format into a ChemicalReaction.
Definition ReactionParser.h:240
RDKit::v1::PNGStreamToChemicalReaction
ChemicalReaction * PNGStreamToChemicalReaction(std::istream &pngStream)
constructs a ChemicalReaction from the metadata in a PNG stream
Definition ReactionParser.h:336
RDKit::v1::RxnFileToChemicalReaction
ChemicalReaction * RxnFileToChemicalReaction(const std::string &fileName, bool sanitize=false, bool removeHs=false, bool strictParsing=true)
Parse a file in MDL rxn format into a ChemicalReaction.
Definition ReactionParser.h:229
RDKit::v1::PNGStringToChemicalReaction
ChemicalReaction * PNGStringToChemicalReaction(const std::string &data)
constructs a ChemicalReaction from the metadata in a PNG string See PNGStreamToChemicalReaction() for...
Definition ReactionParser.h:341
RDKit::v1::PNGFileToChemicalReaction
ChemicalReaction * PNGFileToChemicalReaction(const std::string &fname)
constructs a ChemicalReaction from the metadata in a PNG file See PNGStreamToChemicalReaction() for m...
Definition ReactionParser.h:346
RDKit::v2::ReactionParser
Definition ReactionParser.h:72
RDKit::v2::ReactionParser::ReactionFromPNGString
std::unique_ptr< ChemicalReaction > ReactionFromPNGString(const std::string &data)
constructs a ChemicalReaction from the metadata in a PNG string See PNGStreamToChemicalReaction() for...
Definition ReactionParser.h:306
RDKit::v2::ReactionParser::ReactionFromRxnBlock
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromRxnBlock(const std::string &rxnBlock, const FileParsers::MolFileParserParams &params=FileParsers::MolFileParserParams())
RDKit::v2::ReactionParser::ReactionFromRxnDataStream
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromRxnDataStream(std::istream &rxnStream, unsigned int &line, const FileParsers::MolFileParserParams &params=FileParsers::MolFileParserParams())
RDKit::v2::ReactionParser::ReactionFromPNGFile
std::unique_ptr< ChemicalReaction > ReactionFromPNGFile(const std::string &fname)
constructs a ChemicalReaction from the metadata in a PNG file See PNGStreamToChemicalReaction() for m...
Definition ReactionParser.h:313
RDKit::v2::ReactionParser::ReactionFromSmarts
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromSmarts(const std::string &smarts, const ReactionSmartsParserParams &params=ReactionSmartsParserParams())
RDKit::v2::ReactionParser::ReactionFromRxnFile
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromRxnFile(const std::string &fileName, const FileParsers::MolFileParserParams &params=FileParsers::MolFileParserParams())
RDKit::v2::ReactionParser::ReactionFromPNGStream
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromPNGStream(std::istream &pngStream)
constructs a ChemicalReaction from the metadata in a PNG stream
RDKit::v2::ReactionParser::ReactionFromSmiles
RDKIT_CHEMREACTIONS_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromSmiles(const std::string &smarts, const ReactionSmartsParserParams &params=ReactionSmartsParserParams())
RDKit::v2
Definition ReactionParser.h:71
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::ChemicalReactionToCXRxnSmarts
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToCXRxnSmarts(const ChemicalReaction &rxn, const SmilesWriteParams &params, std::uint32_t flags=SmilesWrite::CXSmilesFields::CX_ALL)
returns the reaction SMARTS for a reaction with CX extension
RDKit::ChemicalReactionToRxnSmarts
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmarts(const ChemicalReaction &rxn, const SmilesWriteParams &params)
returns the reaction SMARTS for a reaction
RDKit::CDXMLFileToChemicalReactions
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLFileToChemicalReactions(const std::string &fileName, bool sanitize=false, bool removeHs=false)
Parse a file in CDXML rxn format into a vector of ChemicalReactions.
RDKit::ChemicalReactionToCXRxnSmiles
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToCXRxnSmiles(const ChemicalReaction &rxn, const SmilesWriteParams &params, std::uint32_t flags=SmilesWrite::CXSmilesFields::CX_ALL)
returns the reaction SMILES for a reaction with CX extension
RDKit::ChemicalReactionToRxnBlock
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnBlock(const ChemicalReaction &rxn, bool separateAgents=false, bool forceV3000=false)
returns an rxn block for a reaction
RDKit::CDXMLDataStreamToChemicalReactions
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLDataStreamToChemicalReactions(std::istream &rxnStream, bool sanitize=false, bool removeHs=false)
Parse a text stream in CDXML rxn format into a vector of ChemicalReactions.
RDKit::CDXMLToChemicalReactions
RDKIT_CHEMREACTIONS_EXPORT std::vector< std::unique_ptr< ChemicalReaction > > CDXMLToChemicalReactions(const std::string &rxnBlock, bool sanitize=false, bool removeHs=false)
Parse text in CDXML rxn format into a vector of ChemicalReactions.
RDKit::addChemicalReactionToPNGStream
RDKIT_CHEMREACTIONS_EXPORT std::string addChemicalReactionToPNGStream(const ChemicalReaction &rxn, std::istream &iStream, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG stream. The modified PNG data is returned...
RDKit::ChemicalReactionToRxnSmiles
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToRxnSmiles(const ChemicalReaction &rxn, const SmilesWriteParams &params=SmilesWriteParams())
returns the reaction SMILES for a reaction
RDKit::addChemicalReactionToPNGFile
std::string addChemicalReactionToPNGFile(const ChemicalReaction &rxn, const std::string &fname, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG string. See addChemicalReactionToPNGStrea...
Definition ReactionParser.h:381
RDKit::ChemicalReactionToV3KRxnBlock
RDKIT_CHEMREACTIONS_EXPORT std::string ChemicalReactionToV3KRxnBlock(const ChemicalReaction &rxn, bool separateAgents=false)
returns an V3000 rxn block for a reaction
RDKit::RxnMolToChemicalReaction
RDKIT_CHEMREACTIONS_EXPORT ChemicalReaction * RxnMolToChemicalReaction(const ROMol &mol)
Parse a ROMol into a ChemicalReaction, RXN role must be set before.
RDKit::ChemicalReactionToRxnMol
RDKIT_CHEMREACTIONS_EXPORT ROMol * ChemicalReactionToRxnMol(const ChemicalReaction &rxn)
returns a ROMol with RXN roles used to describe the reaction
RDKit::addChemicalReactionToPNGString
std::string addChemicalReactionToPNGString(const ChemicalReaction &rxn, const std::string &pngString, bool includePkl=true, bool includeSmiles=true, bool includeSmarts=false, bool includeRxn=false)
adds metadata for a ChemicalReaction to the data from a PNG string. See addChemicalReactionToPNGStrea...
Definition ReactionParser.h:369
RDKit::SmilesWriteParams
Definition SmilesWrite.h:30
RDKit::SmilesWriteParams::canonical
bool canonical
Definition SmilesWrite.h:37
RDKit::v2::FileParsers::MolFileParserParams
Definition FileParsers.h:47
RDKit::v2::FileParsers::MolFileParserParams::strictParsing
bool strictParsing
Definition FileParsers.h:50
RDKit::v2::FileParsers::MolFileParserParams::sanitize
bool sanitize
Definition FileParsers.h:48
RDKit::v2::FileParsers::MolFileParserParams::removeHs
bool removeHs
Definition FileParsers.h:49
RDKit::v2::ReactionParser::ReactionSmartsParserParams
Definition ReactionParser.h:73
RDKit::v2::ReactionParser::ReactionSmartsParserParams::replacements
std::map< std::string, std::string > replacements
Definition ReactionParser.h:76
RDKit::v2::ReactionParser::ReactionSmartsParserParams::strictCXSMILES
bool strictCXSMILES
Definition ReactionParser.h:78
RDKit::v2::ReactionParser::ReactionSmartsParserParams::sanitize
bool sanitize
Definition ReactionParser.h:74
RDKit::v2::ReactionParser::ReactionSmartsParserParams::allowCXSMILES
bool allowCXSMILES
Definition ReactionParser.h:77