Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SmilesParseData.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_IO_SMILES_PARSER_DATA_H
9 #define INCLUDE_MOLASSEMBLER_IO_SMILES_PARSER_DATA_H
10 
11 #include <boost/fusion/adapted/struct/adapt_struct.hpp>
12 #include <boost/fusion/include/adapt_struct.hpp>
13 
16 #include "boost/optional.hpp"
17 #include "Molassembler/Types.h"
18 
19 namespace Scine {
20 namespace Molassembler {
21 namespace IO {
22 
23 struct ElementData {
24  unsigned Z = 0;
25  bool aromatic = false;
26 
27  ElementData() = default;
28  explicit ElementData(Utils::ElementType e) : Z(Utils::ElementInfo::Z(e)) {}
29 
30  static inline ElementData aromaticElement(Utils::ElementType e) {
31  ElementData d(e);
32  d.aromatic = true;
33  return d;
34  }
35 };
36 
37 struct ChiralData {
38  Shapes::Shape shape;
39  unsigned chiralIndex;
40 };
41 
42 struct AtomData {
43  unsigned A = 0;
44  ElementData partialElement;
45  boost::optional<ChiralData> chiralOptional;
46  boost::optional<unsigned> hCount;
47  boost::optional<int> chargeOptional;
48  bool atomBracket = false;
49 
50  inline Utils::ElementType getElement() const {
51  if(partialElement.Z == 0) {
52  return Utils::ElementType::none;
53  }
54 
55  if(A == 0) {
56  return Utils::ElementInfo::element(partialElement.Z);
57  }
58 
59  return Utils::ElementInfo::isotope(partialElement.Z, A);
60  }
61 };
62 
63 struct BondData {
64  enum class StereoMarker {Forward, Backward};
65 
66  boost::optional<BondType> type;
67  boost::optional<StereoMarker> ezStereo;
68  boost::optional<unsigned> ringNumber;
69 };
70 
71 } // namespace IO
72 } // namespace Molassembler
73 } // namespace Scine
74 
75 BOOST_FUSION_ADAPT_STRUCT(
77  (unsigned, Z),
78  (bool, aromatic)
79 )
80 
81 BOOST_FUSION_ADAPT_STRUCT(
82  Scine::Molassembler::IO::ChiralData,
83  (Scine::Molassembler::Shapes::Shape, shape),
84  (unsigned, chiralIndex)
85 )
86 
87 BOOST_FUSION_ADAPT_STRUCT(
88  Scine::Molassembler::IO::AtomData,
89  (unsigned, A),
90  (Scine::Molassembler::IO::ElementData, partialElement),
91  (boost::optional<Scine::Molassembler::IO::ChiralData>, chiralOptional),
92  (boost::optional<unsigned>, hCount),
93  (boost::optional<int>, chargeOptional),
94  (bool, atomBracket)
95 )
96 
97 BOOST_FUSION_ADAPT_STRUCT(
98  Scine::Molassembler::IO::BondData,
99  (boost::optional<Scine::Molassembler::BondType>, type),
100  (boost::optional<Scine::Molassembler::IO::BondData::StereoMarker>, ezStereo)
101  (boost::optional<unsigned>, ringNumber)
102 )
103 
104 #endif
static ElementType element(unsigned z)
Defines basic types widely shared across the project.
ShapeResult shape(const PositionCollection &normalizedPositions, Shape shape)
Forwarding function to calculate the continuous shape measure.
Definition: SmilesParseData.h:37
static ElementType isotope(unsigned z, unsigned a)
static constexpr unsigned Z(const ElementType e) noexcept
Definition: SmilesParseData.h:42
BondType
Discrete bond type numeration.
Definition: Types.h:26
Definition: SmilesParseData.h:63
Defines symmetry names and total count.
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Definition: SmilesParseData.h:23