11#ifndef RD_FILEPARSERUTILS_H
12#define RD_FILEPARSERUTILS_H
17#include <boost/lexical_cast.hpp>
18#include <boost/algorithm/string.hpp>
19#include <boost/format.hpp>
28namespace FileParserUtils {
33 if (
start != std::string_view::npos) {
48 return boost::lexical_cast<T>(
trimmed);
71 int confId = -1,
unsigned int precision = 6);
74 unsigned int precision = 6) {
86 bool strictParsing =
true,
bool expectMEND =
true);
92 bool strictParsing =
true);
101 bool sanitize,
bool removeHs) {
104 ps.removeHs = removeHs;
114 const std::string &
prefix,
118 std::vector<std::string>
tokens;
120 boost::token_compress_on);
123 <<
"Property list " <<
pn <<
" too short, only " <<
tokens.size()
124 <<
" elements found. Ignoring it." << std::endl;
130 tokens[0].back() ==
']') {
136 <<
" is empty." << std::endl;
142 T
apv = boost::lexical_cast<T>(
tokens[i]);
144 }
catch (
const boost::bad_lexical_cast &) {
146 <<
"Value " <<
tokens[i] <<
" for property " <<
pn <<
" of atom "
147 <<
atomid <<
" can not be parsed. Ignoring it." << std::endl;
168 ROMol &mol,
const std::string
pn,
212 for (
const auto &atom : mol.
atoms()) {
216 apVal = boost::lexical_cast<std::string>(
tVal);
#define BOOST_LOG(__arg__)
RDKIT_RDGENERAL_EXPORT RDLogger rdWarningLog
The class for representing atoms.
void getProp(const std::string &key, T &res) const
allows retrieval of a particular property value
void setProp(const std::string &key, T val, bool computed=false) const
sets a property value
STR_VECT getPropList(bool includePrivate=true, bool includeComputed=true) const
returns a list with the names of our properties
Atom * getAtomWithIdx(unsigned int idx)
returns a pointer to a particular Atom
unsigned int getNumAtoms() const
returns our number of atoms
CXXAtomIterator< MolGraph, Atom * > atoms()
C++11 Range iterator.
RWMol is a molecule class that is intended to be edited.
#define RDKIT_FILEPARSERS_EXPORT
void processMolPropertyList(ROMol &mol, const std::string pn, const std::string &missingValueMarker="n/a")
RDKIT_FILEPARSERS_EXPORT void moveAdditionalPropertiesToSGroups(RWMol &mol)
RDKIT_FILEPARSERS_EXPORT std::string getV3000CTAB(const ROMol &tmol, const boost::dynamic_bitset<> &wasAromatic, int confId=-1, unsigned int precision=6)
void createAtomDoublePropertyList(ROMol &mol, const std::string &atomPropName, const std::string &missingValueMarker="", unsigned int lineSize=190)
RDKIT_FILEPARSERS_EXPORT double toDouble(const std::string &input, bool acceptSpaces=true)
void createAtomIntPropertyList(ROMol &mol, const std::string &atomPropName, const std::string &missingValueMarker="", unsigned int lineSize=190)
RDKIT_FILEPARSERS_EXPORT int toInt(const std::string &input, bool acceptSpaces=true)
RDKIT_FILEPARSERS_EXPORT Atom * replaceAtomWithQueryAtom(RWMol *mol, Atom *atom)
Deprecated, please use QueryOps::replaceAtomWithQueryAtom instead.
T stripSpacesAndCast(std::string_view input, bool acceptSpaces=false)
void createAtomStringPropertyList(ROMol &mol, const std::string &atomPropName, const std::string &missingValueMarker="", unsigned int lineSize=190)
void applyMolListPropToAtoms(ROMol &mol, const std::string &pn, const std::string &prefix, const std::string &missingValueMarker="n/a")
applies a particular property to the atoms as an atom property list
std::string getAtomPropertyList(ROMol &mol, const std::string &atomPropName, std::string missingValueMarker="", unsigned int lineSize=190)
RDKIT_FILEPARSERS_EXPORT void finishMolProcessing(RWMol *res, bool chiralityPossible, const v2::FileParsers::MolFileParserParams &ps)
RDKIT_FILEPARSERS_EXPORT std::string_view strip(std::string_view orig, std::string stripChars=" \t\r\n")
void applyMolListPropsToAtoms(ROMol &mol, const std::string &prefix, const std::string missingValueMarker="n/a")
RDKIT_FILEPARSERS_EXPORT bool ParseV3000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol, Conformer *&conf, bool &chiralityPossible, unsigned int &nAtoms, unsigned int &nBonds, bool strictParsing=true, bool expectMEND=true)
void processMolPropertyLists(ROMol &mol, const std::string &missingValueMarker="n/a")
RDKIT_FILEPARSERS_EXPORT bool ParseV2000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol, Conformer *&conf, bool &chiralityPossible, unsigned int &nAtoms, unsigned int &nBonds, bool strictParsing=true)
static const std::string atomPropPrefix
RDKIT_FILEPARSERS_EXPORT std::string getV3000Line(std::istream *inStream, unsigned int &line)
RDKIT_FILEPARSERS_EXPORT unsigned int toUnsigned(const std::string &input, bool acceptSpaces=true)
void createAtomBoolPropertyList(ROMol &mol, const std::string &atomPropName, const std::string &missingValueMarker="", unsigned int lineSize=190)
bool rdvalue_is(const RDValue_cast_t)