⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datab.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 2 页
字号:
 ktype[I13].constnam = ktype[I01].constnam;
 ktype[I13].descr = ktype[I11].descr;
 ktype[R13].nsub = 1;
 ktype[R13].npro = 3;
 ktype[R13].nconst = 2;
 ktype[R13].nmodf = 0;
 ktype[R13].constnam = ktype[R11].constnam;
 ktype[R13].descr = ktype[I11].descr;
 ktype[I22].nsub = 2;
 ktype[I22].npro = 2;
 ktype[I22].nconst = 1;
 ktype[I22].nmodf = 0;
 ktype[I22].constnam = ktype[I01].constnam;
 ktype[I22].descr = ktype[I11].descr;
 ktype[R22].nsub = 2;
 ktype[R22].npro = 2;
 ktype[R22].nconst = 2;
 ktype[R22].nmodf = 0;
 ktype[R22].constnam = ktype[R11].constnam;
 ktype[R22].descr = ktype[I11].descr;
 ktype[I32].nsub = 3;
 ktype[I32].npro = 2;
 ktype[I32].nconst = 1;
 ktype[I32].nmodf = 0;
 ktype[I32].constnam = ktype[I01].constnam;
 ktype[I32].descr = ktype[I11].descr;
 ktype[R32].nsub = 3;
 ktype[R32].npro = 2;
 ktype[R32].nconst = 2;
 ktype[R32].nmodf = 0;
 ktype[R32].constnam = ktype[R11].constnam;
 ktype[R32].descr = ktype[I11].descr;
 ktype[I23].nsub = 2;
 ktype[I23].npro = 3;
 ktype[I23].nconst = 1;
 ktype[I23].nmodf = 0;
 ktype[I23].constnam = ktype[I01].constnam;
 ktype[I23].descr = ktype[I11].descr;
 ktype[R23].nsub = 2;
 ktype[R23].npro = 3;
 ktype[R23].nconst = 2;
 ktype[R23].nmodf = 0;
 ktype[R23].constnam = ktype[R11].constnam;
 ktype[R23].descr = ktype[I11].descr;
 ktype[I33].nsub = 3;
 ktype[I33].npro = 3;
 ktype[I33].nconst = 1;
 ktype[I33].nmodf = 0;
 ktype[I33].constnam = ktype[I01].constnam;
 ktype[I33].descr = ktype[I11].descr;
 ktype[R33].nsub = 3;
 ktype[R33].npro = 3;
 ktype[R33].nconst = 2;
 ktype[R33].nmodf = 0;
 ktype[R33].constnam = ktype[R11].constnam;
 ktype[R33].descr = ktype[I11].descr;
 ktype[IMM].nsub = 1;
 ktype[IMM].npro = 1;
 ktype[IMM].nconst = 2;
 ktype[IMM].nmodf = 0;
 ktype[IMM].constnam = "Km\0V";
 ktype[IMM].descr = "Michaelis-Menten";
 ktype[RMM].nsub = 1;
 ktype[RMM].npro = 1;
 ktype[RMM].nconst = 4;
 ktype[RMM].nmodf = 0;
 ktype[RMM].constnam = "Kms\0Kmp\0Vf\0Vr";
 ktype[RMM].descr = "Reversible Michaelis-Menten";
 ktype[PSI].nsub = 1;
 ktype[PSI].npro = 1;
 ktype[PSI].nconst = 5;
 ktype[PSI].nmodf = 1;
 ktype[PSI].constnam = "Kms\0Kmp\0Vf\0Vr\0Ki";
 ktype[PSI].descr = "Specific inhibition";
 ktype[PCI].nsub = 1;
 ktype[PCI].npro = 1;
 ktype[PCI].nconst = 5;
 ktype[PCI].nmodf = 1;
 ktype[PCI].constnam = ktype[PSI].constnam;
 ktype[PCI].descr = "Catalytic inhibition";
 ktype[MXI].nsub = 1;
 ktype[MXI].npro = 1;
 ktype[MXI].nconst = 6;
 ktype[MXI].nmodf = 1;
 ktype[MXI].constnam = "Kms\0Kmp\0Vf\0Vr\0Ki\0Ki'";
 ktype[MXI].descr = "Mixed inhibition";
 ktype[PSA].nsub = 1;
 ktype[PSA].npro = 1;
 ktype[PSA].nconst = 5;
 ktype[PSA].nmodf = 1;
 ktype[PSA].constnam = "Kms\0Kmp\0Vf\0Vr\0Ka";
 ktype[PSA].descr = "Specific activation";
 ktype[PCA].nsub = 1;
 ktype[PCA].npro = 1;
 ktype[PCA].nconst = 5;
 ktype[PCA].nmodf = 1;
 ktype[PCA].constnam = ktype[PSA].constnam;
 ktype[PCA].descr = "Catalytic activation";
 ktype[MXA].nsub = 1;
 ktype[MXA].npro = 1;
 ktype[MXA].nconst = 6;
 ktype[MXA].nmodf = 1;
 ktype[MXA].constnam = "Kms\0Kmp\0Vf\0Vr\0Ka\0Ka'";
 ktype[MXA].descr = "Mixed activation";
 ktype[GOM].nsub = 1;
 ktype[GOM].npro = 1;
 ktype[GOM].nconst = 6;
 ktype[GOM].nmodf = 1;
 ktype[GOM].constnam = "Kms\0Kmp\0Vf\0Vr\0Ki\0Ki'";
 ktype[GOM].descr = "Botts-Morales";
 ktype[HIL].nsub = 1;
 ktype[HIL].npro = 1;
 ktype[HIL].nconst = 3;
 ktype[HIL].nmodf = 0;
 ktype[HIL].constnam = "Km\0V\0nh";
 ktype[HIL].descr = "Hill";
 ktype[UBS].nsub = 1;
 ktype[UBS].npro = 2;
 ktype[UBS].nconst = 6;
 ktype[UBS].nmodf = 0;
 ktype[UBS].constnam = "Ka\0Kp\0Kq\0Kpq\0Vf\0Vr";
 ktype[UBS].descr = "Ordered Uni Bi (A=P+Q)";
 ktype[UBM].nsub = 1;
 ktype[UBM].npro = 1;
 ktype[UBM].nconst = 6;
 ktype[UBM].nmodf = 0;
 ktype[UBM].constnam = "Ka\0Kp\0Vf\0Vr";
 ktype[UBM].descr = "Ordered Uni Bi (A=2*P)";
 ktype[ALI].nsub = 1;
 ktype[ALI].npro = 1;
 ktype[ALI].nconst = 6;
 ktype[ALI].nmodf = 1;
 ktype[ALI].constnam = "Kms\0Kmp\0Vf\0Vr\0Ki\0n";
 ktype[ALI].descr = "Allosteric inhibition";
}

