Open Babel  3.0
mcdlutil.h
Go to the documentation of this file.
1 /*-*-C++-*-
2 
3 **********************************************************************
4 Copyright (C) 2007,2008 by Sergei V. Trepalin [email protected]
5 Copyright (C) 2007,2008 by Andrei Gakh [email protected]
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 /*
21  Diagram is generated using templates, which are stored in SD file templates.sdf
22  The SD file is usual SD file, which contain chemical structures and might contain data.
23  Only chemical structures are used. Subgraph isomorphisme search is executed and coordinates
24  of atoms are determined from templates. See Molecules, 11, 129-141 (2006) for algorithm decription.
25  Structures in SD file are converted in next manner:
26  1. All atoms, except explicit hydrogens, are replaced with generic ANY_ATOM (matched with any atom in subgraph isomorphisme search)
27  2. All bonds are replaces with generic ANY_BOND, which can be matched with any bond in molecule
28  3. All hydrogen are removed, but they are used for search-query and structure atom matching is believed fo be
29  sucessfukk if chemical structure contains more or equal number of hydrogens, than query. Using explicitly-defined hydrogens
30  on query enables ones to remove substitutors attachment for atom, which are sterically hidden on templates
31  if the file will not be found, predefined templates will be used
32 */
33 
34 
35 namespace OpenBabel {
36 
37  //common constants
38  static const int MAXBONDS=300;
39  static const int MAXFRAGS=200;
40  static const int MAXCHARS=1000;
41  static const int MAX_DEPTH=10;
42  static const int NELEMMAX=120;
43  #define NELEMMCDL 121
44 
45  // Return valency by hydrogen for given atomic position in the Periodic Table
46  OBMCDL int hydrogenValency(int na);
47  OBMCDL int maxValency(int na);
48 
49  //Alternate overloaded methods
50  OBMCDL int alternate(OBMol * pmol, const int nH[], int bondOrders []); //This method does not work!
51  //Zero-based atomic numeration should be in connection matrix arrays iA1 and iA2-so first atom has indez zero
52  OBMCDL int alternate(const std::vector<int> aPosition,const std::vector<int> aCharge,
53  const std::vector<int> aRad,const std::vector<int> nHydr, const std::vector<int> iA1,
54  const std::vector<int> iA2, std::vector<int> & bondOrders, int nAtoms, int nBonds);
58  //Diagram generation overloaded methods
59  OBMCDL void generateDiagram(OBMol * pmol);
60  //Zero-based atomic numeration should be in connection matrix arrays iA1 and iA2-so first atom has indez zero
61  OBMCDL void generateDiagram(const std::vector<int> iA1, const std::vector<int> iA2,
62  std::vector<double>& rx, std::vector<double>& ry, int nAtoms, int nBonds);
63  OBMCDL void generateDiagram(OBMol * pmol, std::ostream & ofs); //for testing purposes only
64 
65  //Fragment search - pure subgraph isomorphisme
66  bool fragmentSearch(OBMol * query, OBMol * structure);
67  bool fragmentSearch(const std::vector<int> aPositionQuery, const std::vector<int> iA1Query,
68  const std::vector<int> iA2Query, const std::vector<int> bondTypesQuery,
69  const std::vector<int> aPositionStructure, const std::vector<int> iA1Structure,
70  const std::vector<int> iA2Structure, const std::vector<int> bondTypesStructure,
71  int nAtomsQuery, int nBondsQuery, int nAtomsStructure, int nBondsStructure);
73  OBMCDL void equivalenceList(OBMol * pmol, std::vector<int>& eqList);
74  void equivalenceList(const std::vector<int> aPosition,const std::vector<int> aCharge,
75  const std::vector<int> aRad, const std::vector<int> iA1, const std::vector<int> iA2,
76  const std::vector<int> bondTypes, std::vector<int>& eqList, int nAtoms, int nBonds);
77  //Fragment addition
78  OBMCDL void addFragment(OBMol * molecule, OBMol * fragment, int molAN, int fragAN, int molBN,
79  int fragBN, bool isAddition);
80 
81  //routines below have no common meaning, but are necessary to process stereo information
82  OBMCDL void createStereoLists(OBMol * pmol, std::vector<int>& bondStereoList,
83  std::vector<int>& atomStereoList, std::vector<int>& eqList);
84  OBMCDL std::string getAtomMCDL(OBMol * pmol, int ntatoms, const std::vector<int> ix,
85  const std::vector<int> aNumber, const std::vector<int> atomStereoList, const std::vector<int> eqList);
86  OBMCDL std::string getBondMCDL(OBMol * pmol, int nbStore, int ntatoms, const std::vector<int> ix,
87  const std::vector<int> aNumber, int bonds[MAXBONDS][4], const std::vector<int> bondStereoList,
88  const std::vector<int> eqList);
89  OBMCDL void implementAtomStereo(std::vector<int>& iA1, std::vector<int>& iA2, std::vector<int>& stereoBonds,
90  const std::vector<double>rx, const std::vector<double> ry, int acount, int bcount, std::string astereo);
91  OBMCDL void implementBondStereo(const std::vector<int> iA1, const std::vector<int> iA2,
92  std::vector<double>& rx, std::vector<double>& ry, int acount, int bcount, std::string bstereo);
93 
94 
95  OBMCDL int groupRedraw(OBMol * pmol, int bondN, int atomN, bool atomNInGroup);
96  //int groupRedrawFrameAtom(OBMol * pmol, int bondN, int atomInFrame);
97 
98  OBMCDL int canonizeMCDL(const std::string atomBlock, std::vector<std::string> & structureList);
99  OBMCDL bool parseFormula(const std::string formulaString, std::vector <int>& enumber, int & valency);
100 
101  OBMCDL void prepareTest(OBMol * pmol, std::ostream & ofs);
102 
103 } // namespace OpenBabel
104 
static const int MAX_DEPTH
Definition: mcdlutil.h:41
bool parseFormula(const std::string formulaString, std::vector< int > &enumber, int &valency)
Definition: mcdlutil.cpp:7189
int canonizeMCDL(const std::string atomBlock, std::vector< std::string > &structureList)
Definition: mcdlutil.cpp:7265
void equivalenceList(OBMol *pmol, std::vector< int > &eqList)
Equivalence list generation.
Definition: mcdlutil.cpp:6191
bool fragmentSearch(OBMol *query, OBMol *structure)
Definition: mcdlutil.cpp:6105
static const int NELEMMAX
Definition: mcdlutil.h:42
static const int MAXFRAGS
Definition: mcdlutil.h:39
void addFragment(OBMol *molecule, OBMol *fragment, int molAN, int fragAN, int molBN, int fragBN, bool isAddition)
Definition: mcdlutil.cpp:6200
void implementAtomStereo(std::vector< int > &iA1, std::vector< int > &iA2, std::vector< int > &stereoBonds, const std::vector< double >rx, const std::vector< double > ry, int acount, int bcount, std::string astereo)
Definition: mcdlutil.cpp:6944
int groupRedraw(OBMol *pmol, int bondN, int atomN, bool atomNInGroup)
Definition: mcdlutil.cpp:7116
void implementBondStereo(const std::vector< int > iA1, const std::vector< int > iA2, std::vector< double > &rx, std::vector< double > &ry, int acount, int bcount, std::string bstereo)
Definition: mcdlutil.cpp:7011
void generateDiagram(OBMol *pmol)
Definition: mcdlutil.cpp:6073
void createStereoLists(OBMol *pmol, std::vector< int > &bondStereoList, std::vector< int > &atomStereoList, std::vector< int > &eqList)
Definition: mcdlutil.cpp:6224
int maxValency(int na)
Definition: mcdlutil.cpp:3552
std::string getBondMCDL(OBMol *pmol, int nbStore, int ntatoms, const std::vector< int > ix, const std::vector< int > aNumber, int bonds[MAXBONDS][4], const std::vector< int > bondStereoList, const std::vector< int > eqList)
Definition: mcdlutil.cpp:6678
static const int MAXBONDS
Definition: mcdlutil.h:38
int alternate(OBMol *pmol, const int nH[], int bondOrders [])
void prepareTest(OBMol *pmol, std::ostream &ofs)
Definition: mcdlutil.cpp:7274
static const int MAXCHARS
Definition: mcdlutil.h:40
int hydrogenValency(int na)
Definition: mcdlutil.cpp:3546
std::string getAtomMCDL(OBMol *pmol, int ntatoms, const std::vector< int > ix, const std::vector< int > aNumber, const std::vector< int > atomStereoList, const std::vector< int > eqList)
Definition: mcdlutil.cpp:6522
Global namespace for all Open Babel code.
Definition: alias.h:22