RDKit
Open-source cheminformatics and machine learning.
FileParserUtils.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2010 Greg Landrum and Rational Discovery LLC
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 #ifndef _RD_FILEPARSERUTILS_H
11 #define _RD_FILEPARSERUTILS_H
12 
13 #include <string>
14 #include <iostream>
15 #include <boost/lexical_cast.hpp>
16 #include <boost/algorithm/string.hpp>
17 
18 namespace RDKit {
19 class RWMol;
20 class Conformer;
21 
22 namespace FileParserUtils {
23 template <typename T>
24 T stripSpacesAndCast(const std::string &input, bool acceptSpaces = false) {
25  std::string trimmed = boost::trim_copy(input);
26  if (acceptSpaces && trimmed == "") {
27  return 0;
28  } else {
29  return boost::lexical_cast<T>(trimmed);
30  }
31 }
32 int toInt(const std::string &input, bool acceptSpaces = false);
33 double toDouble(const std::string &input, bool acceptSpaces = true);
34 
35 // reads a line from an MDL v3K CTAB
36 std::string getV3000Line(std::istream *inStream, unsigned int &line);
37 
38 // nAtoms and nBonds are ignored on input, set on output
39 bool ParseV3000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol,
40  Conformer *&conf, bool &chiralityPossible,
41  unsigned int &nAtoms, unsigned int &nBonds,
42  bool strictParsing = true, bool expectMEND = true);
43 
44 // nAtoms and nBonds are used
45 bool ParseV2000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol,
46  Conformer *&conf, bool &chiralityPossible,
47  unsigned int &nAtoms, unsigned int &nBonds,
48  bool strictParsing = true);
49 
51 }
52 }
53 
54 #endif
RWMol is a molecule class that is intended to be edited.
Definition: RWMol.h:30
std::string getV3000Line(std::istream *inStream, unsigned int &line)
double toDouble(const std::string &input, bool acceptSpaces=true)
int toInt(const std::string &input, bool acceptSpaces=false)
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29
Atom * replaceAtomWithQueryAtom(RWMol *mol, Atom *atom)
T stripSpacesAndCast(const std::string &input, bool acceptSpaces=false)
bool ParseV3000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol, Conformer *&conf, bool &chiralityPossible, unsigned int &nAtoms, unsigned int &nBonds, bool strictParsing=true, bool expectMEND=true)
bool ParseV2000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol, Conformer *&conf, bool &chiralityPossible, unsigned int &nAtoms, unsigned int &nBonds, bool strictParsing=true)
The class for representing 2D or 3D conformation of a molecule.
Definition: Conformer.h:41
The class for representing atoms.
Definition: Atom.h:68