/*
	set up the pointers to params
*/

int SetParams( void )
{
 int i, j;

 /* calculate the number of kinetic parameters                  */
 for( i=0, j=0; i<nsteps; i++ )
  j += ktype[kinetype[i]].nconst;
 /* and the space they take in memory                                   */
 sizeparam = j * sizeof( double );
 /* reallocate memory for parameters                                    */
 /* setting already the first (0) pointer                               */
 params[0] = (double *) mem_realloc( params[0], sizeparam );
 if( params[0] == NULL )
 {
  return -1;
 }
 /* set the other pointers                                                              */
 for( i=1; i<nsteps; i++ )
  params[i] = params[i-1] + ktype[kinetype[i-1]].nconst;
 /* return successfuly                                                                  */
 return 0;
}

/*
	set up the pointers to eff (indexes of effectors)
*/

int SetEff( void )
{
 int i, j;

 /* calculate the total number of effectors                     */
 for( i=0, sizeeff=0; i<nsteps; i++ )
 {             
  j = ktype[kinetype[i]].nsub +
      ktype[kinetype[i]].npro +
      ktype[kinetype[i]].nmodf;
  sizeeff += j;
 }

 /* mem_reallocate memory for effector indexes                          */
 /* setting already the first (0) pointer                               */
 eff[0] = (int *) mem_realloc( eff[0], sizeeff * sizeof( int ) );
 if( eff[0] == NULL )
 {
  return -1;
 }
 /* set the other pointers                                                              */
 for( i=1; i<nsteps; i++ )
  eff[i] = eff[i-1] + ( ktype[kinetype[i-1]].nsub +
						ktype[kinetype[i-1]].npro +
						ktype[kinetype[i-1]].nmodf );
 /* return successfuly                                                                  */
 return 0;
}


