COPASI API  4.16.103
CEFMProblem.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/elementaryFluxModes/CEFMProblem.cpp,v $
3  $Revision: 1.6 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2012/05/10 16:03:08 $
7  End CVS Header */
8 
9 // Copyright (C) 2012 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #include "copasi.h"
24 
25 #include "CEFMProblem.h"
26 #include "CEFMTask.h"
27 #include "CFluxMode.h"
28 #include "CEFMMethod.h"
29 
30 #include "model/CReaction.h"
31 #include "model/CModel.h"
33 
34 // Default constructor
36  CCopasiProblem(CCopasiTask::optimization, pParent),
37  mFluxModes(),
38  mReorderedReactions()
39 {
41  initObjects();
42 }
43 
44 // copy constructor
46  const CCopasiContainer * pParent):
47  CCopasiProblem(src, pParent),
48  mFluxModes(src.mFluxModes),
49  mReorderedReactions(src.mReorderedReactions)
50 {
52  initObjects();
53 }
54 
55 // Destructor
57 {}
58 
60 {elevateChildren();}
61 
63 {return true;}
64 
66 {
67  CCopasiProblem::setCallBack(pCallBack);
68 
69  return true;
70 }
71 
73 {}
74 
76 {
78 }
79 
80 const std::vector< CFluxMode > & CEFMProblem::getFluxModes() const
81 {return mFluxModes;}
82 
83 std::vector< CFluxMode > & CEFMProblem::getFluxModes()
84 {return mFluxModes;}
85 
86 const std::vector< const CReaction * > & CEFMProblem::getReorderedReactions() const
87 {return mReorderedReactions;}
88 
89 std::vector< const CReaction * > & CEFMProblem::getReorderedReactions()
90 {return mReorderedReactions;}
91 
92 void CEFMProblem::printResult(std::ostream * ostream) const
93 {
94  CEFMTask * pTask = dynamic_cast< CEFMTask * >(getObjectParent());
95 
96  if (pTask)
97  {
98  const std::vector< CFluxMode > & FluxModes = pTask->getFluxModes();
99 
100  // List
101  *ostream << "\tNumber of Modes:\t" << FluxModes.size() << std::endl;
102 
103  // Column header
104  *ostream << "#\t\tReactions\tEquations" << std::endl;
105 
106  std::vector< CFluxMode >::const_iterator itMode = FluxModes.begin();
107  std::vector< CFluxMode >::const_iterator endMode = FluxModes.end();
108 
109  unsigned C_INT32 j;
110 
111  for (j = 0; itMode != endMode; ++itMode, j++)
112  {
113  *ostream << j + 1;
114 
115  if (itMode->isReversible() == true)
116  *ostream << "\tReversible";
117  else
118  *ostream << "\tIrreversible";
119 
120  std::string Description = pTask->getFluxModeDescription(*itMode);
121  CFluxMode::const_iterator itReaction = itMode->begin();
122  CFluxMode::const_iterator endReaction = itMode->end();
123 
124  std::string::size_type start = 0;
125  std::string::size_type end = 0;
126 
127  for (; itReaction != endReaction; ++itReaction)
128  {
129  if (itReaction != itMode->begin())
130  *ostream << "\t";
131 
132  end = Description.find("\n", start);
133  *ostream << "\t" << Description.substr(start, end - start);
134  start = end + 1;
135  *ostream << "\t" << pTask->getReactionEquation(itReaction) << std::endl;
136  }
137  }
138 
139  *ostream << std::endl;
140 
141  // Net Reactions
142  // Column header
143  *ostream << "#\tNet Reaction\tInternal Species" << std::endl;
144 
145  itMode = FluxModes.begin();
146 
147  for (j = 0; itMode != endMode; ++itMode, j++)
148  {
149  *ostream << j + 1;
150  *ostream << "\t" << pTask->getNetReaction(*itMode);
151  *ostream << "\t" << pTask->getInternalSpecies(*itMode) << std::endl;
152  }
153 
154  *ostream << std::endl;
155 
156  // EFM vs Reaction
157  std::vector< const CReaction * >::const_iterator itReaction = mReorderedReactions.begin();
158  std::vector< const CReaction * >::const_iterator endReaction = mReorderedReactions.end();
159 
160  // Column header
161  *ostream << "#";
162 
163  for (; itReaction != endReaction; ++itReaction)
164  {
165  *ostream << "\t" << (*itReaction)->getObjectName();
166  }
167 
168  *ostream << std::endl;
169 
170  itMode = FluxModes.begin();
171  size_t k;
172 
173  for (j = 0; itMode != endMode; ++itMode, j++)
174  {
175  itReaction = mReorderedReactions.begin();
176 
177  *ostream << j + 1;
178 
179  for (k = 0; itReaction != endReaction; ++itReaction, k++)
180  {
181  *ostream << "\t" << itMode->getMultiplier(k);
182  }
183 
184  *ostream << std::endl;
185  }
186 
187  *ostream << std::endl;
188 
189  if (mpModel == NULL) return;
190 
191  // EFM vs Species
192  std::vector< CMetab * >::const_iterator itSpecies = mpModel->getMetabolites().begin();
193  std::vector< CMetab * >::const_iterator endSpecies = mpModel->getMetabolites().end();
194  // Column header
195  *ostream << "#";
196 
197  for (; itSpecies != endSpecies; ++itSpecies)
198  {
199  *ostream << "\t" << CMetabNameInterface::getDisplayName(mpModel, **itSpecies, false);
200  }
201 
202  *ostream << std::endl;
203 
204  itMode = FluxModes.begin();
205 
206  for (j = 0; itMode != endMode; ++itMode, j++)
207  {
208  itSpecies = mpModel->getMetabolites().begin();
209 
210  *ostream << j + 1;
211 
212  for (; itSpecies != endSpecies; ++itSpecies)
213  {
214  std::pair< C_FLOAT64, C_FLOAT64 > Changes =
215  pTask->getSpeciesChanges(*itMode, **itSpecies);
216 
217  *ostream << "\t";
218 
219  if (Changes.first > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() ||
220  Changes.second > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon())
221  {
222  *ostream << "-" << Changes.first << " | +" << Changes.second;
223  }
224  }
225 
226  *ostream << std::endl;
227  }
228 
229  *ostream << std::endl;
230  }
231 }
std::string getNetReaction(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:274
void initObjects()
Definition: CEFMProblem.cpp:72
std::string getReactionEquation(const std::map< size_t, C_FLOAT64 >::const_iterator &itReaction) const
Definition: CEFMTask.cpp:188
std::pair< C_FLOAT64, C_FLOAT64 > getSpeciesChanges(const CFluxMode &fluxMode, const CMetab &metab) const
Definition: CEFMTask.cpp:216
std::string getFluxModeDescription(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:132
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
void initializeParameter()
Definition: CEFMProblem.cpp:59
CEFMProblem(const CCopasiContainer *pParent=NULL)
Definition: CEFMProblem.cpp:35
iterator begin()
const std::vector< CFluxMode > & getFluxModes() const
Definition: CEFMTask.cpp:183
#define C_INT32
Definition: copasi.h:90
static std::string getDisplayName(const CModel *model, const std::string &key, const bool &quoted)
virtual bool initialize()
Definition: CEFMProblem.cpp:75
CTSSATask * pTask
iterator end()
const std::vector< CFluxMode > & getFluxModes() const
Definition: CEFMProblem.cpp:80
std::string getInternalSpecies(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:334
virtual bool setCallBack(CProcessReport *pCallBack)
Definition: CEFMProblem.cpp:65
const std::vector< const CReaction * > & getReorderedReactions() const
Definition: CEFMProblem.cpp:86
virtual ~CEFMProblem()
Definition: CEFMProblem.cpp:56
std::vector< const CReaction * > mReorderedReactions
Definition: CEFMProblem.h:135
std::vector< CFluxMode > mFluxModes
Definition: CEFMProblem.h:130
virtual void printResult(std::ostream *ostream) const
Definition: CEFMProblem.cpp:92
std::map< size_t, C_FLOAT64 >::const_iterator const_iterator
Definition: CFluxMode.h:43
virtual bool setCallBack(CProcessReport *pCallBack)
CModel * mpModel
virtual bool elevateChildren()
Definition: CEFMProblem.cpp:62
virtual bool initialize()
CCopasiContainer * getObjectParent() const