11#ifndef RD_SMILESWRITE_H_012020
12#define RD_SMILESWRITE_H_012020
20#include <boost/shared_ptr.hpp>
30 bool doIsomericSmiles =
32 bool doKekule =
false;
36 bool canonical =
true;
37 bool cleanStereo =
true;
38 bool allBondsExplicit =
false;
39 bool allHsExplicit =
false;
40 bool doRandom =
false;
42 int rootedAtAtom = -1;
44 bool includeDativeBonds =
47 bool ignoreAtomMapNumbers =
false;
51namespace SmilesWrite {
53#define CXSMILESFIELDS_ENUM_ITEMS \
54 CXSMILESFIELDS_ENUM_ITEM(CX_NONE, 0) \
55 CXSMILESFIELDS_ENUM_ITEM(CX_ATOM_LABELS, 1 << 0) \
56 CXSMILESFIELDS_ENUM_ITEM(CX_MOLFILE_VALUES, 1 << 1) \
57 CXSMILESFIELDS_ENUM_ITEM(CX_COORDS, 1 << 2) \
58 CXSMILESFIELDS_ENUM_ITEM(CX_RADICALS, 1 << 3) \
59 CXSMILESFIELDS_ENUM_ITEM(CX_ATOM_PROPS, 1 << 4) \
60 CXSMILESFIELDS_ENUM_ITEM(CX_LINKNODES, 1 << 5) \
61 CXSMILESFIELDS_ENUM_ITEM(CX_ENHANCEDSTEREO, 1 << 6) \
62 CXSMILESFIELDS_ENUM_ITEM(CX_SGROUPS, 1 << 7) \
63 CXSMILESFIELDS_ENUM_ITEM(CX_POLYMER, 1 << 8) \
64 CXSMILESFIELDS_ENUM_ITEM(CX_BOND_CFG, 1 << 9) \
65 CXSMILESFIELDS_ENUM_ITEM(CX_BOND_ATROPISOMER, 1 << 10) \
66 CXSMILESFIELDS_ENUM_ITEM(CX_COORDINATE_BONDS, 1 << 11) \
67 CXSMILESFIELDS_ENUM_ITEM(CX_ALL, 0x7fffffff) \
68 CXSMILESFIELDS_ENUM_ITEM(CX_ALL_BUT_COORDS, CX_ALL ^ CX_COORDS)
70#define CXSMILESFIELDS_ENUM_ITEM(k, v) k = (v),
72#undef CXSMILESFIELDS_ENUM_ITEM
73#define CXSMILESFIELDS_STD_MAP_ITEM(k) {#k, SmilesWrite::CXSmilesFields::k},
74#define CXSMILESFIELDS_ENUM_ITEM(k, v) CXSMILESFIELDS_STD_MAP_ITEM(k)
75#define CXSMILESFIELDS_ITEMS_MAP \
76 std::map<std::string, SmilesWrite::CXSmilesFields> { \
77 CXSMILESFIELDS_ENUM_ITEMS \
82 const ROMol &mol, std::uint32_t flags = CXSmilesFields::CX_ALL);
86 const std::vector<ROMol *> &mols, std::uint32_t flags);
110 const Bond * =
nullptr,
111 bool allHsExplicit =
false,
116 ps.doKekule = doKekule;
117 ps.allHsExplicit = allHsExplicit;
141 bool doKekule =
false,
142 bool allBondsExplicit =
false) {
145 ps.allBondsExplicit = allBondsExplicit;
146 ps.doIsomericSmiles =
false;
183 bool doKekule =
false,
int rootedAtAtom = -1,
184 bool canonical =
true,
185 bool allBondsExplicit =
false,
186 bool allHsExplicit =
false,
187 bool doRandom =
false,
188 bool ignoreAtomMapNumbers =
false) {
191 ps.doKekule = doKekule;
192 ps.rootedAtAtom = rootedAtAtom;
193 ps.canonical = canonical;
194 ps.allBondsExplicit = allBondsExplicit;
195 ps.allHsExplicit = allHsExplicit;
196 ps.doRandom = doRandom;
197 ps.ignoreAtomMapNumbers = ignoreAtomMapNumbers;
215 const ROMol &mol,
unsigned int numSmiles,
unsigned int randomSeed = 0,
216 bool doIsomericSmiles =
true,
bool doKekule =
false,
217 bool allBondsExplicit =
false,
bool allHsExplicit =
false);
224 const std::vector<std::string> *atomSymbols =
nullptr,
225 const std::vector<std::string> *
bondSymbols =
nullptr);
255 const std::vector<std::string> *atomSymbols =
nullptr,
256 const std::vector<std::string> *
bondSymbols =
nullptr,
257 bool doIsomericSmiles =
true,
bool doKekule =
false,
int rootedAtAtom = -1,
258 bool canonical =
true,
bool allBondsExplicit =
false,
259 bool allHsExplicit =
false) {
262 ps.doKekule = doKekule;
263 ps.rootedAtAtom = rootedAtAtom;
264 ps.canonical = canonical;
265 ps.allBondsExplicit = allBondsExplicit;
266 ps.allHsExplicit = allHsExplicit;
271#define RESTOREBONDDIROPTION_ENUM_ITEMS \
272 RESTOREBONDDIROPTION_ENUM_ITEM(RestoreBondDirOptionTrue, \
274 RESTOREBONDDIROPTION_ENUM_ITEM(RestoreBondDirOptionClear, \
277#define RESTOREBONDDIROPTION_ENUM_ITEM(k, v) k = v,
279#undef RESTOREBONDDIROPTION_ENUM_ITEM
280#define RESTOREBONDDIROPTION_STD_MAP_ITEM(k) {#k, k},
281#define RESTOREBONDDIROPTION_ENUM_ITEM(k, v) \
282 RESTOREBONDDIROPTION_STD_MAP_ITEM(k)
283#define RESTOREBONDDIROPTION_ITEMS_MAP \
284 std::map<std::string, RestoreBondDirOption> { \
285 RESTOREBONDDIROPTION_ENUM_ITEMS \
291 std::uint32_t flags = SmilesWrite::CXSmilesFields::CX_ALL,
311 bool doKekule =
false,
int rootedAtAtom = -1,
312 bool canonical =
true,
313 bool allBondsExplicit =
false,
314 bool allHsExplicit =
false,
315 bool doRandom =
false) {
318 ps.doKekule = doKekule;
319 ps.rootedAtAtom = rootedAtAtom;
320 ps.canonical = canonical;
321 ps.allBondsExplicit = allBondsExplicit;
322 ps.allHsExplicit = allHsExplicit;
323 ps.doRandom = doRandom;
332 const std::vector<std::string> *atomSymbols =
nullptr,
333 const std::vector<std::string> *
bondSymbols =
nullptr);
361 const std::vector<std::string> *atomSymbols =
nullptr,
362 const std::vector<std::string> *
bondSymbols =
nullptr,
363 bool doIsomericSmiles =
true,
bool doKekule =
false,
int rootedAtAtom = -1,
364 bool canonical =
true,
bool allBondsExplicit =
false,
365 bool allHsExplicit =
false) {
368 ps.doKekule = doKekule;
369 ps.rootedAtAtom = rootedAtAtom;
370 ps.canonical = canonical;
371 ps.allBondsExplicit = allBondsExplicit;
372 ps.allHsExplicit = allHsExplicit;
The class for representing atoms.
class for representing a bond
#define RDKIT_SMILESPARSE_EXPORT
RDKIT_SMILESPARSE_EXPORT std::string MolToSmiles(const ROMol &mol, const SmilesWriteParams ¶ms, bool doingCXSmiles)
RDKIT_SMILESPARSE_EXPORT std::string GetAtomSmiles(const Atom *atom, const SmilesWriteParams &ps)
returns the SMILES for an atom
RDKIT_SMILESPARSE_EXPORT bool inOrganicSubset(int atomicNumber)
returns true if the atom number is in the SMILES organic subset
@ CXSMILESFIELDS_ENUM_ITEMS
RDKIT_SMILESPARSE_EXPORT std::string GetBondSmiles(const Bond *bond, const SmilesWriteParams &ps, int atomToLeftIdx=-1)
returns the SMILES for a bond
RDKIT_SMILESPARSE_EXPORT std::string getCXExtensions(const ROMol &mol, std::uint32_t flags=CXSmilesFields::CX_ALL)
returns the cxsmiles data for a molecule
RDKIT_SMILESPARSE_EXPORT std::vector< std::string > MolToRandomSmilesVect(const ROMol &mol, unsigned int numSmiles, unsigned int randomSeed=0, bool doIsomericSmiles=true, bool doKekule=false, bool allBondsExplicit=false, bool allHsExplicit=false)
returns a vector of random SMILES for a molecule (may contain duplicates)
void updateSmilesWriteParamsFromJSON(SmilesWriteParams ¶ms, const std::string &details_json)
bool rdvalue_is(const RDValue_cast_t)
RDKIT_SMILESPARSE_EXPORT std::string MolFragmentToSmiles(const ROMol &mol, const SmilesWriteParams ¶ms, const std::vector< int > &atomsToUse, const std::vector< int > *bondsToUse=nullptr, const std::vector< std::string > *atomSymbols=nullptr, const std::vector< std::string > *bondSymbols=nullptr)
returns canonical SMILES for part of a molecule
RDKIT_SMILESPARSE_EXPORT std::string MolToSmiles(const ROMol &mol, const SmilesWriteParams ¶ms)
returns canonical SMILES for a molecule
RDKIT_SMILESPARSE_EXPORT std::string MolToCXSmiles(const ROMol &mol, const SmilesWriteParams &ps, std::uint32_t flags=SmilesWrite::CXSmilesFields::CX_ALL, RestoreBondDirOption restoreBondDirs=RestoreBondDirOptionClear)
returns canonical CXSMILES for a molecule
void updateCXSmilesFieldsFromJSON(SmilesWrite::CXSmilesFields &cxSmilesFields, RestoreBondDirOption &restoreBondDirs, const std::string &details_json)
RDKIT_SMILESPARSE_EXPORT std::string MolFragmentToCXSmiles(const ROMol &mol, const SmilesWriteParams ¶ms, const std::vector< int > &atomsToUse, const std::vector< int > *bondsToUse=nullptr, const std::vector< std::string > *atomSymbols=nullptr, const std::vector< std::string > *bondSymbols=nullptr)
returns canonical CXSMILES for part of a molecule
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
@ RESTOREBONDDIROPTION_ENUM_ITEMS