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

📄 gep2.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 3 页
字号:
 /* allocate memory to hold the names of the temp files	*/
 hTmpF = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) 2 );
 if( hTmpF == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  GlobalFree( hOutpEl );
  GlobalFree( hStrPool );
  GlobalFree( hScanPar );
  GlobalFree( hSto );
  GlobalFree( hTreeStr );
  GlobalFree( hTree );
  return -1;
 }

 metname	= ( char (huge *)[NAME_L] ) GlobalLock( hMetname );
 stepname	= ( char (huge *)[NAME_L] ) GlobalLock( hStepname );
 stoiu		= ( int huge * ) GlobalLock( hStoiu );
 loop		= ( unsigned char (huge *)[MAX_STEP][MAX_MET] ) GlobalLock( hLoop );
 ktype		= ( struct kint huge * ) GlobalLock( hKtype );
 rstr		= ( int (huge *)[MAX_STEP][MAX_MOL] ) GlobalLock( hRstr );
 params[0]	= (double huge *) GlobalLock( hParams );
 outpel		= ( struct ou huge * ) GlobalLock( hOutpEl );
 spar		= ( struct sp huge * ) GlobalLock( hScanPar );
 strpool	= GlobalLock( hStrPool );
 stoi		= (int huge *) GlobalLock( hSto );
 treestr	= GlobalLock( hTreeStr );
 tree		= ( struct treet huge * ) GlobalLock( hTree );
 TmpFiles	= (LPSTR) GlobalLock( hTmpF );

 *TmpFiles = '\0';

 /* make the other params[i] point to NULL											*/
 for( i=1; i<MAX_STEP; i++ ) params[i] = NULL;

 get_dfts();										/* read GEPASI default values	*/
 totmet = nmetab = nsteps = 0;						/* clear no. of metb. and steps	*/

 nrateq = MAX_TYP;

 ktype[NOT].nconst = 0;
 ktype[NOT].nmodf = 0;
 ktype[NOT].constnam = (LPSTR) "";
 ktype[NOT].descr = (LPSTR) "<not defined>";
 ktype[I01].nconst = 1;
 ktype[I01].nmodf = 0;
 ktype[I01].constnam = (LPSTR) "k";
 ktype[I01].descr = (LPSTR) "constant rate";
 ktype[I10].nconst = 1;
 ktype[I10].nmodf = 0;
 ktype[I10].constnam = (LPSTR) "k";
 ktype[I10].descr = (LPSTR) ktype[I01].descr;
 ktype[I11].nconst = 1;
 ktype[I11].nmodf = 0;
 ktype[I11].constnam = (LPSTR) "k";
 ktype[I11].descr = (LPSTR) "mass action";
 ktype[R11].nconst = 2;
 ktype[R11].nmodf = 0;
 ktype[R11].constnam = (LPSTR) "k1\0k2";
 ktype[R11].descr = (LPSTR) ktype[I11].descr;
 ktype[I21].nconst = 1;
 ktype[I21].nmodf = 0;
 ktype[I21].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I21].descr = (LPSTR) ktype[I11].descr;
 ktype[R21].nconst = 2;
 ktype[R21].nmodf = 0;
 ktype[R21].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R21].descr = (LPSTR) ktype[I11].descr;
 ktype[I12].nconst = 1;
 ktype[I12].nmodf = 0;
 ktype[I12].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I12].descr = (LPSTR) ktype[I11].descr;
 ktype[R12].nconst = 2;
 ktype[R12].nmodf = 0;
 ktype[R12].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R12].descr = (LPSTR) ktype[I11].descr;
 ktype[I31].nconst = 1;
 ktype[I31].nmodf = 0;
 ktype[I31].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I31].descr = (LPSTR) ktype[I11].descr;
 ktype[R31].nconst = 2;
 ktype[R31].nmodf = 0;
 ktype[R31].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R31].descr = (LPSTR) ktype[I11].descr;
 ktype[I13].nconst = 1;
 ktype[I13].nmodf = 0;
 ktype[I13].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I13].descr = (LPSTR) ktype[I11].descr;
 ktype[R13].nconst = 2;
 ktype[R13].nmodf = 0;
 ktype[R13].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R13].descr = (LPSTR) ktype[I11].descr;
 ktype[I22].nconst = 1;
 ktype[I22].nmodf = 0;
 ktype[I22].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I22].descr = (LPSTR) ktype[I11].descr;
 ktype[R22].nconst = 2;
 ktype[R22].nmodf = 0;
 ktype[R22].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R22].descr = (LPSTR) ktype[I11].descr;
 ktype[I32].nconst = 1;
 ktype[I32].nmodf = 0;
 ktype[I32].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I32].descr = (LPSTR) ktype[I11].descr;
 ktype[R32].nconst = 2;
 ktype[R32].nmodf = 0;
 ktype[R32].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R32].descr = (LPSTR) ktype[I11].descr;
 ktype[I23].nconst = 1;
 ktype[I23].nmodf = 0;
 ktype[I23].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I23].descr = (LPSTR) ktype[I11].descr;
 ktype[R23].nconst = 2;
 ktype[R23].nmodf = 0;
 ktype[R23].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R23].descr = (LPSTR) ktype[I11].descr;
 ktype[I33].nconst = 1;
 ktype[I33].nmodf = 0;
 ktype[I33].constnam = (LPSTR) ktype[I11].constnam;
 ktype[I33].descr = (LPSTR) ktype[I11].descr;
 ktype[R33].nconst = 2;
 ktype[R33].nmodf = 0;
 ktype[R33].constnam = (LPSTR) ktype[R11].constnam;
 ktype[R33].descr = (LPSTR) ktype[I11].descr;
 ktype[IMM].nconst = 2;
 ktype[IMM].nmodf = 0;
 ktype[IMM].constnam = (LPSTR) "Km\0V";
 ktype[IMM].descr = (LPSTR) "Michaelis-Menten";
 ktype[RMM].nconst = 4;
 ktype[RMM].nmodf = 0;
 ktype[RMM].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr";
 ktype[RMM].descr = (LPSTR) "Reversible Michaelis-Menten";
 ktype[PSI].nconst = 5;
 ktype[PSI].nmodf = 1;
 ktype[PSI].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ki";
 ktype[PSI].descr = (LPSTR) "specific inhibition";
 ktype[PCI].nconst = 5;
 ktype[PCI].nmodf = 1;
 ktype[PCI].constnam = ktype[PSI].constnam;
 ktype[PCI].descr = (LPSTR) "catalytic inhibition";
 ktype[MXI].nconst = 6;
 ktype[MXI].nmodf = 1;
 ktype[MXI].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ki\0Ki'";
 ktype[MXI].descr = (LPSTR) "mixed inhibition";
 ktype[PSA].nconst = 5;
 ktype[PSA].nmodf = 1;
 ktype[PSA].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ka";
 ktype[PSA].descr = (LPSTR) "specific activation";
 ktype[PCA].nconst = 5;
 ktype[PCA].nmodf = 1;
 ktype[PCA].constnam = ktype[PSA].constnam;
 ktype[PCA].descr = (LPSTR) "catalytic activation";
 ktype[MXA].nconst = 6;
 ktype[MXA].nmodf = 1;
 ktype[MXA].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ka\0Ka'";
 ktype[MXA].descr = (LPSTR) "mixed activation";
 ktype[GOM].nconst = 6;
 ktype[GOM].nmodf = 1;
 ktype[GOM].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ki\0Ki'";
 ktype[GOM].descr = (LPSTR) "Botts-Morales";
 ktype[HIL].nconst = 3;
 ktype[HIL].nmodf = 0;
 ktype[HIL].constnam = (LPSTR) "K\0V\0h";
 ktype[HIL].descr = (LPSTR) "Hill";
 ktype[UBS].nconst = 6;
 ktype[UBS].nmodf = 0;
 ktype[UBS].constnam = (LPSTR) "Ka\0Kp\0Kq\0Kpq\0Vf\0Vr";
 ktype[UBS].descr = (LPSTR) "Ordered Uni Bi (A=P+Q)";
 ktype[UBM].nconst = 4;
 ktype[UBM].nmodf = 0;
 ktype[UBM].constnam = (LPSTR) "Ka\0Kp\0Vf\0Vr";
 ktype[UBM].descr = (LPSTR) "Ordered Uni Bi (A=2*P)";
 ktype[RHL].nconst = 6;
 ktype[RHL].nmodf = 0;
 ktype[RHL].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0hs\0hp";
 ktype[RHL].descr = (LPSTR) "Reversible Hill";
 ktype[ALI].nconst = 6;
 ktype[ALI].nmodf = 1;
 ktype[ALI].constnam = (LPSTR) "Kms\0Kmp\0Vf\0Vr\0Ki\0h";
 ktype[ALI].descr = (LPSTR) "Allosteric inhibition";

 nudf = 0;
 return 0;
}

