Open Babel  3.0
builder.h
Go to the documentation of this file.
1 /**********************************************************************
2 builder.h - OBBuilder class.
3 
4 Copyright (C) 2007-2008 by Tim Vandermeersch
6 
7 This file is part of the Open Babel project.
8 For more information, see <http://openbabel.org/>
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation version 2 of the License.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 ***********************************************************************/
19 
20 #ifndef OB_BUILDER_H
21 #define OB_BUILDER_H
22 
23 #include <vector>
24 #include <string>
25 #include <map>
26 
27 #include <list>
28 #include <set>
29 
31 
32 namespace OpenBabel
33 {
34  class OBMol;
35  class OBAtom;
36  class OBSmartsPattern;
37  class vector3;
38  class OBBitVec;
39 
42  class OBAPI OBBuilder {
43  public:
44 
45  OBBuilder(): _keeprings(false) {}
46 
48 
49 
55  bool Build(OBMol &mol, bool stereoWarnings = true);
57 
59 
60 
68  void SetKeepRings() { _keeprings = true; }
69  void UnsetKeepRings() { _keeprings = false; }
71 
72 
74  void LoadFragments();
75  std::vector<vector3> GetFragmentCoord(std::string smiles);
76 
82  static vector3 GetNewBondVector(OBAtom *atom);
83  static vector3 GetNewBondVector(OBAtom *atom, double length);
84 
96  static bool Connect(OBMol &mol, int a, int b, vector3 &newpos, int bondOrder = 1);
107  static bool Connect(OBMol &mol, int a, int b, int bondOrder = 1);
135  static bool Swap(OBMol &mol, int a, int b, int c, int d);
142  //bool Insert(OBMol &mol, int a, int b, std::string smiles, int c, int d);
147  static bool CorrectStereoBonds(OBMol &mol);
153  static bool CorrectStereoAtoms(OBMol &mol, bool warn = true);
156  static bool IsSpiroAtom(unsigned long atomId, OBMol &mol);
161  static OBBitVec GetFragment(OBAtom *atom);
162  static void AddNbrs(OBBitVec &fragment, OBAtom *atom);
163 
164  private:
166  //static std::map<std::string, double> _torsion;
167  static std::vector<std::string> _rigid_fragments;
168  static std::vector<std::pair<OBSmartsPattern*, std::vector<vector3> > > _ring_fragments;
169  static std::map<std::string, int> _rigid_fragments_index;
170  static std::map<std::string, std::vector<vector3> > _rigid_fragments_cache;
172  // supports the case where the fragments overlap at a spiro atom only.
173  static void ConnectFrags(OBMol &mol, OBMol &workmol, std::vector<int> match, std::vector<vector3> coords,
174  std::vector<int> pivot);
176  static void FlipSpiro(OBMol &mol, int idx);
177  static bool FixRingStereo(std::vector<std::pair<OBStereo::Ref, bool> > atomIds,
178  OBMol &mol, OBStereo::Refs &unfixedcenters);
179  static void AddRingNbrs(OBBitVec &fragment, OBAtom *atom, OBMol &mol);
180  static bool SwapWithVector(OBMol &mol, int a, int b, int c, const vector3 &newlocation);
181  bool _keeprings;
182  }; // class OBBuilder
183 
184 }// namespace OpenBabel
185 
186 #endif // OB_BUILDER_H
187 
Class to build 3D structures.
Definition: builder.h:42
void UnsetKeepRings()
Definition: builder.h:69
void SetKeepRings()
Definition: builder.h:68
Molecule Class.
Definition: mol.h:118
Process molecular stereochemistry information.
A speed-optimized vector of bits.
Definition: bitvec.h:57
Represents a vector in 3-dimensional real space.
Definition: vector3.h:44
OBBuilder()
Definition: builder.h:45
std::vector< Ref > Refs
Definition: stereo.h:156
Global namespace for all Open Babel code.
Definition: alias.h:22
Atom class.
Definition: atom.h:71