RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
Context.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// Stores the information that is global to the interpreter
14// in this case, values of ctes, names of variables,...
15// It basically contains a map of variables, class Vble is also defined here
16
17#ifndef _RBT_CONTEXT_H_
18#define _RBT_CONTEXT_H_
19
20#include "rxdock/BaseSF.h"
21#include "rxdock/DockingSite.h"
22#include "rxdock/Model.h"
23#include "rxdock/Vble.h"
24#include "rxdock/geneticprogram/GPTypes.h"
25#include <fstream>
26
27namespace rxdock {
28
29typedef std::map<std::string, VblePtr> StringVbleMap; // Map of Vbles
30typedef std::map<int, VblePtr> IntVbleMap; // Map of Vbles
31typedef StringVbleMap::iterator StringVbleMapIter;
32typedef IntVbleMap::iterator IntVbleMapIter;
33
34class Context {
35public:
36 static const std::string _CT;
38 // Constructors
40 Context(const Context &c);
41 Context(); // default constructor disabled
43 // Destructors
45 virtual ~Context();
46 virtual void Assign(std::string, ReturnType) = 0;
47 virtual void Assign(int, ReturnType) = 0;
48 virtual const Vble &GetVble(int) = 0;
49 virtual const Vble &GetVble(std::string) = 0;
50 virtual void SetVble(int key, const Vble &v) = 0;
51 // virtual String GetName(Int)=0;
52 // virtual ReturnType GetValue(Int)=0;
53 // virtual String GetName(String)=0;
54 // virtual ReturnType GetValue(String)=0;
55};
56
57class CellContext : public Context {
58public:
59 // static const std::string _CT;
60 CellContext(std::ifstream &ifile);
62 CellContext(const CellContext &c);
63 virtual ~CellContext();
64 void Assign(int key, ReturnType val) {
65 IntVbleMapIter it = vm.find(key);
66 if (it != vm.end())
67 vm[key]->SetValue(val);
68 else {
69 vm[key] = new Vble(std::to_string(val), val);
70 }
71 }
72 void Assign(std::string s, ReturnType val) {
73 throw Error(_WHERE_, "This is not a string context");
74 }
75 // String GetName(Int key) { return vm[key].GetName();}
76 // ReturnType GetValue(Int key) {return vm[key].GetValue();}
77 // String GetName(String){return "";}
78 // ReturnType GetValue(String){return 0.0;}
79 const Vble &GetVble(int key) { return *(vm[key]); }
80 void SetVble(int key, const Vble &v) { *(vm[key]) = v; }
81 const Vble &GetVble(std::string key) {
82 throw Error(_WHERE_, "This is not a string context");
83 }
84 // void Clear();
85
86private:
87 IntVbleMap vm;
88 int ninputs;
89};
90
91class StringContext : public Context {
92
93public:
94 // static const std::string _CT;
98 virtual ~StringContext();
99 void Assign(std::string key, ReturnType val) {
100 StringVbleMapIter it = vm.find(key);
101 if (it != vm.end())
102 vm[key]->SetValue(val);
103 else {
104 vm[key] = new Vble(key, val);
105 }
106 }
107 void Assign(int i, ReturnType val) {
108 throw Error(_WHERE_, "This is not a cell context");
109 }
110
111 // String GetName(Int){return "";}
112 // ReturnType GetValue(Int){return 0.0;}
113 // String GetName(String key) { return vm[key].GetName();}
114 // ReturnType GetValue(String key) {return vm[key].GetValue();}
115 double Get(ModelPtr lig, std::string name);
116 double Get(ModelPtr rec, DockingSitePtr site, std::string name);
117 double Get(BaseSF *spSF, std::string name, ModelPtr lig);
118 const Vble &GetVble(std::string key) { return *(vm[key]); }
119 const Vble &GetVble(int key) {
120 throw Error(_WHERE_, "This is not a cell context");
121 }
122 void SetVble(int key, const Vble &v) { *(vm[""]) = v; }
123 void UpdateLigs(ModelPtr lig);
124 void UpdateSite(ModelPtr rec, DockingSitePtr site);
125 void UpdateScores(BaseSF *spSF, ModelPtr lig);
126
127private:
128 StringVbleMap vm;
129};
130
131// Useful typedefs
132typedef SmartPtr<CellContext> CellContextPtr; // Smart pointer
133typedef std::vector<CellContextPtr> CellContextList; // Vector of smart
134 // pointers
135typedef CellContextList::iterator CellContextListIter;
136typedef CellContextList::const_iterator CellContextListConstIter;
137typedef SmartPtr<StringContext> StringContextPtr; // Smart pointer
138typedef std::vector<StringContextPtr>
139 StringContextList; // Vector of smart pointers
140typedef StringContextList::iterator StringContextListIter;
141typedef StringContextList::const_iterator StringContextListConstIter;
142typedef SmartPtr<Context> ContextPtr; // Smart pointer
143typedef std::vector<ContextPtr> ContextList; // Vector of smart pointers
144typedef ContextList::iterator ContextListIter;
145typedef ContextList::const_iterator ContextListConstIter;
146
147} // namespace rxdock
148
149#endif //_Context_H_
Definition BaseSF.h:28
Definition Context.h:57
Definition Context.h:34
Definition Error.h:59
Definition SmartPointer.h:48
Definition Context.h:91
Definition Vble.h:22