/*
	set up the pointers to params
*/

int SetParams( void )
{
 int i, j;

 /* calculate the size of parameters array				*/
 for( i=0, j=0; i<nsteps; i++ )
  j += ktype[kinetu[i]].nconst;

 /* unlock hParams to be able to ReAlloc it				*/
 GlobalUnlock( hParams );

 sizeparam = (DWORD) j * sizeof( double );
 /* reallocate memory for parameters from global heap	*/
 hParams = GlobalReAlloc( hParams, sizeparam, GMEM_ZEROINIT | GMEM_MOVEABLE );
 if( hParams == NULL ) return -1;

 /* point to the parameters of the first step 			*/
 params[0] = (double huge *) GlobalLock( hParams );
 /* set all constants of step 0 to the default value	*/
 for( j=0; j<(int)ktype[kinetu[0]].nconst; j++ )
  *(params[0]+j) = dft_const;

 /* set the other pointers								*/
 for( i=1; i<nsteps; i++ )
 {
  params[i] = params[i-1] + ktype[kinetu[i-1]].nconst;
  /* set all constants of step j to the default value	*/
  for( j=0; j<(int)ktype[kinetu[i]].nconst; j++ )
   *(params[i]+j) = dft_const;
 }

 return 0;
}


/*
  setup the output elements
*/