/* setup the output and scanning elements                               */

int SetOutpEl( void )
{
 int i, j, k, l;

 /* calculate the number of output elements                             */
 /* all metabolite concentrations and step fluxes               */
 noutpel = 2*totmet + nsteps;
 nscanpar = totmet;
 /* all kinetic constants...                                                     */
 for( i=0; i<nsteps; i++ )
 {
  noutpel += ktype[kinetu[i]].nconst;
  nscanpar += ktype[kinetu[i]].nconst;
 }
 /* all elasticities                                                                    */
 noutpel += nsteps * totmet;
 /* all concentration control coefficients                              */
 noutpel += totmet * nsteps;
 /* all flux control coefficients                                               */
 noutpel += nsteps * nsteps;
 /* endtime, rel & abs tol, nfunc, njac, nistep, smstep */
 noutpel += 8;
 nscanpar += 4;

 /* calculate the size of outpel and the string pool    */
 sizeoutp = noutpel * sizeof( PDBL );
 sizespar = nscanpar * sizeof( struct sp );

 /* reallocate memory for outpel                                                */
 outpel = (PDBL *) mem_realloc( outpel, sizeoutp );
 if( outpel == NULL )
  return -1;

 /* mem_reallocate memory for sparam                                            */
 sparam = (struct sp *) mem_realloc( sparam, sizespar );
 if( sparam == NULL )
  return -1;

 /* mem_reallocate memory for scindex                                           */
 scindex = (int *) mem_realloc( scindex, nscanpar * sizeof( int ) );
 if( scindex == NULL )
 {
  return -1;
 }

 /* mem_reallocate memory for lindex                                            */
 lindex = (int *) mem_realloc( lindex, nscanpar * sizeof( int ) );
 if( lindex == NULL )
 {
  return -1;
 }

 /* load the pointers                                                                   */

 /* initial concentrations                                                      */
 for( i=l=0; i<totmet; i++, l++ )
 {
  outpel[i] = &(x0[i]);
  sparam[l].var = &(x0[i]);
 }
 /* final concentrations                                                                */
 for( j=0; j<totmet; i++, j++ )
  outpel[i] = &(x[j]);

 /* fluxes                                                                              */
 for( j=0; j<nsteps; j++, i++ )
  outpel[i] = &(flux[j]);

 /* kinetic constants                                                                   */
 for( j=0; j<nsteps; j++ )
  for( k=0; k < (int) ktype[kinetype[j]].nconst; k++, i++, l++ )
   outpel[i] = sparam[l].var = params[j]+k;

 /* elasticities                                                                        */
  for( j=0; j<nsteps; j++ )
   for(k=0;k<totmet;k++,i++)
    outpel[i] = &Dxv[j][k];

 /* concentration control coefficients                                  */
 for( j=0; j<totmet; j++ )
   for(k=0;k<nsteps;k++,i++)
    outpel[i] = &Gamma[j][k];

 /* flux control coefficients                                                   */
 for( j=0; j<nsteps; j++ )
  for(k=0;k<nsteps;k++,i++)
   outpel[i] = &C[j][k];

 /* endtime, tolerance, nfunc, njacob, nistep, smstep   */
 outpel[i++] = sparam[l++].var = &endtime;
 outpel[i++] = &intst;
 outpel[i++] = &nfeval;
 outpel[i++] = &njeval;
 outpel[i++] = &hu;
 outpel[i++] = sparam[l++].var = &options.reltol;
 outpel[i++] = sparam[l++].var = &options.abstol;
 outpel[i]   = sparam[l].var = &options.hrcz;

 return 0;
}

/*
   create a new function tree object
*/

