COPASI API  4.16.103
CLayoutInitializer.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLayoutInitializer.cpp,v $
3 // $Revision: 1.4 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:28:47 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 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) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #include "CLayoutInitializer.h"
19 
20 #include "model/CModel.h"
21 #include "CLayout.h"
22 
23 //static
24 /*CLayout * CLayoutInitializer::createLayoutFromCModel(const CModel* model)
25 {
26  if (!model) return NULL;
27 
28  CLayout * layout = new CLayout("dummy layout");
29 
30  size_t i, imax;
31 
32  //compartments
33  imax = model->getCompartments().size();
34 
35  for (i = 0; i < imax; ++i)
36  {
37  CLCompartmentGlyph * comp = createCompartmentGlyph(model->getCompartments()[i]);
38  layout->addCompartmentGlyph(comp);
39  }
40 
41  //metabs
42  std::map<std::string, std::string> metabMap; //maps from metab key to metab glyph key
43  imax = model->getMetabolites().size();
44 
45  for (i = 0; i < imax; ++i)
46  {
47  CLMetabGlyph * comp = createMetabGlyph(model->getMetabolites()[i]);
48  layout->addMetaboliteGlyph(comp);
49  metabMap[comp->getModelObjectKey()] = comp->getKey();
50  }
51 
52  //reactions
53  imax = model->getReactions().size();
54 
55  for (i = 0; i < imax; ++i)
56  {
57  CLReactionGlyph * reac = createReactionGlyph(model->getReactions()[i], metabMap);
58  layout->addReactionGlyph(reac);
59  }
60 
61  //temporary
62  //std::ofstream ofs; ofs.open("CopasiModel.dot");
63  //layout->exportToDotFile(ofs);
64  //ofs.close();
65 
66  return layout;
67 }*/
68 
70 {
71  if (!c) return NULL;
72 
74  cg->setModelObjectKey(c->getKey());
75 
76  return cg;
77 }
78 
80 {
81  if (!m) return NULL;
82 
83  CLMetabGlyph* cg = new CLMetabGlyph();
84  cg->setModelObjectKey(m->getKey());
85 
86  return cg;
87 }
88 
90  const std::map<std::string, std::string> & mm)
91 {
92  if (!r) return NULL;
93 
94  CLReactionGlyph* rg = new CLReactionGlyph();
95  rg->setModelObjectKey(r->getKey());
96 
97  const CChemEq & ce = r->getChemEq();
98  size_t i, imax;
99 
100  //substrates
101  imax = ce.getSubstrates().size();
102 
103  for (i = 0; i < imax; ++i)
104  {
105  //create metab reference glyph and add to reaction glyph
108  rg->addMetabReferenceGlyph(tmpMRG);
109 
110  //get the metab key from the copasi reaction
111  std::string metabKey = ce.getSubstrates()[i]->getMetaboliteKey();
112 
113  //set the corresponding metab glyph key
114  const std::map<std::string, std::string>::const_iterator it = mm.find(metabKey);
115 
116  if (it != mm.end())
117  tmpMRG->setMetabGlyphKey(it->second);
118  }
119 
120  //products
121  imax = ce.getProducts().size();
122 
123  for (i = 0; i < imax; ++i)
124  {
125  //create metab reference glyph and add to reaction glyph
128  rg->addMetabReferenceGlyph(tmpMRG);
129 
130  //get the metab key from the copasi reaction
131  std::string metabKey = ce.getProducts()[i]->getMetaboliteKey();
132 
133  //set the corresponding metab glyph key
134  const std::map<std::string, std::string>::const_iterator it = mm.find(metabKey);
135 
136  if (it != mm.end())
137  tmpMRG->setMetabGlyphKey(it->second);
138  }
139 
140  //modifier
141  imax = ce.getModifiers().size();
142 
143  for (i = 0; i < imax; ++i)
144  {
145  //create metab reference glyph and add to reaction glyph
148  rg->addMetabReferenceGlyph(tmpMRG);
149 
150  //get the metab key from the copasi reaction
151  std::string metabKey = ce.getModifiers()[i]->getMetaboliteKey();
152 
153  //set the corresponding metab glyph key
154  const std::map<std::string, std::string>::const_iterator it = mm.find(metabKey);
155 
156  if (it != mm.end())
157  tmpMRG->setMetabGlyphKey(it->second);
158  }
159 
160  return rg;
161 }
virtual size_t size() const
static CLCompartmentGlyph * createCompartmentGlyph(const CCompartment *c)
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
void addMetabReferenceGlyph(CLMetabReferenceGlyph *glyph)
Definition: CMetab.h:178
void setModelObjectKey(const std::string &k)
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
virtual const std::string & getKey() const
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
void setMetabGlyphKey(const std::string &k)
static CLReactionGlyph * createReactionGlyph(const CReaction *r, const std::map< std::string, std::string > &mm)
const CCopasiVector< CChemEqElement > & getModifiers() const
Definition: CChemEq.cpp:66
static CLMetabGlyph * createMetabGlyph(const CMetab *m)
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223