RDKit: MolSGroupWriting.h Source File

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