12 #include "../shell/Shell.h"
14 #define DO_CSPACE_DEBUG 0
40 string separator = (
USE_PIPE ) ?
"|" :
"" ;
49 for ( i = 0; i <
mollist_.size(); i++ )
62 id.element()->getName() == ( parent.
element()->
getName() +
"_cplx" )
87 const string& modelname,
Id pa,
const string& solverClass )
91 unsigned long pos = model.find_first_of(
"|" );
92 if ( pos == string::npos ) {
93 cerr <<
"ReadCspace::readModelString: Error: model undefined in\n";
94 cerr << model <<
"\n";
106 compt_ =
Id( modelpath +
"/kinetics");
110 string temp = model.substr( pos + 1 );
111 pos = temp.find_first_of(
" \n" );
113 for (
unsigned long i = 0 ; i < temp.length() && i < pos; i += 5 ) {
114 build( temp.c_str() + i );
115 if ( temp[ i + 4 ] !=
'|' )
121 pos = model.find_last_of(
"|" ) + 1;
124 while ( pos < model.length() ) {
125 if ( model[ pos ] ==
' ' ) {
126 val = atof( model.c_str() + pos + 1 );
127 assert( i <
parms_.size() );
142 vector< Id > children;
145 Id graphs( basepath +
"/graphs" );
146 assert( graphs !=
Id () );
147 for (
unsigned int i = 0; i < children.size(); ++i ) {
148 const Cinfo* kidCinfo = children[i].element()->cinfo();
149 if ( kidCinfo->
isA(
"PoolBase" ) ) {
150 string plotname =
"plot" + children[i].element()->getName();
151 Id tab = shell->
doCreate(
"Table2", graphs, plotname, 1 );
152 assert( tab !=
Id() );
155 tab,
"requestOut", children[i],
"getConc" );
156 assert( mid !=
ObjId() );
185 const char*
name,
int e,
int s,
int p,
int p2 )
189 Id enzMolId =
mol_[ name[e] -
'a' ];
191 Id enzId = shell->
doCreate(
"Enz", enzMolId, name, 1 );
192 assert( enzId !=
Id() );
193 string cplxName =
name;
195 Id cplxId = shell->
doCreate(
"Pool", enzId, cplxName, 1 );
196 assert( cplxId !=
Id() );
198 enzId,
"cplx", cplxId,
"reac" );
201 enzMolId,
"reac", enzId,
"enz" );
204 mol_[ name[ s ] -
'a' ],
"reac", enzId,
"sub" );
207 mol_[ name[ p ] -
'a' ],
"reac", enzId,
"prd" );
211 mol_[ name[ p2 ] -
'a' ],
"reac", enzId,
"prd" );
213 assert( ret !=
ObjId() );
215 reac_.push_back( enzId );
224 if ( name[0] ==
'C' || name[0] ==
'D' || name[0] >=
'J' )
231 for (i = 0; i < nm1; i++ ) {
232 s->
doAddMsg(
"OneToOne", reacId,
"sub",
mol_[ name[1] -
'a' ],
"reac" );
235 if ( name[0] <
'G' ) {
236 s->
doAddMsg(
"OneToOne", reacId,
"prd",
mol_[ name[2] -
'a' ],
"reac" );
238 s->
doAddMsg(
"OneToOne", reacId,
"sub",
mol_[ name[2] -
'a' ],
"reac" );
241 if ( name[0] >
'D' ) {
242 s->
doAddMsg(
"OneToOne", reacId,
"prd",
mol_[ name[3] -
'a' ],
"reac" );
245 if ( name[0] ==
'H' ) {
246 s->
doAddMsg(
"OneToOne", reacId,
"prd",
mol_[ name[3] -
'a' ],
"reac" );
248 reac_.push_back( reacId );
259 strncpy( tname, name, 4 );
262 switch ( tname[0] ) {
302 if ( name < 'a' || name >
'z' ) {
303 cerr <<
"ReadCspace::makeMolecule Error: name '" << name <<
304 "' out of range 'a' to 'z'\n";
308 unsigned int index = 1 + name -
'a';
313 molseq_.push_back( index - 1 );
315 for (
unsigned int i =
mol_.size(); i < index; i++ ) {
324 mol_.push_back( temp );
334 cerr <<
"ReadCspace::deployParameters: Error: # of parms mismatch\n";
337 for ( i = 0; i <
mol_.size(); i++ ) {
344 for ( j = 0; j <
reac_.size(); j++ ) {
345 if (
reac_[ j ].element()->cinfo()->isA(
"Reac" ) ) {
354 vector< Id > cplx( 0 );
356 assert( cplx.size() == 1 );
363 const double CONCSCALE = 1e-3;
367 assert(
mol_.size() == 3 );
368 assert(
reac_.size() == 2 );
372 modelId =
readModelString(
"|AabX|BbcX|CcdX|DdeX|Eefg|Ffgh|Gghi|Hhij|Iijk|Jjkl|Kklm|Llmn| 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 101 102 201 202 301 302 401 402 501 502 601 602 701 702 801 802 901 902 1001 1002 1101 1102 1201 1202",
373 "model",
Id(),
"Neutral" );
374 assert(
mol_.size() == 14 );
375 assert(
reac_.size() == 12 );
379 for ( i = 0; i < 14; i++ ) {
393 assert(
doubleEq( concInit, 0.001 * ( i + 1 ) ) );
397 assert(
reac_[ 0 ].
path() ==
"/model/kinetics/AabX" );
398 assert(
reac_[ 1 ].
path() ==
"/model/kinetics/BbcX" );
399 assert(
reac_[ 2 ].
path() ==
"/model/kinetics/c/CcdX" );
400 assert(
reac_[ 3 ].
path() ==
"/model/kinetics/e/DdeX" );
401 assert(
reac_[ 4 ].
path() ==
"/model/kinetics/Eefg" );
402 assert(
reac_[ 5 ].
path() ==
"/model/kinetics/Ffgh" );
403 assert(
reac_[ 6 ].
path() ==
"/model/kinetics/Gghi" );
404 assert(
reac_[ 7 ].
path() ==
"/model/kinetics/Hhij" );
405 assert(
reac_[ 8 ].
path() ==
"/model/kinetics/Iijk" );
406 assert(
reac_[ 9 ].
path() ==
"/model/kinetics/k/Jjkl" );
407 assert(
reac_[ 10 ].
path() ==
"/model/kinetics/k/Kklm" );
408 assert(
reac_[ 11 ].
path() ==
"/model/kinetics/m/Llmn" );
411 Id tempA(
"/model/kinetics/AabX" );
416 Id tempB(
"/model/kinetics/BbcX" );
421 Id tempC(
"/model/kinetics/c/CcdX" );
426 Id tempD(
"/model/kinetics/e/DdeX" );
431 for ( i = 4; i < 9; i++ ) {
439 string path(
"/model/kinetics/" );
447 assert(
doubleEq( r1, i* 100 + 101 ) &&
451 Id tempJ(
"/model/kinetics/k/Jjkl" );
456 Id tempK(
"/model/kinetics/k/Kklm" );
461 Id tempL(
"/model/kinetics/m/Llmn" );
static const double DEFAULT_RATE
static ObjId parent(const Eref &e)
std::string path(const std::string &separator="/") const
vector< CspaceReacInfo > reaclist_
void printMol(Id id, double conc, double concinit, double vol)
static void children(const Eref &e, vector< Id > &ret)
static bool set(const ObjId &dest, const string &field, A arg)
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
vector< CspaceMolInfo > mollist_
bool doubleEq(double x, double y)
void expandEnzyme(const char *name, int e, int s, int p, int p2=0)
static const double DEFAULT_KM
void build(const char *name)
Id readModelString(const string &model, const string &modelname, Id pa, const string &solverClass)
void makeMolecule(char name)
bool isA(const string &ancestor) const
void makePlots(double plotdt)
const Cinfo * cinfo() const
void expandReaction(const char *name, int nm1)
void printEnz(Id id, Id cplx, double k1, double k2, double k3)
static const bool USE_PIPE
void printReac(Id id, double kf, double kb)
Element * element() const
Id makeStandardElements(Id pa, const string &modelname)
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
static A get(const ObjId &dest, const string &field)
static const double DEFAULT_CONC
const string & getName() const
vector< unsigned int > molseq_
static const double SCALE
vector< double > molparms_