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>
18
19#include <string>
20#include <iostream>
21
22namespace RDKit {
23namespace v2 {
24namespace MarvinParser {
28 const std::string &molmrvText);
29
31 bool sanitize = true; /**< sanitize the molecule after building it */
32 bool removeHs = true; /**< remove Hs after constructing the molecule */
33};
34
36 std::istream &inStream, const MrvParserParams &params = MrvParserParams());
38 const std::string &molmrvText,
39 const MrvParserParams &params = MrvParserParams());
41 const std::string &fName,
42 const MrvParserParams &params = MrvParserParams());
43
44RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
46 const MrvParserParams &params = MrvParserParams());
47RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
49 const MrvParserParams &params = MrvParserParams());
50RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction> ReactionFromMrvFile(
51 const std::string &fName,
52 const MrvParserParams &params = MrvParserParams());
53} // namespace MarvinParser
54} // namespace v2
55
56inline namespace v1 {
57inline bool MrvFileIsReaction(const std::string &fname) {
59}
63
67inline bool MrvBlockIsReaction(const std::string &molmrvText) {
69}
70
71inline RWMol *MrvDataStreamToMol(std::istream *inStream, bool sanitize = false,
72 bool removeHs = false) {
74 params.sanitize = sanitize;
75 params.removeHs = removeHs;
76 return v2::MarvinParser::MolFromMrvDataStream(*inStream, params).release();
77}
78inline RWMol *MrvDataStreamToMol(std::istream &inStream, bool sanitize = false,
79 bool removeHs = false) {
81 params.sanitize = sanitize;
82 params.removeHs = removeHs;
83 return v2::MarvinParser::MolFromMrvDataStream(inStream, params).release();
84}
85inline RWMol *MrvBlockToMol(const std::string &molmrvText,
86 bool sanitize = false, bool removeHs = false) {
88 params.sanitize = sanitize;
89 params.removeHs = removeHs;
90 return v2::MarvinParser::MolFromMrvBlock(molmrvText, params).release();
91}
92inline RWMol *MrvFileToMol(const std::string &fName, bool sanitize = false,
93 bool removeHs = false) {
95 params.sanitize = sanitize;
96 params.removeHs = removeHs;
97 return v2::MarvinParser::MolFromMrvFile(fName, params).release();
98}
99
101 std::istream *inStream, bool sanitize = false, bool removeHs = false) {
103 params.sanitize = sanitize;
104 params.removeHs = removeHs;
106 .release();
107}
109 std::istream &inStream, bool sanitize = false, bool removeHs = false) {
111 params.sanitize = sanitize;
112 params.removeHs = removeHs;
114 .release();
115}
117 const std::string &molmrvText, bool sanitize = false,
118 bool removeHs = false) {
120 params.sanitize = sanitize;
121 params.removeHs = removeHs;
122 return v2::MarvinParser::ReactionFromMrvBlock(molmrvText, params).release();
123}
125 bool sanitize = false,
126 bool removeHs = false) {
128 params.sanitize = sanitize;
129 params.removeHs = removeHs;
130 return v2::MarvinParser::ReactionFromMrvFile(fName, params).release();
131}
132} // namespace v1
133
135 bool includeStereo = true; /**< toggles inclusion of stereochemical */
136 bool kekulize =
137 true; /**< triggers kekulization of the molecule before it's written */
138 bool prettyPrint = false; /**< makes the output more human readable */
139 unsigned int precision = 6; /**< precision of the coordinates */
140};
141
142// \brief Writes a Marvin (MRV) file for a molecule
143/*!
144 * \param mol - the molecule
145 * \param fName - the file to write to
146 * \param params - marvin write params
147 * \param confId - selects which conformation to output
148 */
150 const std::string &fName,
151 const MrvWriterParams &params,
152 int confId = -1);
153
154// \brief Writes a Marvin (MRV) file for a molecule
155/*!
156 * \param mol - the molecule
157 * \param fName - the file to write to
158 * \param includeStereo - toggles inclusion of stereochemical information in
159 * the output \param confId - selects which conformation to output \param
160 * kekulize - triggers kekulization of the molecule before it's written
161 * \param prettyPrint - makes the output more human readable
162 */
163inline void MolToMrvFile(const ROMol &mol, const std::string &fName,
164 bool includeStereo = true, int confId = -1,
165 bool kekulize = true, bool prettyPrint = false) {
166 MrvWriterParams params{includeStereo, kekulize, prettyPrint};
167 MolToMrvFile(mol, fName, params, confId);
168}
169
170// \brief Returns a Marvin (Mrv) Mol block for a molecule
171/*!
172 * \param mol - the molecule
173 * \param params - marvin write params
174 * \param confId - selects which conformation to output
175 */
177 const ROMol &mol, const MrvWriterParams &params, int confId = -1);
178
179// \brief Returns a Marvin (Mrv) Mol block for a molecule
180/*!
181 * \param mol - the molecule
182 * \param includeStereo - toggles inclusion of stereochemical information in
183 * the output \param confId - selects which conformation to output \param
184 * kekulize - triggers kekulization of the molecule before it's written
185 * \param prettyPrint - makes the output more human readable
186 */
187inline std::string MolToMrvBlock(const ROMol &mol, bool includeStereo = true,
188 int confId = -1, bool kekulize = true,
189 bool prettyPrint = false) {
190 MrvWriterParams params{includeStereo, kekulize, prettyPrint};
191 return MolToMrvBlock(mol, params, confId);
192}
193
195 const ChemicalReaction &rxn, bool prettyPrint = false);
196
198 const ChemicalReaction &rxn, const std::string &fName,
199 bool prettyPrint = false);
200} // namespace RDKit
201
202#endif
pulls in the core RDKit functionality
This is a class for storing and applying general chemical reactions.
Definition Reaction.h:121
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
#define RDKIT_MARVINPARSER_EXPORT
Definition export.h:265
ChemicalReaction * MrvDataStreamToChemicalReaction(std::istream *inStream, bool sanitize=false, bool removeHs=false)
bool MrvFileIsReaction(const std::string &fname)
RWMol * MrvFileToMol(const std::string &fName, bool sanitize=false, bool removeHs=false)
RWMol * MrvBlockToMol(const std::string &molmrvText, bool sanitize=false, bool removeHs=false)
bool MrvDataStreamIsReaction(std::istream *inStream)
ChemicalReaction * MrvBlockToChemicalReaction(const std::string &molmrvText, bool sanitize=false, bool removeHs=false)
bool MrvBlockIsReaction(const std::string &molmrvText)
RWMol * MrvDataStreamToMol(std::istream *inStream, bool sanitize=false, bool removeHs=false)
ChemicalReaction * MrvFileToChemicalReaction(const std::string &fName, bool sanitize=false, bool removeHs=false)
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvFile(const std::string &fName, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvBlock(const std::string &molmrvText, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvBlock(const std::string &molmrvText, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvFile(const std::string &fName, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT bool MrvBlockIsReaction(const std::string &molmrvText)
RDKIT_MARVINPARSER_EXPORT bool MrvFileIsReaction(const std::string &fname)
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< RWMol > MolFromMrvDataStream(std::istream &inStream, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT std::unique_ptr< ChemicalReaction > ReactionFromMrvDataStream(std::istream &inStream, const MrvParserParams &params=MrvParserParams())
RDKIT_MARVINPARSER_EXPORT bool MrvDataStreamIsReaction(std::istream &inStream)
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
RDKIT_MARVINPARSER_EXPORT std::string MolToMrvBlock(const ROMol &mol, const MrvWriterParams &params, int confId=-1)
RDKIT_MARVINPARSER_EXPORT std::string ChemicalReactionToMrvBlock(const ChemicalReaction &rxn, bool prettyPrint=false)
RDKIT_MARVINPARSER_EXPORT void MolToMrvFile(const ROMol &mol, const std::string &fName, const MrvWriterParams &params, int confId=-1)
RDKIT_MARVINPARSER_EXPORT void ChemicalReactionToMrvFile(const ChemicalReaction &rxn, const std::string &fName, bool prettyPrint=false)