35#ifndef __RD_SLNPARSEOPS_H__
36#define __RD_SLNPARSEOPS_H__
44#include <boost/lexical_cast.hpp>
56 if (
mp->hasAtomBookmark(label)) {
57 std::stringstream
err;
58 err <<
"SLN Parser error: Atom ID " << label <<
" used a second time.";
59 throw SLNParseException(
err.str());
61 if (
mp->hasBondBookmark(label)) {
62 std::stringstream
err;
63 err <<
"SLN Parser error: Atom ID " << label
64 <<
" appears *after* its ring closure.";
65 throw SLNParseException(
err.str());
67 mp->setAtomBookmark(atom, label);
72template <
typename BondType>
76 mp->addBond(bond,
true);
80 bond->setIsAromatic(
true);
81 bond->getBeginAtom()->setIsAromatic(
true);
82 bond->getEndAtom()->setIsAromatic(
true);
89template <
typename AtomType>
101 for (
unsigned int i = 0; i <
firstAtom->getNumExplicitHs(); ++i) {
102 int hIdx =
mp->addAtom(
new Atom(1),
false,
true);
115template <
typename AtomType,
typename BondType>
128 bond->setOwningMol(
mp);
137 for (
unsigned int i = 0; i < atom->getNumExplicitHs(); ++i) {
138 int hIdx =
mp->addAtom(
new Atom(1),
false,
true);
141 atom->setNumExplicitHs(0);
145template <
typename AtomType>
156template <
typename BondType>
158 unsigned int ringIdx, BondType *bond,
168 bond->setOwningMol(
mp);
169 bond->setEndAtomIdx(
mp->getActiveAtom()->getIdx());
173 std::stringstream
err;
174 err <<
"SLN Parser error: Ring closure " <<
ringIdx
175 <<
" does not have a corresponding opener.";
184 bond->setBeginAtom(
opener);
202template <
typename BondType>
204 unsigned int branchIdx, BondType *&bond) {
222 for (ROMol::ATOM_BOOKMARK_MAP::const_iterator
bmIt =
223 branch->getAtomBookmarks()->begin();
225 if (
bmIt->first < 0) {
228 if (
mp->hasAtomBookmark(
bmIt->first)) {
229 std::stringstream
err;
230 err <<
"SLN Parser error: Atom ID " <<
bmIt->first
231 <<
" used a second time.";
233 }
else if (
mp->hasBondBookmark(
bmIt->first)) {
234 std::stringstream
err;
235 err <<
"SLN Parser error: Atom ID " <<
bmIt->first
236 <<
" appears *after* its ring closure.";
240 "bad atom bookmark list on branch");
248 for (ROMol::BOND_BOOKMARK_MAP::const_iterator
bmIt =
249 branch->getBondBookmarks()->begin();
252 "bad bond bookmark list on branch");
253 for (ROMol::BOND_PTR_LIST::const_iterator
bondIt =
bmIt->second.begin();
256 if (
bmIt->first > 0 &&
mp->hasAtomBookmark(
bmIt->first)) {
273 bond->setOwningMol(
mp);
322 std::string
res = boost::lexical_cast<std::string>(val);
#define CHECK_INVARIANT(expr, mess)
#define PRECONDITION(expr, mess)
pulls in the core RDKit functionality
pulls in the RDKit Query functionality
The class for representing atoms.
unsigned int getIdx() const
returns our index within the ROMol
void setOwningMol(ROMol *other)
sets our owning molecule
class for representing a bond
RWMol is a molecule class that is intended to be edited.
void addAtomToMol(std::vector< RWMol * > &molList, unsigned int idx, AtomType *atom, BondType *bond, bool doingQuery)
adds an atom to a molecule
int startMol(std::vector< RWMol * > &molList, AtomType *firstAtom, bool doingQuery)
initialize a molecule
int addFragToMol(std::vector< RWMol * > &molList, unsigned int molIdx, unsigned int fragIdx)
int addBranchToMol(std::vector< RWMol * > &molList, unsigned int molIdx, unsigned int branchIdx, BondType *&bond)
std::string convertToString(T val)
convenience function to convert the argument to a string
void closeRingBond(std::vector< RWMol * > &molList, unsigned int molIdx, unsigned int ringIdx, BondType *bond, bool postponeAllowed=true)
RDKIT_RDGENERAL_EXPORT const std::string _AtomID
bool rdvalue_is(const RDValue_cast_t)