reaction.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

reaction.h
Go to the documentation of this file.

    00001 /**********************************************************************
    00002 reaction.h - Handle chemical reactions (i.e., lists of reagents and products).
    00003
    00004 Copyright (C) 2005 by Chris Morley
    00005
    00006 This file is part of the Open Babel project.
    00007 For more information, see <http://openbabel.org/>
    00008
    00009 This program is free software; you can redistribute it and/or modify
    00010 it under the terms of the GNU General Public License as published by
    00011 the Free Software Foundation version 2 of the License.
    00012
    00013 This program is distributed in the hope that it will be useful,
    00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016 GNU General Public License for more details.
    00017 ***********************************************************************/
    00018
    00019 #ifndef OB_REACT_H
    00020 #define OB_REACT_H
    00021
    00022 #include <vector>
    00023 #include <openbabel/shared_ptr.h>
    00024 #include <openbabel/mol.h>
    00025
    00026 namespace OpenBabel
    00027 {
    00028
    00035 class OBReaction : public OBBase
    00036 {
    00037 private:
    00038   std::vector<shared_ptr<OBMol> > _reactants;
    00039   std::vector<shared_ptr<OBMol> > _products;
    00040   shared_ptr<OBMol> _ts;
    00041   shared_ptr<OBMol> _agent;
    00042   std::string _title;
    00043   std::string _comment;
    00044   bool _reversible;
    00045 public:
    00046   OBReaction() : _reversible(false)
    00047   {}
    00048
    00049   int NumReactants() const
    00050   { return static_cast<int> (_reactants.size()); }
    00051
    00052   int NumProducts()const
    00053   { return static_cast<int> (_products.size()); }
    00054
    00055   void AddReactant(const shared_ptr<OBMol> sp)
    00056   { _reactants.push_back(sp); }
    00057
    00058   void AddProduct(const shared_ptr<OBMol> sp)
    00059   { _products.push_back(sp); }
    00060
    00061   void SetTransitionState(const shared_ptr<OBMol> sp)
    00062   { _ts = sp; }
    00063
    00064   void AddAgent(const shared_ptr<OBMol> sp)
    00065   { _agent = sp; }
    00066
    00067   shared_ptr<OBMol> GetReactant(const unsigned i)
    00068   {
    00069     shared_ptr<OBMol> sp;
    00070     if(i<_reactants.size())
    00071       sp = _reactants[i];
    00072     return sp; //returns empty if out of range
    00073   }
    00074   shared_ptr<OBMol> GetProduct(const unsigned i)
    00075   {
    00076     shared_ptr<OBMol> sp;
    00077     if(i<_products.size())
    00078       sp = _products[i];
    00079     return sp; //returns empty if out of range
    00080   }
    00081
    00082   shared_ptr<OBMol> GetTransitionState()const
    00083   { return _ts; }
    00084
    00085   shared_ptr<OBMol> GetAgent()const
    00086   { return _agent; }
    00087
    00088   std::string GetTitle()        const { return _title; }
    00089   std::string GetComment()      const { return _comment; }
    00090   void SetTitle(const std::string& title) { _title=title; }
    00091   void SetComment(const std::string& comment) { _comment=comment; }
    00092
    00093   bool IsReversible() const       {return _reversible;}
    00094   void SetReversible(bool b=true) {_reversible=b;}
    00095
    00096   static const char* ClassDescription()
    00097   {
    00098     return " reactions\n";
    00099   }
    00100
    00101   bool Clear()
    00102   {
    00103     _reactants.clear();
    00104     _products.clear();
    00105     _ts.reset();
    00106     _agent.reset();
    00107     _title.clear();
    00108     _comment.clear();
    00109     _reversible = false;
    00110     return true;
    00111   }
    00112 };
    00113
    00114
    00115 } //namespace OpenBabel
    00116 #endif
    00117

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines