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 
36  // reads a line from an MDL v3K CTAB
37  std::string getV3000Line(std::istream *inStream,unsigned int &line);
38 
39  // nAtoms and nBonds are ignored on input, set on output
40  bool ParseV3000CTAB(std::istream *inStream,unsigned int &line,
41  RWMol *mol, Conformer *&conf,
42  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,
48  RWMol *mol, Conformer *&conf,
49  bool &chiralityPossible,
50  unsigned int &nAtoms,unsigned int &nBonds,
51  bool strictParsing=true);
52 
54 
55  }
56 }
57 
58 #endif
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
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:28
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:67