MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MarkovChannel.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2011 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 #include "VectorTable.h"
12 #include "../builtins/Interpol2D.h"
13 #include "MarkovRateTable.h"
14 #include "ChanBase.h"
15 #include "ChanCommon.h"
16 #include "MarkovChannel.h"
17 
18 #if USE_GSL
19 #include <gsl/gsl_errno.h>
20 #endif
21 
23 {
25  //Field information.
27  static ValueFinfo< MarkovChannel, double > ligandconc( "ligandConc",
28  "Ligand concentration.",
31  );
32 
34  "Membrane voltage.",
37  );
38 
39  static ValueFinfo< MarkovChannel, unsigned int > numstates( "numStates",
40  "The number of states that the channel can occupy.",
43  );
44 
45 
46  static ValueFinfo< MarkovChannel, unsigned int > numopenstates( "numOpenStates",
47  "The number of states which are open/conducting.",
50  );
51 
52  static ValueFinfo< MarkovChannel, vector< string > > labels("labels",
53  "Labels for each state.",
56  );
57 
59  "This is a row vector that contains the probabilities of finding the channel in each state.",
61  );
62 
63  static ValueFinfo< MarkovChannel, vector< double > > initialstate( "initialState",
64  "This is a row vector that contains the probabilities of finding the channel in each state at t = 0. The state of the channel is reset to this value during a call to reinit()",
67  );
68 
69  static ValueFinfo< MarkovChannel, vector< double > > gbar( "gbar",
70  "A row vector containing the conductance associated with each of the open/conducting states.",
73  );
74 
75  //MsgDest functions
76  static DestFinfo handleligandconc( "handleLigandConc",
77  "Deals with incoming messages containing information of ligand concentration",
79 
80  static DestFinfo handlestate("handleState",
81  "Deals with incoming message from MarkovSolver object containing state information of the channel.\n",
82  new OpFunc1< MarkovChannel, vector< double > >(&MarkovChannel::handleState) );
83 
85  static Finfo* MarkovChannelFinfos[] =
86  {
87  &ligandconc,
88  &vm,
89  &numstates,
90  &numopenstates,
91  &state,
92  &initialstate,
93  &labels,
94  &gbar,
95  &handleligandconc,
96  &handlestate,
97  };
98 
99  static string doc[] =
100  {
101  "Name", "MarkovChannel",
102  "Author", "Vishaka Datta S, 2011, NCBS",
103  "Description", "MarkovChannel : Multistate ion channel class."
104  "It deals with ion channels which can be found in one of multiple states, "
105  "some of which are conducting. This implementation assumes the occurence "
106  "of first order kinetics to calculate the probabilities of the channel "
107  "being found in all states. Further, the rates of transition between these "
108  "states can be constant, voltage-dependent or ligand dependent (only one "
109  "ligand species). The current flow obtained from the channel is calculated "
110  "in a deterministic method by solving the system of differential equations "
111  "obtained from the assumptions above."
112  };
113 
114  static Dinfo< MarkovChannel > dinfo;
115  static Cinfo MarkovChannelCinfo(
116  "MarkovChannel",
118  MarkovChannelFinfos,
119  sizeof( MarkovChannelFinfos )/ sizeof( Finfo* ),
120  &dinfo,
121  doc,
122  sizeof(doc) / sizeof(string)
123  );
124 
125  return &MarkovChannelCinfo;
126 }
127 
129 
131  g_(0),
132  ligandConc_(0),
133  numStates_(0),
134  numOpenStates_(0)
135 { ; }
136 
137 MarkovChannel::MarkovChannel(unsigned int numStates, unsigned int numOpenStates) :
138  g_(0), ligandConc_(0), numStates_(numStates), numOpenStates_(numOpenStates)
139 {
140  stateLabels_.resize( numStates );
141  state_.resize( numStates );
142  initialState_.resize( numStates );
143  Gbars_.resize( numOpenStates ) ;
144 }
145 
147 {
148  ;
149 }
150 
151 double MarkovChannel::getVm( ) const
152 {
153  return Vm_;
154 }
155 
156 void MarkovChannel::setVm( double Vm )
157 {
158  Vm_ = Vm;
159 }
160 
162 {
163  return ligandConc_;
164 }
165 
166 void MarkovChannel::setLigandConc( double ligandConc )
167 {
168  ligandConc_ = ligandConc;
169 }
170 
171 unsigned int MarkovChannel::getNumStates( ) const
172 {
173  return numStates_;
174 }
175 
176 void MarkovChannel::setNumStates( unsigned int numStates )
177 {
178  numStates_ = numStates;
179 }
180 
181 unsigned int MarkovChannel::getNumOpenStates( ) const
182 {
183  return numOpenStates_;
184 }
185 
186 void MarkovChannel::setNumOpenStates( unsigned int numOpenStates )
187 {
188  numOpenStates_ = numOpenStates;
189 }
190 
191 vector< string > MarkovChannel::getStateLabels( ) const
192 {
193  return stateLabels_;
194 }
195 
196 void MarkovChannel::setStateLabels( vector< string > stateLabels )
197 {
198  stateLabels_ = stateLabels;
199 }
200 
201 vector< double > MarkovChannel::getState ( ) const
202 {
203  return state_;
204 }
205 
206 vector< double > MarkovChannel::getInitialState() const
207 {
208  return initialState_;
209 }
210 
211 void MarkovChannel::setInitialState( vector< double > initialState )
212 {
213  initialState_ = initialState;
214  state_ = initialState;
215 }
216 
217 vector< double > MarkovChannel::getGbars() const
218 {
219  return Gbars_;
220 }
221 
222 void MarkovChannel::setGbars( vector< double > Gbars )
223 {
224  Gbars_ = Gbars;
225 }
226 
228 //MsgDest functions
230 
231 void MarkovChannel::vProcess( const Eref& e, const ProcPtr p )
232 {
233  g_ = 0.0;
234 
235  //Cannot use the Gbar_ variable of the ChanBase class. The conductance
236  //Gk_ calculated here is the "expected conductance" of the channel due to its
237  //stochastic nature.
238 
239  for( unsigned int i = 0; i < numOpenStates_; ++i )
240  g_ += Gbars_[i] * state_[i];
241 
242  setGk( e, g_ );
243  updateIk();
244 
245  sendProcessMsgs( e, p );
246 }
247 
248 void MarkovChannel::vReinit( const Eref& e, const ProcPtr p )
249 {
250  g_ = 0.0;
251 
252  if ( initialState_.empty() )
253  {
254  cerr << "MarkovChannel::reinit : Initial state has not been set.!\n";
255  return;
256  }
258 
259  sendReinitMsgs( e, p );
260 }
261 
262 void MarkovChannel::handleLigandConc( double ligandConc )
263 {
264  ligandConc_ = ligandConc;
265 }
266 
267 void MarkovChannel::handleState( vector< double > state )
268 {
269  state_ = state;
270 }
void vProcess(const Eref &, const ProcPtr)
vector< double > getState() const
double getVm() const
void setVm(double)
unsigned int numStates_
Definition: MarkovChannel.h:75
Definition: Dinfo.h:60
void setInitialState(vector< double >)
void setLigandConc(double)
void handleState(vector< double >)
void updateIk()
Definition: ChanCommon.cpp:119
void setGbars(vector< double >)
void setGk(const Eref &e, double Gk)
Definition: ChanBase.cpp:216
void handleLigandConc(double)
double Vm_
Vm_ is input variable from compartment, used for most rates.
Definition: ChanCommon.h:80
unsigned int numOpenStates_
Definition: MarkovChannel.h:76
unsigned int getNumStates() const
vector< string > stateLabels_
Definition: MarkovChannel.h:78
vector< double > initialState_
Definition: MarkovChannel.h:80
void vReinit(const Eref &, const ProcPtr)
static const Cinfo * markovChannelCinfo
Definition: OpFunc.h:27
Definition: Eref.h:26
vector< double > state_
Definition: MarkovChannel.h:79
vector< double > getInitialState() const
vector< double > Gbars_
Definition: MarkovChannel.h:81
vector< double > getGbars() const
double getLigandConc() const
vector< string > getStateLabels() const
void sendReinitMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:111
static const Cinfo * initCinfo()
double ligandConc_
Definition: MarkovChannel.h:74
void setNumStates(unsigned int)
void sendProcessMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:100
unsigned int getNumOpenStates() const
Definition: Cinfo.h:18
static const Cinfo * initCinfo()
Specify the Class Info static variable for initialization.
Definition: ChanBase.cpp:36
void setNumOpenStates(unsigned int)
Definition: Finfo.h:12
void setStateLabels(vector< string >)