RDKit: MarvinParser.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
MarvinParser.h
Go to the documentation of this file.
1//
2// Copyright (C) 2022-2023 Tad Hurst, Greg Landrum and other RDKit contributors
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
11#include <RDGeneral/export.h>
12
13#ifndef RD_MARVINPARSER_H
14#define RD_MARVINPARSER_H
15
16#include <GraphMol/RDKitBase.h>
17#include <GraphMol/ChemReactions/Reaction.h>
18
19#include <string>
20
21namespace RDKit {
22namespace v2 {
23 namespace MarvinParser {
24 RDKIT_MARVINPARSER_EXPORT bool MrvFileIsReaction(const std::string &fname);
25 RDKIT_MARVINPARSER_EXPORT bool MrvDataStreamIsReaction(std::istream &inStream);
26 RDKIT_MARVINPARSER_EXPORT bool MrvBlockIsReaction(
27 const std::string &molmrvText);
28
29 struct RDKIT_MARVINPARSER_EXPORT MrvParserParams {
30 bool sanitize = true; /**< sanitize the molecule after building it */
31 bool removeHs = true; /**< remove Hs after constructing the molecule */
32};
33
34 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<RWMol> MolFromMrvDataStream(
35 std::istream &inStream, const MrvParserParams &params = MrvParserParams());
36 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<RWMol> MolFromMrvBlock(
37 const std::string &molmrvText,
38 const MrvParserParams &params = MrvParserParams());
39 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<RWMol> MolFromMrvFile(
40 const std::string &fName,
41 const MrvParserParams &params = MrvParserParams());
42
43 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
44ReactionFromMrvDataStream(std::istream &inStream,
45 const MrvParserParams &params = MrvParserParams());
46 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
47ReactionFromMrvBlock(const std::string &molmrvText,
48 const MrvParserParams &params = MrvParserParams());
49 RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction> ReactionFromMrvFile(
50 const std::string &fName,
51 const MrvParserParams &params = MrvParserParams());
52} // namespace MarvinParser
53} // namespace v2
54
55inline namespace v1 {
56 inline bool MrvFileIsReaction(const std::string &fname) {
57 return v2::MarvinParser::MrvFileIsReaction(fname);
58}
59 inline bool MrvDataStreamIsReaction(std::istream *inStream) {
60 return v2::MarvinParser::MrvDataStreamIsReaction(*inStream);
61}
62
63 inline bool MrvDataStreamIsReaction(std::istream &inStream) {
64 return v2::MarvinParser::MrvDataStreamIsReaction(inStream);
65}
66 inline bool MrvBlockIsReaction(const std::string &molmrvText) {
67 return v2::MarvinParser::MrvBlockIsReaction(molmrvText);
68}
69
70 inline RWMol *MrvDataStreamToMol(std::istream *inStream, bool sanitize = false,
71 bool removeHs = false) {
72 v2::MarvinParser::MrvParserParams params;
73 params.sanitize = sanitize;
74 params.removeHs = removeHs;
75 return v2::MarvinParser::MolFromMrvDataStream(*inStream, params).release();
76}
77 inline RWMol *MrvDataStreamToMol(std::istream &inStream, bool sanitize = false,
78 bool removeHs = false) {
79 v2::MarvinParser::MrvParserParams params;
80 params.sanitize = sanitize;
81 params.removeHs = removeHs;
82 return v2::MarvinParser::MolFromMrvDataStream(inStream, params).release();
83}
84 inline RWMol *MrvBlockToMol(const std::string &molmrvText,
85 bool sanitize = false, bool removeHs = false) {
86 v2::MarvinParser::MrvParserParams params;
87 params.sanitize = sanitize;
88 params.removeHs = removeHs;
89 return v2::MarvinParser::MolFromMrvBlock(molmrvText, params).release();
90}
91 inline RWMol *MrvFileToMol(const std::string &fName, bool sanitize = false,
92 bool removeHs = false) {
93 v2::MarvinParser::MrvParserParams params;
94 params.sanitize = sanitize;
95 params.removeHs = removeHs;
96 return v2::MarvinParser::MolFromMrvFile(fName, params).release();
97}
98
99 inline ChemicalReaction *MrvDataStreamToChemicalReaction(
100 std::istream *inStream, bool sanitize = false, bool removeHs = false) {
101 v2::MarvinParser::MrvParserParams params;
102 params.sanitize = sanitize;
103 params.removeHs = removeHs;
104 return v2::MarvinParser::ReactionFromMrvDataStream(*inStream, params)
105 .release();
106}
107 inline ChemicalReaction *MrvDataStreamToChemicalReaction(
108 std::istream &inStream, bool sanitize = false, bool removeHs = false) {
109 v2::MarvinParser::MrvParserParams params;
110 params.sanitize = sanitize;
111 params.removeHs = removeHs;
112 return v2::MarvinParser::ReactionFromMrvDataStream(inStream, params)
113 .release();
114}
115 inline ChemicalReaction *MrvBlockToChemicalReaction(
116 const std::string &molmrvText, bool sanitize = false,
117 bool removeHs = false) {
118 v2::MarvinParser::MrvParserParams params;
119 params.sanitize = sanitize;
120 params.removeHs = removeHs;
121 return v2::MarvinParser::ReactionFromMrvBlock(molmrvText, params).release();
122}
123 inline ChemicalReaction *MrvFileToChemicalReaction(const std::string &fName,
124 bool sanitize = false,
125 bool removeHs = false) {
126 v2::MarvinParser::MrvParserParams params;
127 params.sanitize = sanitize;
128 params.removeHs = removeHs;
129 return v2::MarvinParser::ReactionFromMrvFile(fName, params).release();
130}
131} // namespace v1
132
133 struct RDKIT_MARVINPARSER_EXPORT MrvWriterParams {
134 bool includeStereo = true; /**< toggles inclusion of stereochemical */
135 bool kekulize =
136 true; /**< triggers kekulization of the molecule before it's written */
137 bool prettyPrint = false; /**< makes the output more human readable */
138 unsigned int precision = 6; /**< precision of the coordinates */
139};
140
141// \brief Writes a Marvin (MRV) file for a molecule
142/*!
143 * \param mol - the molecule
144 * \param fName - the file to write to
145 * \param params - marvin write params
146 * \param confId - selects which conformation to output
147 */
148 RDKIT_MARVINPARSER_EXPORT void MolToMrvFile(const ROMol &mol,
149 const std::string &fName,
150 const MrvWriterParams &params,
151 int confId = -1);
152
153// \brief Writes a Marvin (MRV) file for a molecule
154/*!
155 * \param mol - the molecule
156 * \param fName - the file to write to
157 * \param includeStereo - toggles inclusion of stereochemical information in
158 * the output \param confId - selects which conformation to output \param
159 * kekulize - triggers kekulization of the molecule before it's written
160 * \param prettyPrint - makes the output more human readable
161 */
162 inline void MolToMrvFile(const ROMol &mol, const std::string &fName,
163 bool includeStereo = true, int confId = -1,
164 bool kekulize = true, bool prettyPrint = false) {
165 MrvWriterParams params{includeStereo, kekulize, prettyPrint};
166 MolToMrvFile(mol, fName, params, confId);
167}
168
169// \brief Returns a Marvin (Mrv) Mol block for a molecule
170/*!
171 * \param mol - the molecule
172 * \param params - marvin write params
173 * \param confId - selects which conformation to output
174 */
175 RDKIT_MARVINPARSER_EXPORT std::string MolToMrvBlock(
176 const ROMol &mol, const MrvWriterParams &params, int confId = -1);
177
178// \brief Returns a Marvin (Mrv) Mol block for a molecule
179/*!
180 * \param mol - the molecule
181 * \param includeStereo - toggles inclusion of stereochemical information in
182 * the output \param confId - selects which conformation to output \param
183 * kekulize - triggers kekulization of the molecule before it's written
184 * \param prettyPrint - makes the output more human readable
185 */
186 inline std::string MolToMrvBlock(const ROMol &mol, bool includeStereo = true,
187 int confId = -1, bool kekulize = true,
188 bool prettyPrint = false) {
189 MrvWriterParams params{includeStereo, kekulize, prettyPrint};
190 return MolToMrvBlock(mol, params, confId);
191}
192
193 RDKIT_MARVINPARSER_EXPORT std::string ChemicalReactionToMrvBlock(
194 const ChemicalReaction &rxn, bool prettyPrint = false);
195
196 RDKIT_MARVINPARSER_EXPORT void ChemicalReactionToMrvFile(
197 const ChemicalReaction &rxn, const std::string &fName,
198 bool prettyPrint = false);
199} // namespace RDKit
200
201#endif
RDKitBase.h
pulls in the core RDKit functionality
Reaction.h
RDKit::ChemicalReaction
This is a class for storing and applying general chemical reactions.
Definition Reaction.h:121
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_MARVINPARSER_EXPORT
#define RDKIT_MARVINPARSER_EXPORT
Definition export.h:281
RDKit::v1
Definition ReactionParser.h:91
RDKit::v1::MrvDataStreamToChemicalReaction
ChemicalReaction * MrvDataStreamToChemicalReaction(std::istream *inStream, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:99
RDKit::v1::MrvFileIsReaction
bool MrvFileIsReaction(const std::string &fname)
Definition MarvinParser.h:56
RDKit::v1::MrvFileToMol
RWMol * MrvFileToMol(const std::string &fName, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:91
RDKit::v1::MrvBlockToMol
RWMol * MrvBlockToMol(const std::string &molmrvText, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:84
RDKit::v1::MrvDataStreamIsReaction
bool MrvDataStreamIsReaction(std::istream *inStream)
Definition MarvinParser.h:59
RDKit::v1::MrvBlockToChemicalReaction
ChemicalReaction * MrvBlockToChemicalReaction(const std::string &molmrvText, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:115
RDKit::v1::MrvBlockIsReaction
bool MrvBlockIsReaction(const std::string &molmrvText)
Definition MarvinParser.h:66
RDKit::v1::MrvDataStreamToMol
RWMol * MrvDataStreamToMol(std::istream *inStream, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:70
RDKit::v1::MrvFileToChemicalReaction
ChemicalReaction * MrvFileToChemicalReaction(const std::string &fName, bool sanitize=false, bool removeHs=false)
Definition MarvinParser.h:123
RDKit::v2::MarvinParser
Definition MarvinParser.h:23
RDKit::v2::MarvinParser::ReactionFromMrvFile
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvFile(const std::string &fName, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::ReactionFromMrvBlock
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvBlock(const std::string &molmrvText, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::MolFromMrvBlock
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvBlock(const std::string &molmrvText, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::MolFromMrvFile
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvFile(const std::string &fName, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::MrvBlockIsReaction
RDKIT_MARVINPARSER_EXPORT bool MrvBlockIsReaction(const std::string &molmrvText)
RDKit::v2::MarvinParser::MrvFileIsReaction
RDKIT_MARVINPARSER_EXPORT bool MrvFileIsReaction(const std::string &fname)
RDKit::v2::MarvinParser::MolFromMrvDataStream
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvDataStream(std::istream &inStream, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::ReactionFromMrvDataStream
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvDataStream(std::istream &inStream, const MrvParserParams &params=MrvParserParams())
RDKit::v2::MarvinParser::MrvDataStreamIsReaction
RDKIT_MARVINPARSER_EXPORT bool MrvDataStreamIsReaction(std::istream &inStream)
RDKit::v2
Definition ReactionParser.h:71
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::MolToMrvBlock
RDKIT_MARVINPARSER_EXPORT std::string MolToMrvBlock(const ROMol &mol, const MrvWriterParams &params, int confId=-1)
RDKit::ChemicalReactionToMrvBlock
RDKIT_MARVINPARSER_EXPORT std::string ChemicalReactionToMrvBlock(const ChemicalReaction &rxn, bool prettyPrint=false)
RDKit::MolToMrvFile
RDKIT_MARVINPARSER_EXPORT void MolToMrvFile(const ROMol &mol, const std::string &fName, const MrvWriterParams &params, int confId=-1)
RDKit::ChemicalReactionToMrvFile
RDKIT_MARVINPARSER_EXPORT void ChemicalReactionToMrvFile(const ChemicalReaction &rxn, const std::string &fName, bool prettyPrint=false)
RDKit::MrvWriterParams
Definition MarvinParser.h:133
RDKit::MrvWriterParams::includeStereo
bool includeStereo
Definition MarvinParser.h:134
RDKit::MrvWriterParams::prettyPrint
bool prettyPrint
Definition MarvinParser.h:137
RDKit::MrvWriterParams::kekulize
bool kekulize
Definition MarvinParser.h:135
RDKit::MrvWriterParams::precision
unsigned int precision
Definition MarvinParser.h:138
RDKit::v2::MarvinParser::MrvParserParams
Definition MarvinParser.h:29
RDKit::v2::MarvinParser::MrvParserParams::sanitize
bool sanitize
Definition MarvinParser.h:30
RDKit::v2::MarvinParser::MrvParserParams::removeHs
bool removeHs
Definition MarvinParser.h:31