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
21namespace RDKit {
22namespace v2 {
23namespace MarvinParser {
24RDKIT_MARVINPARSER_EXPORT bool MrvFileIsReaction(const std::string &fname);
27 const std::string &molmrvText);
28
30 bool sanitize = true; /**< sanitize the molecule after building it */
31 bool removeHs = true; /**< remove Hs after constructing the molecule */
32};
33
35 std::istream &inStream, const MrvParserParams &params = MrvParserParams());
37 const std::string &molmrvText,
38 const MrvParserParams &params = MrvParserParams());
40 const std::string &fName,
41 const MrvParserParams &params = MrvParserParams());
42
43RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
44ReactionFromMrvDataStream(std::istream &inStream,
45 const MrvParserParams &params = MrvParserParams());
46RDKIT_MARVINPARSER_EXPORT std::unique_ptr<ChemicalReaction>
47ReactionFromMrvBlock(const std::string &molmrvText,
48 const MrvParserParams &params = MrvParserParams());
49RDKIT_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 {
56inline bool MrvFileIsReaction(const std::string &fname) {
58}
59inline bool MrvDataStreamIsReaction(std::istream *inStream) {
61}
62
63inline bool MrvDataStreamIsReaction(std::istream &inStream) {
65}
66inline bool MrvBlockIsReaction(const std::string &molmrvText) {
67 return v2::MarvinParser::MrvBlockIsReaction(molmrvText);
68}
69
70inline RWMol *MrvDataStreamToMol(std::istream *inStream, bool sanitize = false,
71 bool removeHs = false) {
73 params.sanitize = sanitize;
74 params.removeHs = removeHs;
75 return v2::MarvinParser::MolFromMrvDataStream(*inStream, params).release();
76}
77inline RWMol *MrvDataStreamToMol(std::istream &inStream, bool sanitize = false,
78 bool removeHs = false) {
80 params.sanitize = sanitize;
81 params.removeHs = removeHs;
82 return v2::MarvinParser::MolFromMrvDataStream(inStream, params).release();
83}
84inline RWMol *MrvBlockToMol(const std::string &molmrvText,
85 bool sanitize = false, bool removeHs = false) {
87 params.sanitize = sanitize;
88 params.removeHs = removeHs;
89 return v2::MarvinParser::MolFromMrvBlock(molmrvText, params).release();
90}
91inline RWMol *MrvFileToMol(const std::string &fName, bool sanitize = false,
92 bool removeHs = false) {
94 params.sanitize = sanitize;
95 params.removeHs = removeHs;
96 return v2::MarvinParser::MolFromMrvFile(fName, params).release();
97}
98
100 std::istream *inStream, bool sanitize = false, bool removeHs = false) {
102 params.sanitize = sanitize;
103 params.removeHs = removeHs;
104 return v2::MarvinParser::ReactionFromMrvDataStream(*inStream, params)
105 .release();
106}
108 std::istream &inStream, bool sanitize = false, bool removeHs = false) {
110 params.sanitize = sanitize;
111 params.removeHs = removeHs;
112 return v2::MarvinParser::ReactionFromMrvDataStream(inStream, params)
113 .release();
114}
116 const std::string &molmrvText, bool sanitize = false,
117 bool removeHs = false) {
119 params.sanitize = sanitize;
120 params.removeHs = removeHs;
121 return v2::MarvinParser::ReactionFromMrvBlock(molmrvText, params).release();
122}
123inline ChemicalReaction *MrvFileToChemicalReaction(const std::string &fName,
124 bool sanitize = false,
125 bool removeHs = false) {
127 params.sanitize = sanitize;
128 params.removeHs = removeHs;
129 return v2::MarvinParser::ReactionFromMrvFile(fName, params).release();
130}
131} // namespace v1
132
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 */
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 */
162inline 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 */
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 */
186inline 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
194 const ChemicalReaction &rxn, bool prettyPrint = false);
195
197 const ChemicalReaction &rxn, const std::string &fName,
198 bool prettyPrint = false);
199} // namespace RDKit
200
201#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:281
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.
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)