Open Babel  3.0
reaction.h
Go to the documentation of this file.
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 
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:
48  OBReaction() : _reversible(false)
49  {}
50 
51  int NumReactants() const
52  { return static_cast<int> (_reactants.size()); }
53 
54  int NumProducts()const
55  { return static_cast<int> (_products.size()); }
56 
57  int NumAgents() const
58  {
59  return static_cast<int> (_agents.size());
60  }
61 
62  void AddReactant(const obsharedptr<OBMol> sp)
63  { _reactants.push_back(sp); }
64 
65  void AddProduct(const obsharedptr<OBMol> sp)
66  { _products.push_back(sp); }
67 
68  void SetTransitionState(const obsharedptr<OBMol> sp)
69  { _ts = sp; }
70 
71  void AddAgent(const obsharedptr<OBMol> sp)
72  { _agents.push_back(sp); }
73 
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  }
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  }
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 
96  obsharedptr<OBMol> GetTransitionState()const
97  { return _ts; }
98 
99  std::string GetTitle() const { return _title; }
100  std::string GetComment() const { return _comment; }
101  void SetTitle(const std::string& title) { _title=title; }
102  void SetComment(const std::string& comment) { _comment=comment; }
103 
104  bool IsReversible() const {return _reversible;}
105  void SetReversible(bool b=true) {_reversible=b;}
106 
107  static const char* ClassDescription()
108  {
109  return " reactions\n";
110  }
111 
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 
OBReaction()
Definition: reaction.h:48
int NumAgents() const
Definition: reaction.h:57
obsharedptr< OBMol > GetAgent(const unsigned i)
Definition: reaction.h:88
void AddProduct(const obsharedptr< OBMol > sp)
Definition: reaction.h:65
Base classes to build a graph.
obsharedptr< OBMol > GetProduct(const unsigned i)
Definition: reaction.h:81
std::string GetComment() const
Definition: reaction.h:100
void SetReversible(bool b=true)
Definition: reaction.h:105
Used to store chemical reactions (i.e., reactants -> products)
Definition: reaction.h:37
int NumReactants() const
Definition: reaction.h:51
void AddReactant(const obsharedptr< OBMol > sp)
Definition: reaction.h:62
obsharedptr< OBMol > GetReactant(const unsigned i)
Definition: reaction.h:74
void SetComment(const std::string &comment)
Definition: reaction.h:102
void AddAgent(const obsharedptr< OBMol > sp)
Definition: reaction.h:71
bool IsReversible() const
Definition: reaction.h:104
void SetTitle(const std::string &title)
Definition: reaction.h:101
static const char * ClassDescription()
Definition: reaction.h:107
Shared pointer.
int NumProducts() const
Definition: reaction.h:54
obsharedptr< OBMol > GetTransitionState() const
Definition: reaction.h:96
bool Clear()
Clear any and all data associated with this object.
Definition: reaction.h:112
Base Class.
Definition: base.h:239
std::string GetTitle() const
Definition: reaction.h:99
void SetTransitionState(const obsharedptr< OBMol > sp)
Definition: reaction.h:68
Global namespace for all Open Babel code.
Definition: alias.h:22