1 /********************************************************************** 2 reaction.h - Handle chemical reactions (i.e., lists of reagents and products). 3 4 Copyright (C) 2005 by Chris Morley 5 6 This file is part of the Open Babel project. 7 For more information, see <http://openbabel.org/> 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation version 2 of the License. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 ***********************************************************************/ 18 19 #ifndef OB_REACT_H 20 #define OB_REACT_H 21 22 #include <vector> 23 #include <openbabel/shared_ptr.h> 24 #include <openbabel/base.h> 25 26 27 namespace OpenBabel 28 { 29 class OBMol; 30 31 //!\brief Used to store chemical reactions (i.e., reactants -> products) 32 //! 33 //! Reactants and products stored as smart pointers to molecules stored elsewhere. 34 //! 35 //! For performing actual reaction transformations (i.e., deleting atoms, 36 //! changing bonds, etc.) use the OBChemTsfm class. 37 class OBReaction : public OBBase 38 { 39 private: 40 std::vector<obsharedptr<OBMol> > _reactants; 41 std::vector<obsharedptr<OBMol> > _products; 42 std::vector<obsharedptr<OBMol> > _agents; 43 obsharedptr<OBMol> _ts; 44 std::string _title; 45 std::string _comment; 46 bool _reversible; 47 public: OBReaction()48 OBReaction() : _reversible(false) 49 {} 50 NumReactants()51 int NumReactants() const 52 { return static_cast<int> (_reactants.size()); } 53 NumProducts()54 int NumProducts()const 55 { return static_cast<int> (_products.size()); } 56 NumAgents()57 int NumAgents() const 58 { 59 return static_cast<int> (_agents.size()); 60 } 61 AddReactant(const obsharedptr<OBMol> sp)62 void AddReactant(const obsharedptr<OBMol> sp) 63 { _reactants.push_back(sp); } 64 AddProduct(const obsharedptr<OBMol> sp)65 void AddProduct(const obsharedptr<OBMol> sp) 66 { _products.push_back(sp); } 67 SetTransitionState(const obsharedptr<OBMol> sp)68 void SetTransitionState(const obsharedptr<OBMol> sp) 69 { _ts = sp; } 70 AddAgent(const obsharedptr<OBMol> sp)71 void AddAgent(const obsharedptr<OBMol> sp) 72 { _agents.push_back(sp); } 73 GetReactant(const unsigned i)74 obsharedptr<OBMol> GetReactant(const unsigned i) 75 { 76 obsharedptr<OBMol> sp; 77 if(i<_reactants.size()) 78 sp = _reactants[i]; 79 return sp; //returns empty if out of range 80 } GetProduct(const unsigned i)81 obsharedptr<OBMol> GetProduct(const unsigned i) 82 { 83 obsharedptr<OBMol> sp; 84 if(i<_products.size()) 85 sp = _products[i]; 86 return sp; //returns empty if out of range 87 } GetAgent(const unsigned i)88 obsharedptr<OBMol> GetAgent(const unsigned i) 89 { 90 obsharedptr<OBMol> sp; 91 if (i<_agents.size()) 92 sp = _agents[i]; 93 return sp; //returns empty if out of range 94 } 95 GetTransitionState()96 obsharedptr<OBMol> GetTransitionState()const 97 { return _ts; } 98 GetTitle()99 std::string GetTitle() const { return _title; } GetComment()100 std::string GetComment() const { return _comment; } SetTitle(const std::string & title)101 void SetTitle(const std::string& title) { _title=title; } SetComment(const std::string & comment)102 void SetComment(const std::string& comment) { _comment=comment; } 103 IsReversible()104 bool IsReversible() const {return _reversible;} 105 void SetReversible(bool b=true) {_reversible=b;} 106 ClassDescription()107 static const char* ClassDescription() 108 { 109 return " reactions\n"; 110 } 111 Clear()112 bool Clear() 113 { 114 _reactants.clear(); 115 _products.clear(); 116 _agents.clear(); 117 _ts.reset(); 118 _title.clear(); 119 _comment.clear(); 120 _reversible = false; 121 return true; 122 } 123 }; 124 125 126 } //namespace OpenBabel 127 #endif 128 129 //! \file reaction.h 130 //! \brief Handle chemical reactions (i.e., lists of reagents and products). 131