/*------------------------------------------------------------- Copyright (C) 2000 Stefan Schoenauer, Peter Clote. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. THE AUTHOR AND PUBLISHER MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -------------------------------------------------------------*/ /***************************************************************************** * general.h: general data structures and function definitions for the * * Project "Error optimized genetic code" * * * * author: S.Schoenauer * * creation: 3/17/1997 * *****************************************************************************/ #ifndef bool #define bool int #endif /* global definitions */ #define NUM_ACIDS 20 /* Number of amino acids */ #define NUM_ACIDS_SS 21 /* Number of amino acids plus start and stop codon */ #define STOP 20 /* STOP codon comes after 0..19 in list */ /* #define RAND_MAX 32767 maximum value returned by random() */ #define ALPHA 2 /* ALPHA,BETA,GAMMA using in monte_carlo() */ #define BETA 5 #define GAMMA 0 #define POS_INF MAXFLOAT /* positive and negative "infinity" */ #define NEG_INF -MAXFLOAT /* for finding min,max stats */ /***************************************************************** Choice of constants: Schoenauer's values : 2 min for run 5 500 #define kb 1.3807E-23 Boltzmans constant #define T_hi 1 starting high temperature; set for WAC matrix #define T_lo 1E-10 terminating low temperature; set for WAC matrix Clote's values : 6 min for run 5 500 #define kb 1.0 #define T_hi 10000.0 #define T_lo 1E-40 #define kb 1.0 #define T_hi 100 #define T_lo 1E-45 The following values, I computed using EXCEL, assuming Delta E is at most 1 initially (so T_hi yields 99% prob of change, while T_lo yields less than 0.01 % prob of changing. NOTE: get error (random value of above constants) if don't use decimal or exp notation. *****************************************************************/ #define kb 1.0 /* Boltzmans constant */ #define T_hi 10.0 /* starting high temperature; set for WAC matrix */ #define T_lo 1E-4 /* terminating low temperature; set for WAC matrix */ /* enumeration type of the nucleotide bases */ enum base {A, T, C, G}; /* A genetic code is represented by an array of the 64 codons. For each codon the array contains the number of the encoded amino acid. */ typedef unsigned int *gcode; typedef unsigned int gcode_array[64]; typedef unsigned int gcode_triple[4][4][4]; typedef unsigned int *lincode; /* This is the standard natural genetic code. */ extern gcode std_code; /* This is a table to convert the numeric code into the one-letter code. */ extern unsigned char num2char[NUM_ACIDS_SS]; /* This is a table to convert the numeric code into the three-letter code. */ extern char *num2triple[NUM_ACIDS_SS]; /* smatrix contains the similarity matrix for amino acid substitutions */ extern float smatrix[NUM_ACIDS][NUM_ACIDS]; /* dmatrix contains the Mean Square Difference Matrix wrt polar requirement.*/ extern float dmatrix[NUM_ACIDS][NUM_ACIDS]; struct float4tuple { float whole; float one; float two; float three; }; typedef struct float4tuple Fourtuple; /* prototypes for functins in general.c */ /* read_matrix() gets a filename and puts the scoring valus from the file into smatrix. It does not check, whether the file really contains a scoring matrix or not. It expects that the scoring matrix is provided as an upper triangle matrix consisting of float values. */ int read_matrix(char *filename, float matrix[NUM_ACIDS][NUM_ACIDS]); void print_matrix(float matrix[NUM_ACIDS][NUM_ACIDS]); int rand_int(int n); /* random integer uniformly out of 0..(n-1) */ double rand_flt(); /* random flt uniformly out of [0..1[ */ void swap(unsigned int *i, unsigned int *j); /* allows addressing of code entries by triple ijk */ #define get_code(code, i, j, k) code[i*16+j*4+k]