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>
16 #include <boost/lexical_cast.hpp>
17 #include <boost/algorithm/string.hpp>
19 
20 namespace RDKit {
21 class RWMol;
22 class Conformer;
23 
24 namespace FileParserUtils {
25 template <typename T>
26 T stripSpacesAndCast(const std::string &input, bool acceptSpaces = false) {
27  std::string trimmed = boost::trim_copy(input);
28  if (acceptSpaces && trimmed == "") {
29  return 0;
30  } else {
31  return boost::lexical_cast<T>(trimmed);
32  }
33 }
34 int toInt(const std::string &input, bool acceptSpaces = false);
35 double toDouble(const std::string &input, bool acceptSpaces = true);
36 
37 // reads a line from an MDL v3K CTAB
38 std::string getV3000Line(std::istream *inStream, unsigned int &line);
39 
40 // nAtoms and nBonds are ignored on input, set on output
41 bool ParseV3000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol,
42  Conformer *&conf, bool &chiralityPossible,
43  unsigned int &nAtoms, unsigned int &nBonds,
44  bool strictParsing = true, bool expectMEND = true);
45 
46 // nAtoms and nBonds are used
47 bool ParseV2000CTAB(std::istream *inStream, unsigned int &line, RWMol *mol,
48  Conformer *&conf, bool &chiralityPossible,
49  unsigned int &nAtoms, unsigned int &nBonds,
50  bool strictParsing = true);
51 
53 }
54 }
55 
56 #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