Chemical Data Processing Library C++ API - Version 1.1.1
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 
150  class CDPL_CHEM_API INCHIMoleculeReader : public Util::StreamDataReader<Molecule, INCHIMoleculeReader>
151  {
152 
153  public:
159  INCHIMoleculeReader(std::istream& is);
160 
168  int getReturnCode() const;
169 
174  const std::string& getMessage() const;
175 
180  const std::string& getLogOutput() const;
181 
182  private:
184 
186 
187  INCHIMoleculeReader& operator=(const INCHIMoleculeReader&);
188 
189  bool readData(std::istream&, Molecule&, bool overwrite);
190  bool skipData(std::istream&);
191  bool moreData(std::istream&);
192 
193  bool readMolecule(std::istream&, Molecule&);
194  bool skipMolecule(std::istream&);
195 
196  void buildMolecule(Molecule&, const inchi_Atom*, std::size_t, const inchi_Stereo0D*, std::size_t) const;
197 
198  void setElement(Atom&, const inchi_Atom&) const;
199  void setIsotope(Atom&, const inchi_Atom&) const;
200  void setFormalCharge(Atom&, const inchi_Atom&) const;
201  void setRadicalType(Atom&, const inchi_Atom&) const;
202  void setImplicitHCounts(Atom&, const inchi_Atom&) const;
203  void createBonds(Molecule&, Atom&, const inchi_Atom&, std::size_t) const;
204 
205  void set2DCoordinates(Molecule&, const inchi_Atom*, std::size_t) const;
206  void set3DCoordinates(Molecule&, const inchi_Atom*, std::size_t) const;
207 
208  void process0DStereoInfo(Molecule&, const inchi_Stereo0D*, std::size_t, std::size_t) const;
209 
210  void process0DAtomStereoInfo(Molecule&, const inchi_Stereo0D&, std::size_t) const;
211  void process0DBondStereoInfo(Molecule&, const inchi_Stereo0D&, std::size_t) const;
212 
213  typedef std::vector<char> StringData;
214 
215  std::string inputToken;
216  StringData inputData;
217  StringData inchiOptions;
218  bool strictErrorChecking;
219  int returnCode;
220  std::string message;
221  std::string logOutput;
222  };
223  } // namespace Chem
224 } // namespace CDPL
225 
226 #endif // CDPL_CHEM_INCHIMOLECULEREADER_HPP
CDPL::Chem::setFormalCharge
CDPL_CHEM_API void setFormalCharge(Atom &atom, long charge)
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::set3DCoordinates
CDPL_CHEM_API void set3DCoordinates(Entity3DContainer &cntnr, const Math::Vector3DArray &coords)
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
inchi_Stereo0D
struct tagINCHIStereo0D inchi_Stereo0D
Definition: INCHIMolecularGraphWriter.hpp:42
CDPL::Chem::setRadicalType
CDPL_CHEM_API void setRadicalType(Atom &atom, unsigned int type)
CDPL::Chem::INCHIMoleculeReader::getReturnCode
int getReturnCode() const
Returns the error code of the last read operation.
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
inchi_Atom
struct tagInchiAtom inchi_Atom
Definition: INCHIMolecularGraphWriter.hpp:41
CDPL::Chem::INCHIMoleculeReader
A reader for molecule data in the IUPAC International Chemical Identifier (InChI) [INCHI] format.
Definition: INCHIMoleculeReader.hpp:151
CDPL::Chem::Molecule
Molecule.
Definition: Molecule.hpp:49
CDPL::Chem::setIsotope
CDPL_CHEM_API void setIsotope(Atom &atom, std::size_t isotope)
CDPL::Chem::INCHIMoleculeReader::getMessage
const std::string & getMessage() const
Returns the error message associated with the last read operation.
CDPL::Chem::INCHIMoleculeReader::INCHIMoleculeReader
INCHIMoleculeReader(std::istream &is)
Constructs a INCHIMoleculeReader instance that will read the molecule data from the input stream is.
CDPL
The namespace of the Chemical Data Processing Library.
StreamDataReader.hpp
Definition of the class CDPL::Util::StreamDataReader.
CDPL::Util::StreamDataReader
A helper class that implements Base::DataReader for std::istream based data readers.
Definition: StreamDataReader.hpp:73
CDPL::Chem::set2DCoordinates
CDPL_CHEM_API void set2DCoordinates(AtomContainer &cntnr, const Math::Vector2DArray &coords)