1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
//
// Copyright (C) 2002-2021 Greg Landrum and T5 Informatics GmbH
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#pragma once
#include <RDGeneral/BoostStartInclude.h>
#include <boost/algorithm/string/trim.hpp>
#include <boost/format.hpp>
#include <RDGeneral/BoostEndInclude.h>
#include <GraphMol/SubstanceGroup.h>
namespace RDKit {
namespace SGroupWriting {
typedef std::unordered_map<int, SubstanceGroup> IDX_TO_SGROUP_MAP;
/* ------------------ Inlined Formatters ------------------ */
inline std::string FormatV2000IntField(int value) {
auto fmt = boost::format(" %3d") % value;
return fmt.str();
}
inline std::string FormatV2000NumEntriesField(int value) {
auto fmt = boost::format(" %2d") % value;
return fmt.str();
}
inline std::string FormatV2000DoubleField(double value) {
auto fmt = boost::format("%10.4f") % value;
return fmt.str();
}
inline std::string FormatV2000StringField(const std::string &value,
unsigned int fieldSize, bool pad,
bool addSeparator) {
std::ostringstream os;
if (addSeparator) {
os << ' ';
}
if (value.size() >= fieldSize) {
os << value.substr(0, fieldSize);
} else if (pad) {
os << std::setw(fieldSize) << std::left << value;
} else {
os << value;
}
return os.str();
}
inline std::string FormatV3000DoubleField(double value) {
return boost::trim_copy(FormatV2000DoubleField(value));
}
/* ------------------ V2000 Utils ------------------ */
std::string BuildV2000STYLines(const ROMol &mol);
std::string BuildV2000StringPropLines(const unsigned int entriesPerLine,
const ROMol &mol,
const std::string &propName,
const std::string &propCode,
const unsigned int fieldWitdh);
std::string BuildV2000SLBLines(const ROMol &mol);
std::string BuildV2000SDSLines(const ROMol &mol);
std::string BuildV2000SPLLines(const ROMol &mol);
std::string BuildV2000SNCLines(const ROMol &mol);
std::string BuildV2000SBTLines(const ROMol &mol);
template <class T>
std::string BuildV2000IdxVectorDataLines(const unsigned int entriesPerLine,
const unsigned int sGroupId,
const std::string &code,
const T &dataVector);
std::string BuildV2000SMTLine(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SDILine(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SBVLine(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SDTLine(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SDDLine(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SCDSEDLines(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SAPLines(const int idx, const SubstanceGroup *sgroup);
std::string BuildV2000SCLLine(const int idx, const SubstanceGroup *sgroup);
const std::string GetMolFileSGroupInfo(const RWMol &mol);
/* ------------------ V3000 Utils ------------------ */
template <class T>
std::string BuildV3000IdxVectorDataBlock(const std::string &key,
const std::vector<T *> &dataVector);
template <class Iterator>
std::string BuildV3000IdxVectorDataBlock(const std::string &key,
const Iterator &dataVectorBegin,
const Iterator &dataVectorEnd);
/* Classify bonds between XBONDS and CBOfindP work on a copy of
* bonds vector to prevent reordering of original vector */
std::string BuildV3000BondsBlock(const SubstanceGroup &sgroup);
std::string FormatV3000StringPropertyBlock(const std::string &prop,
const SubstanceGroup &sgroup);
std::string FormatV3000ParentBlock(const SubstanceGroup &sgroup);
std::string FormatV3000CompNoBlock(const SubstanceGroup &sgroup);
std::string FormatV3000BracketBlock(
const std::vector<SubstanceGroup::Bracket> brackets);
std::string FormatV3000CStateBlock(
const std::vector<SubstanceGroup::CState> &cstates);
const std::string GetV3000MolFileSGroupLines(const unsigned int idx,
const SubstanceGroup &sgroup);
} // namespace SGroupWriting
} // namespace RDKit
|