12#ifndef _RD_MOLWRITERS_H_
13#define _RD_MOLWRITERS_H_
20#include <boost/noncopyable.hpp>
22#ifdef RDK_BUILD_MAEPARSER_SUPPORT
23namespace schrodinger {
70 SmilesWriter(
const std::string &fileName,
const std::string &delimiter =
" ",
71 const std::string &nameHeader =
"Name",
72 bool includeHeader =
true,
bool isomericSmiles =
true,
73 bool kekuleSmiles =
false);
76 std::string nameHeader =
"Name",
bool includeHeader =
true,
77 bool takeOwnership =
false,
bool isomericSmiles =
true,
78 bool kekuleSmiles =
false);
96 if (dp_ostream->good()) {
97 dp_ostream->setstate(std::ios::badbit);
99 }
catch (
const std::runtime_error &) {
113 dp_ostream =
nullptr;
117 unsigned int numMols()
const override {
return d_molid; }
121 void init(
const std::string &delimiter,
const std::string &nameHeader,
122 bool includeHeader,
bool isomericSmiles,
bool kekuleSmiles);
125 void dumpHeader()
const;
127 std::ostream *dp_ostream;
129 bool df_includeHeader;
130 unsigned int d_molid;
132 std::string d_nameHeader;
134 bool df_isomericSmiles;
135 bool df_kekuleSmiles;
153 SDWriter(std::ostream *outStream,
bool takeOwnership =
false);
163 bool kekulize =
true,
bool force_V3000 =
false,
164 int molid = -1,
STR_VECT *propNames =
nullptr);
176 if (dp_ostream->good()) {
177 dp_ostream->setstate(std::ios::badbit);
179 }
catch (
const std::runtime_error &) {
193 dp_ostream =
nullptr;
197 unsigned int numMols()
const override {
return d_molid; }
206 void writeProperty(
const ROMol &mol,
const std::string &name);
208 std::ostream *dp_ostream;
210 unsigned int d_molid;
231 TDTWriter(std::ostream *outStream,
bool takeOwnership =
false);
249 if (dp_ostream->good()) {
250 dp_ostream->setstate(std::ios::badbit);
252 }
catch (
const std::runtime_error &) {
262 *dp_ostream <<
"|\n";
270 dp_ostream =
nullptr;
274 unsigned int numMols()
const override {
return d_molid; }
286 void writeProperty(
const ROMol &mol,
const std::string &name);
288 std::ostream *dp_ostream;
290 unsigned int d_molid;
302 PDBWriter(
const std::string &fileName,
unsigned int flavor = 0);
303 PDBWriter(std::ostream *outStream,
bool takeOwnership =
false,
304 unsigned int flavor = 0);
319 if (dp_ostream->good()) {
320 dp_ostream->setstate(std::ios::badbit);
322 }
catch (
const std::runtime_error &) {
336 dp_ostream =
nullptr;
340 unsigned int numMols()
const override {
return d_count; }
343 std::ostream *dp_ostream;
344 unsigned int d_flavor;
345 unsigned int d_count;
349#ifdef RDK_BUILD_MAEPARSER_SUPPORT
377 MaeWriter(
const std::string &fileName);
382 MaeWriter(std::ostream *outStream);
384 MaeWriter(std::shared_ptr<std::ostream> outStream);
386 ~MaeWriter()
override;
390 void setProps(
const STR_VECT &propNames)
override;
393 static std::string getText(
const ROMol &mol,
int confId = defaultConfId,
394 const STR_VECT &propNames = STR_VECT());
397 void write(
const ROMol &mol,
int confId = defaultConfId)
override;
400 void flush()
override;
402 void close()
override;
405 unsigned int numMols()
const override {
return d_molid; }
408 MaeWriter() =
default;
410 std::shared_ptr<std::ostream> dp_ostream;
415 std::unique_ptr<schrodinger::mae::Writer> dp_writer;
416 unsigned d_molid = 0;
#define PRECONDITION(expr, mess)
Defines the primary molecule class ROMol as well as associated typedefs.
virtual void write(const ROMol &mol, int confId=defaultConfId)=0
virtual void setProps(const STR_VECT &propNames)=0
virtual unsigned int numMols() const =0
PDBWriter(const std::string &fileName, unsigned int flavor=0)
void write(const ROMol &mol, int confId=defaultConfId) override
write a new molecule to the file
void flush() override
flush the ostream
PDBWriter(std::ostream *outStream, bool takeOwnership=false, unsigned int flavor=0)
void setProps(const STR_VECT &) override
unsigned int numMols() const override
get the number of molecules written so far
void close() override
close our stream (the writer cannot be used again)
bool getForceV3000() const
unsigned int numMols() const override
get the number of molecules written so far
SDWriter(std::ostream *outStream, bool takeOwnership=false)
void flush() override
flush the ostream
void setProps(const STR_VECT &propNames) override
set a vector of property names that are need to be written out for each molecule
void write(const ROMol &mol, int confId=defaultConfId) override
write a new molecule to the file
static std::string getText(const ROMol &mol, int confId=defaultConfId, bool kekulize=true, bool force_V3000=false, int molid=-1, STR_VECT *propNames=nullptr)
return the text that would be written to the file
void close() override
close our stream (the writer cannot be used again)
void setForceV3000(bool val)
SDWriter(const std::string &fileName)
void setKekulize(bool val)
unsigned int numMols() const override
get the number of molecules written so far
SmilesWriter(const std::string &fileName, const std::string &delimiter=" ", const std::string &nameHeader="Name", bool includeHeader=true, bool isomericSmiles=true, bool kekuleSmiles=false)
void write(const ROMol &mol, int confId=defaultConfId) override
write a new molecule to the file
SmilesWriter(std::ostream *outStream, std::string delimiter=" ", std::string nameHeader="Name", bool includeHeader=true, bool takeOwnership=false, bool isomericSmiles=true, bool kekuleSmiles=false)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setProps(const STR_VECT &propNames) override
set a vector of property names that are need to be written out for each molecule
void close() override
close our stream (the writer cannot be used again)
void flush() override
flush the ostream
void setNumDigits(unsigned int numDigits)
void setWrite2D(bool state=true)
void setProps(const STR_VECT &propNames) override
set a vector of property names that are need to be written out for each molecule
unsigned int numMols() const override
get the number of molecules written so far
unsigned int getNumDigits() const
TDTWriter(std::ostream *outStream, bool takeOwnership=false)
void close() override
close our stream (the writer cannot be used again)
TDTWriter(const std::string &fileName)
void write(const ROMol &mol, int confId=defaultConfId) override
write a new molecule to the file
void setWriteNames(bool state=true)
void flush() override
flush the ostream
bool getWriteNames() const
#define RDKIT_FILEPARSERS_EXPORT
std::vector< std::string > STR_VECT