int new_tree( int idx )
{
 nudf++;
 tree = (struct treet *) mem_realloc( (void *) tree, nudf * sizeof( struct treet ) );
 if( tree == NULL )
  return IDS_ERR_NOEXEC;
 memcpy( (void *) &tree[idx], (void *) &tr, sizeof( struct treet ) );
 return 0;
}

/*
  add a user-defined rate equation to the database
*/

int new_rateq( int idx )
{
 unsigned int strsize;
 int i, pm, ef;
 long l;
 char *tmpptr;

 /* measure the required length for the constant names                          */
 for( i=0, strsize=0; i<tree[idx].nid; i++ )
  if( tree[idx].id[i][9] == (char) 0 )
   strsize += strlen(tree[idx].id[i]) + 1;
 sizetr += strsize * sizeof( char );
 l = (long) (treeptr - treestr);
 /* reallocate the buffer to hold new strings                                           */
 treestr = (char *) mem_realloc( (void *) treestr, sizetr );
 if( treestr == NULL )
  return IDS_ERR_NOEXEC;
 treeptr = treestr + l;
 tmpptr = treeptr;
 /* copy the strings to the buffer                                                                      */
 for( i=0; i<tree[idx].nid; i++ )
  if( tree[idx].id[i][9] == (char) 0 )
  {
   strcpy( treeptr, tree[idx].id[i] );
   treeptr += strlen( tree[idx].id[i] ) + 1;
  }
 /* reuse the space in tree.id[idx][0] to store indexes                         */
 for( i=0, ef=pm=0; i<tree[idx].nid; i++ )
  switch( (int) tree[idx].id[i][9] )
  {
   case 0: tree[idx].id[i][0] = (char) pm; pm++; break; /* constant  */
   case 1: tree[idx].id[i][0] = (char) ef; ef++;        /* substrate */
  }
 /* the first nsub are reserved for substrates even when not explicit*/
 for( i=0, ef=tree[idx].nsub; i<tree[idx].nid; i++ )
  if( (int) tree[idx].id[i][9] == 2 )                   /* product   */
  {
   tree[idx].id[i][0] = (char) ef; ef++;
  }
 /* nsub+npro are reserved for substs.& prods. even when not explicit*/
 for( i=0, ef=tree[idx].nsub+tree[idx].npro; i<tree[idx].nid; i++ )
  if( (int) tree[idx].id[i][9] == 3 )                   /* modifier  */
  {
   tree[idx].id[i][0] = (char) ef; ef++;
  }

 /* expand the memory block                                                                             */
 nrateq++;
 ktype = (struct kint *) mem_realloc( ktype, nrateq * sizeof( struct kint ) );
 if( ktype != NULL )
 {
  ktype[MAX_TYP+idx].nmodf    = (unsigned char) tree[idx].nmodf;
  ktype[MAX_TYP+idx].nconst   = (unsigned char) tree[idx].nconst;
  ktype[MAX_TYP+idx].nsub     = (unsigned char) tree[idx].nsub;
  ktype[MAX_TYP+idx].npro     = (unsigned char) tree[idx].npro;
  ktype[MAX_TYP+idx].descr    = tree[idx].descr;
  ktype[MAX_TYP+idx].constnam = tmpptr;
  return 0;
 }
 else
  return IDS_ERR_NOEXEC;
}

/*
  add a new function read from a .TOP file
  and renumber references to this type in the .TOP
*/

int addtr( int e )
{
 int i, j, k, nRc;

 j = nudf;
 k = kinetu[e];
 if( (nRc = new_tree( j )) != 0 ) return nRc;
 if( (nRc = new_rateq( j )) != 0 ) return nRc;
 for( i=e; i<nsteps; i++ )
  if( (kinetu[i]==k) && (kfl[i]) )
  {
   kinetu[i] = MAX_TYP+j;
   kfl[i] = 0;
  }
 return 0;
}


void FreeMem( void )
{
 mem_free( treestr );
 mem_free( tree );
 mem_free( lindex );
 mem_free( scindex );
 mem_free( scanpar );
 mem_free( sparam );
 mem_free( outtit );
 mem_free( rstr );
 mem_free( loop );
 mem_free( poutelem );
 mem_free( outpel );
 mem_free( ktype );
 mem_free( params[0] );
 mem_free( eff[0] );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -