COPASI API  4.16.103
CTimeSeries.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) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef TIMESERIES_H
16 #define TIMESERIES_H
17 
18 #include <vector>
19 
20 #include "model/CState.h"
21 #include "utilities/CVector.h"
22 #include "utilities/CMatrix.h"
24 
25 class CModel;
26 class CCopasiDataModel;
27 
28 class CTimeSeries : public COutputInterface, protected CMatrix< C_FLOAT64 >
29 {
30 private:
31  //since the assignment operator are not properly implemented
32  //they should be inaccessible
33 
35 
36 public:
37  /**
38  * Default constructor
39  */
40  CTimeSeries();
41 
42  /**
43  * Copy constructor
44  * @param const CTimeSeries & src
45  */
46  CTimeSeries(const CTimeSeries & src);
47 
48  /**
49  * Destructor
50  */
51  ~CTimeSeries();
52 
53 public:
54  /**
55  * compile the object list from name vector
56  * @param std::vector< CCopasiContainer * > listOfContainer
57  * @param const CCopasiDataModel* pDataModel
58  * @return bool success
59  */
60  virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel* pDataModel);
61 
62  /**
63  * Perform an output event for the current activity
64  * @param const Activity & activity
65  */
66  virtual void output(const Activity & activity);
67 
68  /**
69  * Introduce an additional separator into the output
70  * @param const Activity & activity
71  */
72  virtual void separate(const Activity & activity);
73 
74  /**
75  * Finish the output
76  */
77  virtual void finish();
78 
79  //**** put data into time series ***
80 
81 public:
82  /**
83  * The maximal number of recorded steps. This must be set before compiling
84  * @param const size_t & steps
85  */
86  void allocate(const size_t & steps);
87 
88  /**
89  * Increase the allocated space for the time series.
90  */
91  void increaseAllocation();
92 
93  /**
94  * Clear the time series
95  */
96  void clear();
97 
98  /**
99  * Save the time series to a file
100  * @param const std::string & fileName
101  * @param bool writeConcentrations (default: false)
102  * @param const std::string& separator (default: "\t")
103  * @return int retcode
104  */
105  int save(const std::string& fileName,
106  bool writeConcentrations = false,
107  const std::string& separator = "\t") const;
108 
109  /**
110  * Retrieve the number of time steps (rows)
111  * @return const size_t & recordedSteps
112  */
113  const size_t & getRecordedSteps() const;
114 
115  /**
116  * Retrieve the number of variables (columns)
117  * @return size_t & numVariables
118  */
119  const size_t & getNumVariables() const;
120 
121  /**
122  * Retrieve the data (particle number for species) for the indexed step and variable
123  * @param const size_t & step
124  * @param const size_t & variable
125  * @return const C_FLOAT64 & data
126  */
127  const C_FLOAT64 & getData(const size_t & step,
128  const size_t & variable) const;
129 
130  /**
131  * Retrieve the data (concentration for species) for the indexed step and variable
132  * @param const size_t & step
133  * @param const size_t & variable
134  * @return const C_FLOAT64 & data
135  */
136  C_FLOAT64 getConcentrationData(const size_t & step,
137  const size_t & variable) const;
138 
139  /**
140  * Retrieve the title of the indexed variable (column)
141  * @param const size_t & variable
142  * @return const std::string & title
143  */
144  const std::string & getTitle(const size_t & variable) const;
145 
146  /**
147  * Retrieve the key of the model entity of the indexed variable (column)
148  * @param const size_t & variable
149  * @return const std::string & key
150  */
151  const std::string & getKey(const size_t & variable) const;
152 
153  /**
154  * get the id of the SBML object corresponding to column indexed by variable.
155  * If there is no corresponding SBML object (e.g. if the model comes from a
156  * COPASI file) the empty string is returned.
157  * @param const size_t & variable
158  * @return const std::string SBMLId
159  */
160  std::string getSBMLId(const size_t & variable, const CCopasiDataModel* pDataModel) const;
161 
162 private:
163 
164  /**
165  * The number of allocated steps
166  */
168 
169  /**
170  * The number of actually recorded steps
171  */
173 
174  /**
175  * Iterator pointing the next step (row) to be recorded
176  */
178 
179  /**
180  * Iterator pointing beyond the last allocated step (row)
181  */
183 
184  /**
185  * Pointer to the state which has to be recorded.
186  */
187  const CState * mpState;
188 
189  /**
190  * Vector of column titles.
191  */
192  std::vector< std::string > mTitles;
193 
194  /**
195  * Vector of indexes pointing to the column storing the volume of the containing
196  * compartment for a species (C_INVALID_INDEX otherwise)
197  */
199 
200  /**
201  * Pivot rearranging the columns to a more user friendly order
202  */
204 
205  /**
206  * Vector storing the keys for the model entity represented by each column
207  */
208  std::vector< std::string > mKeys;
209 
210  /**
211  * Conversion factor needed for computing concentration data
212  */
214 
215  /**
216  * Static empty string for performance reasons
217  */
218  static std::string mDummyString;
219 
220  /**
221  * Static C_FLOAT64 0.0 for performance reasons
222  */
224 };
225 
226 #endif
const size_t & getRecordedSteps() const
C_FLOAT64 getConcentrationData(const size_t &step, const size_t &variable) const
std::string getSBMLId(const size_t &variable, const CCopasiDataModel *pDataModel) const
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
const size_t & getNumVariables() const
C_FLOAT64 * mpEnd
Definition: CTimeSeries.h:182
int save(const std::string &fileName, bool writeConcentrations=false, const std::string &separator="\t") const
void clear()
Definition: CTimeSeries.cpp:96
std::vector< std::string > mTitles
Definition: CTimeSeries.h:192
size_t mRecordedSteps
Definition: CTimeSeries.h:172
const std::string & getTitle(const size_t &variable) const
void allocate(const size_t &steps)
Definition: CTimeSeries.cpp:73
Definition: CState.h:305
const CState * mpState
Definition: CTimeSeries.h:187
CTimeSeries & operator=(const CTimeSeries &)
const std::string & getKey(const size_t &variable) const
static std::string mDummyString
Definition: CTimeSeries.h:218
virtual void finish()
CVector< size_t > mPivot
Definition: CTimeSeries.h:203
static C_FLOAT64 mDummyFloat
Definition: CTimeSeries.h:223
const C_FLOAT64 & getData(const size_t &step, const size_t &variable) const
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mNumberToQuantityFactor
Definition: CTimeSeries.h:213
C_FLOAT64 * mpIt
Definition: CTimeSeries.h:177
Definition: CModel.h:50
void increaseAllocation()
Definition: CTimeSeries.cpp:79
size_t mAllocatedSteps
Definition: CTimeSeries.h:167
virtual void separate(const Activity &activity)
virtual void output(const Activity &activity)
CVector< size_t > mCompartment
Definition: CTimeSeries.h:198
std::vector< std::string > mKeys
Definition: CTimeSeries.h:208