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 = 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 */
149 const ROMol &mol, const std::string &fName, const MrvWriterParams &params, int confId = -1);
150
151// \brief Writes a Marvin (MRV) file for a molecule
152/*!
153 * \param mol - the molecule
154 * \param fName - the file to write to
155 * \param includeStereo - toggles inclusion of stereochemical information in the output
156 * \param confId - selects which conformation to output
157 * \param kekulize - triggers kekulization of the molecule before it's written
158 * \param prettyPrint - makes the output more human readable
159 */
160inline void MolToMrvFile(
161 const ROMol &mol, const std::string &fName, bool includeStereo = true,
162 int confId = -1, bool kekulize = true, bool prettyPrint = false) {
163 MrvWriterParams params{includeStereo, kekulize, prettyPrint};
164 MolToMrvFile(mol, fName, params, confId);
165}
166
167// \brief Returns a Marvin (Mrv) Mol block for a molecule
168/*!
169 * \param mol - the molecule
170 * \param params - marvin write params
171 * \param confId - selects which conformation to output
172 */
174 const MrvWriterParams &params,
175 int confId = -1);
176
177// \brief Returns a Marvin (Mrv) Mol block for a molecule
178/*!
179 * \param mol - the molecule
180 * \param includeStereo - toggles inclusion of stereochemical information in the output
181 * \param confId - selects which conformation to output
182 * \param kekulize - triggers kekulization of the molecule before it's written
183 * \param prettyPrint - makes the output more human readable
184 */
185inline std::string MolToMrvBlock(const ROMol &mol,
186 bool includeStereo = true,
187 int confId = -1,
188 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)