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

📄 gep2.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 3 页
字号:
#include "copyleft.h"

/*
    GEPASI - a simulator of metabolic pathways and other dynamical systems
    Copyright (C) 1989, 1992, 1993  Pedro Mendes
*/

/*************************************/
/*                                   */
/*         GWSIM - Simulation        */
/*        MS-WINDOWS front end       */
/*                                   */
/*       Initialization and some     */
/*           data structures         */
/*                                   */
/*           QuickC/WIN 1.0          */
/*                                   */
/*   (include here compilers that    */
/*   compiled GWSIM successfully)    */
/*                                   */
/*************************************/


#include <windows.h>
#include <string.h>
#include <float.h>
#include "globals.h"
#include "gaussw.h"
#include "strtbl.h"
#include "simgvar.h"

void get_dfts( void );

struct kint {
		  		unsigned char nconst;
		  		unsigned char nmodf;
		  		LPSTR descr;
				LPSTR constnam;
	   	    };

struct nodet{
             char item;
             unsigned char val;
             unsigned char left;
             unsigned char right;
            };

struct treet{
             struct nodet node[256];
             char id[64][10];
             float constant[32];
             int nnode,
                 nnum,
                 nid,
                 nsub,
                 npro,
                 nmodf,
                 nconst,
                 revers;
             char descr[64];
            };

struct opt {
            int dyn;
            long pfo;
	        double	endtime;
            double	reltol;
            double	abstol;
            double	hrcz;
            int adams;
            int bdf;
            int ss;
            int debug;
            int txt;
            int structan;
            int staban;
            int stdela;
            int nonela;
            int stdcc;
            int noncc;
            int dat;
            int datsep;
            int datwidth;
            int dattit;
            int datmca;
            int datss;
            int quotes;
            int append;
			char timeu[32];
			char concu[32];
            int scan;
            int scanlog;
            unsigned long scandens;
           };

struct plt{
           int type;		/* 0 for 2d, 1 for 3d */
           int file;		/* 0 for dynamics, 1 for steady state */
           int x;			/* column for x */
           int y[10];		/* columns for y */
           int z;			/* column for z */
           int ny;			/* number of y variables */
           int logx;		/* 1 if log x axis */
           int logy;		/* 1 if log y axis */
           int logz;		/* 1 if log z axis */
           int lines;		/* 1 if points connected by lines */
           int colour;		/* 1 if colour to be used */
           int hidden;		/* 1 if hidden line removal */
           int contour;		/* 1 if contour plots on base */
          };

struct ou {
           LPSTR title;
           unsigned int idx;
          };

struct sp{
          int idx;
          LPSTR title;
	      double low;
	      double high;
	      unsigned long dens;
	      int log;
	      int lidx;
	      int linkedto;
	      double factor;
	      int operation;
	     };

GLOBALHANDLE hMetname;								/* handle to memory block w/ metname	*/
GLOBALHANDLE hStepname;								/* handle to memory block w/ stepname	*/
GLOBALHANDLE hStoiu;								/* handle to memory block w/ stoiu		*/
GLOBALHANDLE hSto;									/* handle to memory block w/ stoi		*/
GLOBALHANDLE hLoop;									/* handle to memory block w/ loop		*/
GLOBALHANDLE hParams;								/* handle to memory block w/ params		*/
GLOBALHANDLE hKtype;								/* handle to memory block w/ ktype		*/
GLOBALHANDLE hRstr;									/* handle to memory block w/ rstr		*/
GLOBALHANDLE hOutpEl;								/* handle to memory block w/ outpel		*/
GLOBALHANDLE hStrPool;								/* handle to memory block w/ strings	*/
GLOBALHANDLE hScanPar;								/* handle to memory block w/ strings	*/
GLOBALHANDLE hTree;									/* handle to memory block w/ trees		*/
GLOBALHANDLE hTreeStr;								/* handle to memory block w/ tree str	*/
GLOBALHANDLE hTmpF;									/* handle to memory block w/ temp files	*/

