COPASI API  4.16.103
CMetab.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CMetab class.
17  * Derived from Gepasi's cmetab.cpp. (C) Pedro Mendes 1995-2000.
18  * Converted for COPASI by Stefan Hoops 2001
19  */
20 
21 #ifndef COPASI_CMetab
22 #define COPASI_CMetab
23 
24 #include <string>
25 #include <iostream>
26 #include <set>
27 
30 #include "copasi/model/CMoiety.h"
31 
32 class CCompartment;
33 class CReadConfig;
34 class CMetabOld;
35 class CModel;
36 
38 {
39 private:
40  /**
41  * Hidden default constructor
42  */
44 
45 public:
46  /**
47  * Specific constructor
48  * @param const std::string & name
49  * @param const CCopasiContainer * pParent,
50  * @param C_FLOAT64 & reference,
51  */
52  CConcentrationReference(const std::string & name,
53  const CCopasiContainer * pParent,
54  C_FLOAT64 & reference);
55 
56  /**
57  * Copy constructor
58  * @param const CConcentrationReference & src
59  * @param const CCopasiContainer * pParent,
60  */
62  const CCopasiContainer * pParent);
63 
64  /**
65  * Destructor
66  */
68 
69  /**
70  * Retrieve the list of direct dependencies
71  * @param const CCopasiObject::DataObjectSet & context (default empty set)
72  * @return const CCopasiObject::DataObjectSet & directDependencies
73  */
74  virtual const DataObjectSet & getDirectDependencies(const DataObjectSet & context = DataObjectSet()) const;
75 
76  /**
77  * Check whether a given object is a prerequisite for a context.
78  * @param const CObjectInterface * pObject
79  * @param const CMath::SimulationContextFlag & context
80  * @param const CObjectInterface::ObjectSet & changedObjects
81  * @return bool isPrerequisiteForContext
82  */
83  virtual bool isPrerequisiteForContext(const CObjectInterface * pObject,
84  const CMath::SimulationContextFlag & context,
85  const CObjectInterface::ObjectSet & changedObjects) const;
86 
87  /**
88  * Retrieve the refresh call which calculates the concentration based on state values needed
89  * when applying the initial state.
90  * @return Refresh * applyInitialValueRefresh
91  */
93 
94  // Attributes
95 private:
96  /**
97  * The list of direct dependencies when the values is in the changed context,
98  * i.e., it is always empty
99  */
101 
102  /**
103  * The refresh call needed when applying initial values.
104  */
106 };
107 
108 class CParticleReference : public CCopasiObjectReference< C_FLOAT64 >
109 {
110  /**
111  * Hidden default constructor
112  */
114 
115 public:
116  /**
117  * Specific constructor
118  * @param const std::string & name
119  * @param const CCopasiContainer * pParent,
120  * @param C_FLOAT64 & reference,
121  */
122  CParticleReference(const std::string & name,
123  const CCopasiContainer * pParent,
124  C_FLOAT64 & reference);
125 
126  /**
127  * Copy constructor
128  * @param const CParticleReference & src
129  * @param const CCopasiContainer * pParent,
130  */
132  const CCopasiContainer * pParent);
133 
134  /**
135  * Destructor
136  */
138 
139  /**
140  * Retrieve the list of direct dependencies
141  * @param const CCopasiObject::DataObjectSet & context (default empty set)
142  * @return const CCopasiObject::DataObjectSet & directDependencies
143  */
144  virtual const DataObjectSet & getDirectDependencies(const DataObjectSet & context = DataObjectSet()) const;
145 
146  /**
147  * Retrieve the prerequisites, i.e., the objects which need to be evaluated
148  * before this.
149  * @return const CObjectInterface::ObjectSet & prerequisites
150  */
151  virtual const CObjectInterface::ObjectSet & getPrerequisites() const;
152 
153  /**
154  * Check whether a given object is a prerequisite for a context.
155  * @param const CObjectInterface * pObject
156  * @param const CMath::SimulationContextFlag & context
157  * @param const CObjectInterface::ObjectSet & changedObjects
158  * @return bool isPrerequisiteForContext
159  */
160  virtual bool isPrerequisiteForContext(const CObjectInterface * pObject,
161  const CMath::SimulationContextFlag & context,
162  const CObjectInterface::ObjectSet & changedObjects) const;
163 
164  // Attributes
165 private:
166  /**
167  * The list of direct dependencies when the values is in the changed context,
168  * i.e., it is always empty
169  */
171 
172  /**
173  * The prerequisites for building the math dependency graph.
174  */
176 };
177 
178 class CMetab : public CModelEntity
179 {
180  friend void CMoiety::add(C_FLOAT64 value, CMetab * pMetabolite);
181 
182 public:
183 
184  /**
185  * Converts the concentration to number
186  * @param const C_FLOAT64 & concentration
187  * @param const CCompartment & compartment
188  * @param const CModel & model
189  * @return C_FLOAT64 number
190  */
191  static C_FLOAT64 convertToNumber(const C_FLOAT64 & concentration,
192  const CCompartment & compartment,
193  const CModel & model);
194 
195  /**
196  * Converts the number to concentration
197  * @param const C_FLOAT64 & number
198  * @param const CCompartment & compartment
199  * @param const CModel & model
200  * @return C_FLOAT64 concentration
201  */
202  static C_FLOAT64 convertToConcentration(const C_FLOAT64 & number,
203  const CCompartment & compartment,
204  const CModel & model);
205 
206  // Attributes
207 private:
208  /**
209  * Concentration of the metabolite as double.
210  */
212 
213  /**
214  * Initial concentration of the metabolite as double
215  */
217 
218  /**
219  * The rate of concentration change
220  */
222 
223  /**
224  * Transition time of the metabolite
225  */
227 
228  /**
229  * pointer to the compartment the metabolite is located in.
230  * The metab needs to know about volumes.
231  */
233 
234  /**
235  * If dependent the moiety the metabolite is calculated from
236  */
237  const CMoiety * mpMoiety;
238 
239  std::vector< std::pair< C_FLOAT64, const C_FLOAT64 * > > mRateVector;
240 
242 
243 protected:
248 
249  // Operations
250 public:
251  /**
252  * Default constructor
253  * @param const std::string & name (default: "NoName")
254  * @param const CCopasiContainer * pParent (default: NULL)
255  */
256  CMetab(const std::string & name = "NoName",
257  const CCopasiContainer * pParent = NULL);
258 
259  /**
260  * Copy constructor
261  * @param const CMetab & src
262  * @param const CCopasiContainer * pParent (default: NULL)
263  */
264  CMetab(const CMetab & src,
265  const CCopasiContainer * pParent = NULL);
266 
267  /**
268  * Destructor.
269  */
270  ~CMetab();
271 
272  /**
273  * Retrieve the units of the child object.
274  * @return std::string units
275  */
276  virtual std::string getChildObjectUnits(const CCopasiObject * pObject) const;
277 
278  /**
279  * Retrieve the object representing the value;
280  */
281  virtual const CCopasiObject * getValueObject() const;
282 
283  /**
284  * Retrieve a pointer to the value;
285  */
286  virtual void * getValuePointer() const;
287 
288  virtual std::string getObjectDisplayName(bool regular = true, bool richtext = false) const;
289 
290  /**
291  * Cleanup
292  */
293  void cleanup();
294  void initCompartment(const CCompartment * pCompartment = NULL);
295 
296  /**
297  * Assignment operator.
298  */
299  CMetab & operator=(const CMetabOld & rhs);
300 
301  /**
302  * Loads an object with data coming from a CReadConfig object.
303  * (CReadConfig object reads an input stream)
304  * @param pconfigbuffer reference to a CReadConfig object.
305  * @return Fail
306  */
307  C_INT32 load(CReadConfig & configbuffer);
308 
309  /**
310  * Sets the parent of the metabolite;
311  * @param const CCopasiContainer * pParent
312  * @return bool success
313  */
314  virtual bool setObjectParent(const CCopasiContainer * pParent);
315 
316  /**
317  *
318  */
319  virtual void setStatus(const CModelEntity::Status & status);
320 
321  /**
322  * Compile the model value.
323  * @return bool success
324  */
325  virtual bool compile();
326 
327  /**
328  * Compile the initial particle number and initial concentration dependencies.
329  * @return bool success
330  */
332 
333  /**
334  * Determine whether changing the initial concentration is allowed
335  */
337 
338  /**
339  * Check whether changing the initial concentration is allowed
340  * @return const bool & allowed
341  */
342  const bool & isInitialConcentrationChangeAllowed() const;
343 
344  /**
345  * Calculate the value or the rate depending whether we have an ASIGNMENT or ODE
346  */
347  virtual void calculate();
348 
349  /**
350  * Retrieve the list of deleted numeric child objects;
351  * @return CCopasiObject::DataObjectSet deletedObjects
352  */
353  virtual DataObjectSet getDeletedObjects() const;
354 
355  /**
356  * Check whether an object must be deleted because its prerequisites can
357  * no longer be fulfilled due to the given deleted objects
358  * @param const DataObjectSet & deletedObjects
359  * @return bool mustBeDeleted
360  */
361  virtual bool mustBeDeleted(const DataObjectSet & deletedObjects) const;
362 
363  /**
364  *
365  */
366  void setConcentration(const C_FLOAT64 concentration);
367 
368  /**
369  *
370  */
371  const C_FLOAT64 & getConcentration() const;
372 
373  /**
374  *
375  */
376  void setInitialConcentration(const C_FLOAT64 & initialConcentration);
377 
378  /**
379  *
380  */
381  const C_FLOAT64 & getInitialConcentration() const;
382 
383  /**
384  * Retrieve object referencing the initial concentration
385  * @return CConcentrationReference * initialConcentrationReference
386  */
388 
389  /**
390  * Retrieve object referencing the concentration
391  * @return CConcentrationReference * concentrationReference
392  */
394 
395  /**
396  * Retrieve object referencing the concentration
397  * @return CCopasiObject * concentrationRateReference
398  */
400 
401  /**
402  * Refresh the initial value
403  */
404  virtual void refreshInitialValue();
405 
407 
408  void refreshConcentration();
409 
410  void refreshNumber();
411 
412  /**
413  *
414  */
415  const CCompartment * getCompartment() const;
416 
417  /**
418  *
419  */
420  const CModel * getModel() const;
421 
422  /**
423  * Set transition time
424  * @param "const C_FLOAT64 &" transitionTime
425  */
426  void setTransitionTime(const C_FLOAT64 & transitionTime);
427 
428  /**
429  * Retrieves the transition time
430  * @return "const C_FLOAT64 &" transitionTime
431  */
432  const C_FLOAT64 & getTransitionTime() const;
433 
434  /**
435  * Return rate of production of this metaboLite
436  */
438 
439  /**
440  * Calculate the concentration rate.
441  */
443 
444  /**
445  * Calculate the particle rate.
446  */
447  void refreshRate();
448 
449  /**
450  * Calculate the transition time.
451  */
452  void refreshTransitionTime();
453 
454  /**
455  * Set whether the metabolite is dependent, i.e., calculated
456  * by a moiety
457  * @param const CMoiety * pMoiety
458  */
459  void setDependentOn(const CMoiety * pMoiety);
460 
461  /**
462  * Retrieve whether the metabolite dependent
463  * @return bool dependent
464  */
465  bool isDependent() const;
466 
467  /**
468  * Retrieve a pointer to the moiety the species depends on
469  * @return const CMoiety * pMoiety;
470  */
471  const CMoiety * getMoiety() const;
472 
473  /**
474  * ostream operator
475  */
476  friend std::ostream & operator<<(std::ostream &os, const CMetab & d);
477 
478 private:
479  /**
480  * Initialize the contained CCopasiObjects
481  */
482  void initObjects();
483 };
484 
486 {
487  friend class CMetab;
488 
489  // Attributes
490 
491 private:
492  /**
493  * Concentration of the metabolite.
494  */
496 
497  /**
498  * Status of the metabolite.
499  * One of (METAB_FIXED, METAB_VARIABLE, METAB_DEPENDENT, METAB_MOIETY).
500  */
502 
503  /**
504  * Index of the compartment the metabolite is located in.
505  */
507 
508  // Operations
509 
510 public:
511  /**
512  * Default constructor
513  * @param const std::string & name (default: "NoName")
514  * @param const CCopasiContainer * pParent (default: NULL)
515  */
516  CMetabOld(const std::string & name = "NoName",
517  const CCopasiContainer * pParent = NULL);
518 
519  /**
520  * Copy constructor
521  * @param const CMetabOld & src
522  * @param const CCopasiContainer * pParent (default: NULL)
523  */
524  CMetabOld(const CMetabOld & src,
525  const CCopasiContainer * pParent = NULL);
526 
527  /**
528  * Destructor.
529  */
530  ~CMetabOld();
531 
532  /**
533  * cleanup()
534  */
535  void cleanup();
536 
537  /**
538  * Loads an object with data coming from a CReadConfig object.
539  * (CReadConfig object reads an input stream)
540  * @param pconfigbuffer reference to a CReadConfig object.
541  * @return Fail
542  */
543  C_INT32 load(CReadConfig & configbuffer);
544 
545  C_INT32 getIndex() const;
546 };
547 
548 #endif // COPASI_CMetab
C_INT32 load(CReadConfig &configbuffer)
Definition: CMetab.cpp:922
void setInitialConcentration(const C_FLOAT64 &initialConcentration)
Definition: CMetab.cpp:257
static DataObjectSet EmptyDependencies
Definition: CMetab.h:170
Header file of class CModelEntity and CModelValue.
const CMoiety * getMoiety() const
Definition: CMetab.cpp:992
CMetab & operator=(const CMetabOld &rhs)
Definition: CMetab.cpp:93
void initCompartment(const CCompartment *pCompartment=NULL)
Definition: CMetab.cpp:209
virtual void setStatus(const CModelEntity::Status &status)
Definition: CMetab.cpp:291
C_FLOAT64 mTT
Definition: CMetab.h:226
static DataObjectSet EmptyDependencies
Definition: CMetab.h:100
virtual void * getValuePointer() const
Definition: CMetab.cpp:895
const C_FLOAT64 & getInitialConcentration() const
Definition: CMetab.cpp:220
virtual bool setObjectParent(const CCopasiContainer *pParent)
Definition: CMetab.cpp:231
bool mIsInitialConcentrationChangeAllowed
Definition: CMetab.h:241
virtual void calculate()
Definition: CMetab.cpp:669
bool compileInitialValueDependencies()
Definition: CMetab.cpp:590
virtual bool mustBeDeleted(const DataObjectSet &deletedObjects) const
Definition: CMetab.cpp:819
C_INT32 load(CReadConfig &configbuffer)
Definition: CMetab.cpp:1017
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
Definition: CMetab.cpp:974
~CMetabOld()
Definition: CMetab.cpp:1013
#define C_INT32
Definition: copasi.h:90
C_FLOAT64 mConc
Definition: CMetab.h:211
Definition: CMetab.h:178
virtual bool isPrerequisiteForContext(const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
Definition: CMetab.cpp:1124
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
Definition: CMetab.cpp:1112
void cleanup()
Definition: CMetab.cpp:207
virtual DataObjectSet getDeletedObjects() const
Definition: CMetab.cpp:806
virtual const CCopasiObject * getValueObject() const
Definition: CMetab.cpp:889
CMetabOld(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
Definition: CMetab.cpp:997
void setDependentOn(const CMoiety *pMoiety)
Definition: CMetab.cpp:986
const CCompartment * mpCompartment
Definition: CMetab.h:232
const bool & isInitialConcentrationChangeAllowed() const
Definition: CMetab.cpp:664
const CModel * getModel() const
Definition: CMetab.cpp:224
Refresh * mpApplyInitialValuesRefresh
Definition: CMetab.h:105
CCopasiObject * getConcentrationRateReference() const
Definition: CMetab.cpp:867
C_FLOAT64 mConcRate
Definition: CMetab.h:221
void refreshRate()
Definition: CMetab.cpp:696
void refreshNumber()
Definition: CMetab.cpp:286
void refreshTransitionTime()
Definition: CMetab.cpp:728
virtual void refreshInitialValue()
Definition: CMetab.cpp:264
static C_FLOAT64 convertToNumber(const C_FLOAT64 &concentration, const CCompartment &compartment, const CModel &model)
Definition: CMetab.cpp:35
void setConcentration(const C_FLOAT64 concentration)
Definition: CMetab.cpp:250
void refreshInitialConcentration()
Definition: CMetab.cpp:269
void compileIsInitialConcentrationChangeAllowed()
Definition: CMetab.cpp:644
CCopasiObjectReference< C_FLOAT64 > * mpTTReference
Definition: CMetab.h:247
bool isDependent() const
Definition: CMetab.cpp:989
virtual std::string getChildObjectUnits(const CCopasiObject *pObject) const
Definition: CMetab.cpp:118
C_INT32 getIndex() const
Definition: CMetab.cpp:1075
CConcentrationReference * mpIConcReference
Definition: CMetab.h:244
std::set< const CObjectInterface * > ObjectSet
virtual bool compile()
Definition: CMetab.cpp:385
void refreshConcentration()
Definition: CMetab.cpp:281
CMetab::Status mStatus
Definition: CMetab.h:501
C_INT32 mCompartment
Definition: CMetab.h:506
void add(C_FLOAT64 value, CMetab *metabolite)
Definition: CMoiety.cpp:96
C_FLOAT64 mIConc
Definition: CMetab.h:216
#define C_FLOAT64
Definition: copasi.h:92
void refreshConcentrationRate()
Definition: CMetab.cpp:876
Refresh * getApplyInitialValueRefresh() const
Definition: CMetab.cpp:1136
void initObjects()
Definition: CMetab.cpp:777
C_FLOAT64 mIConc
Definition: CMetab.h:495
const CMoiety * mpMoiety
Definition: CMetab.h:237
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
Definition: CMetab.cpp:1161
friend std::ostream & operator<<(std::ostream &os, const CMetab &d)
Definition: CMetab.cpp:900
const C_FLOAT64 & getConcentration() const
Definition: CMetab.cpp:218
Definition: CModel.h:50
~CMetab()
Definition: CMetab.cpp:111
virtual const CObjectInterface::ObjectSet & getPrerequisites() const
Definition: CMetab.cpp:1207
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
CMetab(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
Definition: CMetab.cpp:46
void cleanup()
Definition: CMetab.cpp:1015
const C_FLOAT64 & getTransitionTime() const
Definition: CMetab.cpp:229
C_FLOAT64 getConcentrationRate() const
Definition: CMetab.cpp:870
CCopasiObjectReference< C_FLOAT64 > * mpConcRateReference
Definition: CMetab.h:246
std::set< const CCopasiObject * > DataObjectSet
void setTransitionTime(const C_FLOAT64 &transitionTime)
Definition: CMetab.cpp:226
static C_FLOAT64 convertToConcentration(const C_FLOAT64 &number, const CCompartment &compartment, const CModel &model)
Definition: CMetab.cpp:41
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
ObjectSet mPrerequisites
Definition: CMetab.h:175
CConcentrationReference * mpConcReference
Definition: CMetab.h:245
virtual bool isPrerequisiteForContext(const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
Definition: CMetab.cpp:1221
CConcentrationReference * getConcentrationReference() const
Definition: CMetab.cpp:864
std::vector< std::pair< C_FLOAT64, const C_FLOAT64 * > > mRateVector
Definition: CMetab.h:239