Chemical Data Processing Library C++ API - Version 1.4.0
INCHIMoleculeReader.hpp
Go to the documentation of this file.
1 /*
2  * INCHIMoleculeReader.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_INCHIMOLECULEREADER_HPP
30 #define CDPL_CHEM_INCHIMOLECULEREADER_HPP
31 
32 #include <string>
33 #include <vector>
34 #include <cstddef>
35 
36 #include "CDPL/Chem/APIPrefix.hpp"
38 
39 
40 typedef struct tagInchiAtom inchi_Atom;
41 typedef struct tagINCHIStereo0D inchi_Stereo0D;
42 
43 
44 namespace CDPL
45 {
46 
47  namespace Chem
48  {
49 
50  class Molecule;
51  class Atom;
52 
85  class CDPL_CHEM_API INCHIMoleculeReader : public Util::StreamDataReader<Molecule, INCHIMoleculeReader>
86  {
87 
88  public:
94  INCHIMoleculeReader(std::istream& is);
95 
97 
99 
107  int getReturnCode() const;
108 
113  const std::string& getMessage() const;
114 
119  const std::string& getLogOutput() const;
120 
121  private:
123 
124  bool readData(std::istream&, Molecule&, bool overwrite);
125  bool skipData(std::istream&);
126  bool moreData(std::istream&);
127 
128  bool readMolecule(std::istream&, Molecule&);
129  bool skipMolecule(std::istream&);
130 
131  void buildMolecule(Molecule&, const inchi_Atom*, std::size_t, const inchi_Stereo0D*, std::size_t) const;
132 
133  void setElement(Atom&, const inchi_Atom&) const;
134  void setIsotope(Atom&, const inchi_Atom&) const;
135  void setFormalCharge(Atom&, const inchi_Atom&) const;
136  void setRadicalType(Atom&, const inchi_Atom&) const;
137  void setImplicitHCounts(Atom&, const inchi_Atom&) const;
138  void createBonds(Molecule&, Atom&, const inchi_Atom&, std::size_t) const;
139 
140  void set2DCoordinates(Molecule&, const inchi_Atom*, std::size_t) const;
141  void set3DCoordinates(Molecule&, const inchi_Atom*, std::size_t) const;
142 
143  void process0DStereoInfo(Molecule&, const inchi_Stereo0D*, std::size_t, std::size_t) const;
144 
145  void process0DAtomStereoInfo(Molecule&, const inchi_Stereo0D&, std::size_t) const;
146  void process0DBondStereoInfo(Molecule&, const inchi_Stereo0D&, std::size_t) const;
147 
148  typedef std::vector<char> StringData;
149 
150  std::string inputToken;
151  StringData inputData;
152  StringData inchiOptions;
153  bool strictErrorChecking;
154  int returnCode;
155  std::string message;
156  std::string logOutput;
157  };
158  } // namespace Chem
159 } // namespace CDPL
160 
161 #endif // CDPL_CHEM_INCHIMOLECULEREADER_HPP
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
struct tagInchiAtom inchi_Atom
Definition: INCHIMolecularGraphWriter.hpp:41
struct tagINCHIStereo0D inchi_Stereo0D
Definition: INCHIMolecularGraphWriter.hpp:42
Definition of class CDPL::Util::StreamDataReader.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Reader for molecule data in the IUPAC International Chemical Identifier (InChI) [INCHI] format.
Definition: INCHIMoleculeReader.hpp:86
INCHIMoleculeReader(std::istream &is)
Constructs a INCHIMoleculeReader instance that will read the molecule data from the input stream is.
const std::string & getMessage() const
Returns the error message associated with the last read operation.
INCHIMoleculeReader & operator=(const INCHIMoleculeReader &)=delete
int getReturnCode() const
Returns the error code of the last read operation.
const std::string & getLogOutput() const
Returns the log output that was generated for the last read operation.
INCHIMoleculeReader(const INCHIMoleculeReader &)=delete
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
Helper class that implements Base::DataReader for std::istream based data readers.
Definition: StreamDataReader.hpp:73
CDPL_CHEM_API void setRadicalType(Atom &atom, unsigned int type)
Sets the value of the Chem::AtomProperty::RADICAL_TYPE property of the atom atom to type.
CDPL_CHEM_API void set3DCoordinates(Entity3DContainer &cntnr, const Math::Vector3DArray &coords)
Sets the 3D coordinates of the entities of cntnr from coords.
CDPL_CHEM_API void setIsotope(Atom &atom, std::size_t isotope)
Sets the value of the Chem::AtomProperty::ISOTOPE property of the atom atom to isotope.
CDPL_CHEM_API void set2DCoordinates(AtomContainer &cntnr, const Math::Vector2DArray &coords)
Writes the 2D coordinates in coords back to the corresponding atoms of cntnr.
CDPL_CHEM_API void setFormalCharge(Atom &atom, long charge)
Sets the value of the Chem::AtomProperty::FORMAL_CHARGE property of the atom atom to charge.
The namespace of the Chemical Data Processing Library.