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