int SetOutpEl( void )
{
 int i, j, k, l;
 LPSTR ptr, poolptr;
 char buff[128], c;

 /* 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 elasticies										*/
 noutpel += nsteps * totmet;
 /* all concentration control coefficients				*/
 noutpel += totmet * nsteps;
 /* all flux control coefficients						*/
 noutpel += nsteps * nsteps;
 /* endtime, rel and abs tol, nfunc, njacob, nistep,
    smstep, flux resolution								*/
 noutpel += 8;
 nscanpar += 4;

 /* unlock memory blocks to be able to ReAlloc them		*/
 GlobalUnlock( hOutpEl );
 GlobalUnlock( hStrPool );
 GlobalUnlock( hScanPar );

 sizeoutp = (DWORD) noutpel * sizeof( struct ou );
 sizespar = (DWORD) nscanpar * sizeof( struct sp );
 sizestrp = (DWORD) noutpel * 44;

 /* reallocate memory for parameters from global heap	*/
 hOutpEl = GlobalReAlloc( hOutpEl, sizeoutp, GMEM_ZEROINIT | GMEM_MOVEABLE );
 if( hOutpEl == NULL )
 {
  return -1;
 }
 hScanPar = GlobalReAlloc( hScanPar, sizespar, GMEM_ZEROINIT | GMEM_MOVEABLE );
 if( hScanPar == NULL )
 {
  return -1;
 }
 hStrPool = GlobalReAlloc( hStrPool, sizestrp, GMEM_ZEROINIT | GMEM_MOVEABLE );
 if( hStrPool == NULL )
 {
  return -1;
 }

 /* lock the memory block and have outpel[0] point to it*/
 outpel  = (struct ou huge *) GlobalLock( hOutpEl );
 spar    = (struct sp huge *) GlobalLock( hScanPar );
 strpool = GlobalLock( hStrPool );

 /* reset the auxiliary pool pointer					*/
 poolptr = strpool;

 /* set all idx to 0 (to signal not selected)			*/
 for( i=0; i<noutpel; i++ )
  outpel[i].idx = 0;
 for( i=0; i<nscanpar; i++ )
 {
  spar[i].idx = 0;
  spar[i].low = 0;
  spar[i].high= 0;
  spar[i].dens = (unsigned long) 1;
  spar[i].log = 0;
  spar[i].factor = 1;
  spar[i].operation = 1;
  spar[i].lidx = -1;
  spar[i].linkedto = -1;
 }

 /* initialize the titles								*/

 /* initial concentrations 								*/
 for( i=0; i<totmet; i++ )
 {
  wsprintf( (LPSTR) buff, "[%s]i", (LPSTR) metname[i] );
  /* copy buff to the string pool						*/
  _fstrcpy( (char __far *) poolptr,
            (char __far *) buff );

  /* store the pointer in outpel[i] and spar[i]			*/
  outpel[i].title = spar[i].title = poolptr;

  /* increase poolptr to point to the first free byte	*/
  poolptr += _fstrlen( buff ) + 1;
 }
 l = i;

 /* concentrations at time t							*/
 for( j=0; j<totmet; j++, i++ )
 {
  wsprintf( (LPSTR) buff, "[%s]f", (LPSTR) metname[j] );
  /* copy buff to the string pool						*/
  _fstrcpy( (char __far *) poolptr,
            (char __far *) buff );

  /* store the pointer in outpel[i] and spar[i]			*/
  outpel[i].title = poolptr;

  /* increase poolptr to point to the first free byte	*/
  poolptr += _fstrlen( buff ) + 1;
 }

 for( j=0; j<nsteps; j++, i++ )
 {
  wsprintf( (LPSTR) buff, "J(%s)", (LPSTR) stepname[j] );
  /* copy buff to the string pool						*/
  _fstrcpy( (char __far *) poolptr,
            (char __far *) buff );

  /* store the pointer in outpel[i]						*/
  outpel[i].title = poolptr;

  /* increase poolptr to point to the first free byte	*/
  poolptr += _fstrlen( buff ) + 1;
 }

 for( j=0; j<nsteps; j++ )
  for( k=0, ptr = ktype[kinetu[j]].constnam;
       k < (int) ktype[kinetu[j]].nconst;
       k++, i++, l++
     )
  {
   wsprintf( (LPSTR) buff, "%s,%s", (LPSTR) ptr, (LPSTR) stepname[j] );
   /* copy buff to the string pool						*/
   _fstrcpy( (char __far *) poolptr,
             (char __far *) buff );

   /* store the pointer in outpel[i]					*/
   outpel[i].title = spar[l].title = poolptr;

   /* ptr points to the following constant name			*/
   do{} while( *(ptr++) );

   /* increase poolptr to point to the first free byte	*/
   poolptr += _fstrlen( buff ) + 1;
  }

⌨️ 快捷键说明

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