char	(huge *metname)[NAME_L];					/* pointer to work with metname array	*/
char	(huge *stepname)[NAME_L];					/* metabolite names						*/
int		huge *stoiu;								/* pointer to work with stoiu array		*/
int		huge *stoi;									/* pointer to work with stoi array		*/
unsigned char (huge *loop)[MAX_STEP][MAX_MET];		/* def. of modification loops			*/
int		(huge *rstr)[MAX_STEP][MAX_MOL];			/* reaction structure					*/
char	topname[256];								/* title for the topology				*/
char	stepstr[MAX_STEP][256];						/* array to hold description of steps	*/
double 	huge *params[MAX_STEP];						/* ptr to parameters for each rate eq.	*/
DWORD	sizeparam;									/* size of parameters memory block		*/
DWORD	sizeoutp;									/* size of outpel memory block			*/
DWORD	sizestrp;									/* size of StrPool memory block			*/
DWORD	sizestra;									/* size of allocated strings in StrPool	*/
DWORD	sizespar;
DWORD	sizetr;										/* size of allocated strings in TreeStr	*/
double	xu[MAX_MET];								/* metabolite concentrations			*/
double	moiety[MAX_MET];							/* concentration of conserved moieties	*/
int		intmet[MAX_MET];							/* 1 if internal metabolite				*/
unsigned char	revers[MAX_STEP];					/* 1 if reaction is reversible			*/
int		kinetu[MAX_STEP];							/* type of kinetics (user numb.)		*/
int		kfl[MAX_STEP];								/* flags for input of user-def.kinetics */
LPSTR	strpool;									/* points to the string pool mem block	*/
LPSTR	treestr;									/* points to the tree string pool		*/
LPSTR	treeptr;									/* points to the tree string pool		*/
struct	opt options;								/* structure with simulation options	*/
struct	plt plot;									/* structure with plot options			*/
struct	kint huge *ktype;							/* ptr array of kinetic types & proprt	*/
struct	ou huge *outpel;							/* ptr array of output elements			*/
struct	sp huge *spar;								/* ptr array of scanning elements		*/
float	ver_no;										/* .top and .sim version number			*/
double	dft_endtime;								/* time value for last iteration		*/
double	dft_hrcz;									/* highest rate considered zero			*/
int		totmet;										/* number of total metabolites			*/
int		nmetab;										/* number of internal metabolites		*/
int		indmet;										/* number of independent metabolites	*/
int		nextmet;									/* number of external metabolites		*/
int		nsteps;										/* number of steps                		*/
int		nloops;										/* number of modifier loops             */
int		noutpel;                                    /* number of output elements			*/
int		nudf;										/* number of user-defined functions		*/
int		nrateq;										/* number of user-defined functions		*/
int		totsel;                                     /* number of selected output elements	*/
int		totscan;									/* number of dimensions to scan			*/
int		nscanpar;                                   /* number of scanning elements			*/
int		nlinks;										/* number of links between parameters	*/
unsigned char dft_debugval;							/* debug mode							*/
double	dft_conc;									/* default metabolite concentration		*/
double	dft_const;									/* default value for kinetic constants	*/
char	*dft_timeu;									/* default time units					*/
char	*dft_concu;									/* default conctration units			*/
unsigned long dft_pfo;								/* number of points for output			*/
struct	treet huge *tree;							/* function tree for rate equations		*/
struct	treet tr;									/* tree for the input					*/
LPSTR	TmpFiles;									/* string holding names of temp files	*/

int		InitGepasiVar( void );
void	TidyGepasiVar( void );
int 	SetParams( void );
int 	SetOutpEl( void );
void 	step_string( void );
void	conc_dft( void );
void 	numer_dft( void );
void 	def_def( void );
void 	set_dfts( void );
void 	get_dfts( void );

#pragma alloc_text( CODE1, InitGepasiVar, TidyGepasiVar, SetParams, SetOutpEl, step_string, conc_dft, numer_dft, def_def, set_dfts, get_dfts )

/* Initialization of GEPASI's variables */

int InitGepasiVar( void )
{
 int i, j;

 hMetname = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * NAME_L * sizeof( char ) );
 if( hMetname == NULL ) return -1;

 hStepname = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * NAME_L * sizeof( char ) );
 if( hStepname == NULL )
 {
  GlobalFree( hMetname );
  return -1;
 }

 hStoiu = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * MAX_STEP * sizeof( int ) );
 if( hStoiu == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  return -1;
 }

 hLoop = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * MAX_MET * sizeof( unsigned char ) );
 if( hLoop == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  return -1;
 }

 hKtype = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_TYP * sizeof( struct kint ) );
 if( hKtype == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  return -1;
 }

 hRstr = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * MAX_MOL * sizeof( int ) );
 if( hRstr == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  return -1;
 }

 sizeparam = (DWORD) sizeof( double );
 hParams = GlobalAlloc( GMEM_ZEROINIT, sizeparam );
 if( hParams == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  return -1;
 }

 sizeoutp = (DWORD) 4 * sizeof( struct ou );
 hOutpEl = GlobalAlloc( GMEM_ZEROINIT, sizeoutp );
 if( hOutpEl == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  return -1;
 }

 sizestrp = (DWORD) 4 * 17; /* strings will be limited to 17, but this can change */
 hStrPool = GlobalAlloc( GMEM_ZEROINIT, sizestrp );
 if( hStrPool == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  GlobalFree( hOutpEl );
  return -1;
 }

 sizespar = (DWORD) 4 * sizeof( struct sp );
 hScanPar = GlobalAlloc( GMEM_ZEROINIT, sizespar );
 if( hScanPar == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  GlobalFree( hOutpEl );
  GlobalFree( hStrPool );
  return -1;
 }

 hSto = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * MAX_STEP * sizeof( int ) );
 if( hSto == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  GlobalFree( hOutpEl );
  GlobalFree( hStrPool );
  GlobalFree( hScanPar );
  return -1;
 }

 sizetr = (DWORD) 4 * sizeof( char );
 hTreeStr = GlobalAlloc( GMEM_ZEROINIT, sizetr );
 if( hTreeStr == NULL )
 {
  GlobalFree( hMetname );
  GlobalFree( hStepname );
  GlobalFree( hStoiu );
  GlobalFree( hLoop );
  GlobalFree( hKtype );
  GlobalFree( hRstr );
  GlobalFree( hParams );
  GlobalFree( hOutpEl );
  GlobalFree( hStrPool );
  GlobalFree( hScanPar );
  GlobalFree( hSto );
  return -1;
 }

 nudf = 0;
 hTree = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) sizeof( struct treet ) );
 if( hTree == 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 );
  return -1;
 }

⌨️ 快捷键说明

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