mcdlutil.h
Go to the documentation of this file.
00001 /*-*-C++-*-
00002 
00003 **********************************************************************
00004 Copyright (C) 2007,2008 by Sergei V. Trepalin sergey_trepalin@chemical-block.com
00005 Copyright (C) 2007,2008 by Andrei Gakh andrei.gakh@nnsa.doe.gov
00006 
00007 This file is part of the Open Babel project.
00008 For more information, see <http://openbabel.org/>
00009 
00010 This program is free software; you can redistribute it and/or modify
00011 it under the terms of the GNU General Public License as published by
00012 the Free Software Foundation version 2 of the License.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 ***********************************************************************
00019 */
00020 /*
00021   Diagram is generated using templates, which are stored in SD file templates.sdf
00022   The SD file is usual SD file, which contain chemical structures and might contain data.
00023   Only chemical structures are used. Subgraph isomorphisme search is executed and coordinates
00024   of atoms are determined from templates. See Molecules, 11, 129-141 (2006) for algorithm decription.
00025   Structures in SD file are converted in next manner:
00026   1. All atoms, except explicit hydrogens, are replaced with generic ANY_ATOM (matched with any atom in subgraph isomorphisme search)
00027   2. All bonds are replaces with generic ANY_BOND, which can be matched with any bond in molecule
00028   3. All hydrogen are removed, but they are used for search-query and structure atom matching is believed fo be
00029      sucessfukk if chemical structure contains more or equal number of hydrogens, than query. Using explicitly-defined hydrogens
00030          on query enables ones to remove substitutors attachment for atom, which are sterically hidden on templates
00031   if the file will not be found, predefined templates will be used
00032 */
00033 
00034 
00035 namespace OpenBabel {
00036 
00037   //common constants
00038   static const int MAXBONDS=300;
00039   static const int MAXFRAGS=200;
00040   static const int MAXCHARS=1000;
00041   static const int MAX_DEPTH=10;
00042   static const int NELEMMAX=120;
00043   #define NELEMMCDL 121
00044 
00045   // Return valency by hydrogen for given atomic position in the Periodic Table
00046   OBMCDL int hydrogenValency(int na);
00047   OBMCDL int maxValency(int na);
00048 
00049   //Alternate overloaded methods
00050   OBMCDL int alternate(OBMol * pmol, const int nH[], int bondOrders []);  //This method does not work!
00051   //Zero-based atomic numeration should be in connection matrix arrays iA1 and iA2-so first atom has indez zero
00052   OBMCDL int alternate(const std::vector<int> aPosition,const std::vector<int> aCharge,
00053       const std::vector<int> aRad,const std::vector<int> nHydr, const std::vector<int> iA1,
00054       const std::vector<int> iA2, std::vector<int> & bondOrders, int nAtoms, int nBonds);
00058   //Diagram generation overloaded methods
00059   OBMCDL void generateDiagram(OBMol * pmol);
00060   //Zero-based atomic numeration should be in connection matrix arrays iA1 and iA2-so first atom has indez zero
00061   OBMCDL void generateDiagram(const std::vector<int> iA1, const std::vector<int> iA2,
00062       std::vector<double>& rx, std::vector<double>& ry, int nAtoms, int nBonds);
00063   OBMCDL void generateDiagram(OBMol * pmol, std::ostream & ofs);  //for testing purposes only
00064 
00065   //Fragment search - pure subgraph isomorphisme
00066   bool fragmentSearch(OBMol * query, OBMol * structure);
00067   bool fragmentSearch(const std::vector<int> aPositionQuery, const std::vector<int> iA1Query,
00068       const std::vector<int> iA2Query, const std::vector<int> bondTypesQuery,
00069       const std::vector<int> aPositionStructure, const std::vector<int> iA1Structure,
00070       const std::vector<int> iA2Structure,  const std::vector<int> bondTypesStructure,
00071       int nAtomsQuery, int nBondsQuery, int nAtomsStructure, int nBondsStructure);
00073   OBMCDL void equivalenceList(OBMol * pmol,  std::vector<int>& eqList);
00074   void equivalenceList(const std::vector<int> aPosition,const std::vector<int> aCharge,
00075       const std::vector<int> aRad, const std::vector<int> iA1, const std::vector<int> iA2,
00076       const std::vector<int> bondTypes,  std::vector<int>& eqList, int nAtoms, int nBonds);
00077   //Fragment addition
00078   OBMCDL void addFragment(OBMol * molecule, OBMol * fragment, int molAN, int fragAN, int molBN,
00079       int fragBN, bool isAddition);
00080 
00081   //routines below have no common meaning, but are necessary to process stereo information
00082   OBMCDL void createStereoLists(OBMol * pmol, std::vector<int>& bondStereoList,
00083       std::vector<int>& atomStereoList, std::vector<int>& eqList);
00084   OBMCDL std::string getAtomMCDL(OBMol * pmol, int ntatoms, const std::vector<int> ix,
00085       const std::vector<int> aNumber, const std::vector<int> atomStereoList, const std::vector<int> eqList);
00086   OBMCDL std::string getBondMCDL(OBMol * pmol, int nbStore, int ntatoms, const std::vector<int> ix,
00087       const std::vector<int> aNumber, int bonds[MAXBONDS][4], const std::vector<int> bondStereoList,
00088       const std::vector<int> eqList);
00089   OBMCDL void implementAtomStereo(std::vector<int>& iA1, std::vector<int>& iA2, std::vector<int>& stereoBonds,
00090       const std::vector<double>rx, const std::vector<double> ry, int acount, int bcount, std::string astereo);
00091   OBMCDL void implementBondStereo(const std::vector<int> iA1, const std::vector<int> iA2,
00092       std::vector<double>& rx, std::vector<double>& ry, int acount, int bcount, std::string bstereo);
00093 
00094 
00095   OBMCDL int groupRedraw(OBMol * pmol, int bondN, int atomN, bool atomNInGroup);
00096   //int  groupRedrawFrameAtom(OBMol * pmol, int bondN, int atomInFrame);
00097 
00098   OBMCDL int  canonizeMCDL(const std::string atomBlock, std::vector<std::string> & structureList);
00099   OBMCDL bool parseFormula(const std::string formulaString, std::vector <int>& enumber, int & valency);
00100 
00101   OBMCDL void prepareTest(OBMol * pmol, std::ostream & ofs);
00102 
00103 } // namespace OpenBabel
00104 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines