/*------------------------------------------------------------- Copyright (C) 2000 Rolf Backofen, 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. -------------------------------------------------------------*/ /* Include section */ #include "general.h" #include #include #include #include #include /* function declarations */ /* calc square distance-matrix from a vector of polar requirements */ void calc_matrix(float PC[NUM_ACIDS], float matrix[NUM_ACIDS][NUM_ACIDS]); void print_pc_code(float PC[NUM_ACIDS],gcode code); int printblockstruct( gcode block_code, int *fixed ); /* reads a vector */ int read_non_fixed_vector(char *filename, float PC[NUM_ACIDS], int fixed[NUM_ACIDS], float V[5]); /* sets the value of matrix nij (= digulio in Peters version) calculates and returns MS (including sumnij). */ Fivetuple setnij_and_ms(gcode code, float matrix[NUM_ACIDS][NUM_ACIDS], int nij[NUM_ACIDS][NUM_ACIDS]); /********************************************************************** General Routines for measuring Fault Tolerance ***********************************************************************/ /* sets the value of matrix nij calculates and returns MS (including sumnij). after return: nij gives how often we go from block i to block j by one mutation of the triplet code. MS.sumnij is the sum over all nij values MS.whole is mean square distance of polar requirements of blocknumbers, where the triplet code changes by one base MS.one/MS.two/MS.three is mean square distance ..., where the triplet changes in first/second/third base. */ Fivetuple setnij_and_ms(gcode code, float matrix[NUM_ACIDS][NUM_ACIDS], int nij[NUM_ACIDS][NUM_ACIDS]) { int i, j, k, m; /* loop variables for genetic code*/ int sumnij = 0; /* error tolerance of the given code */ int num1 = 0, num2 = 0, num3 = 0; Fivetuple MS; MS.whole = MS.one = MS.two = MS.three = 0.0; /* initialize matrix for DiGiulio coefficients */ for (i=0;i or %s v1 v2 v3 v4 v5 \n", argv[0], argv[0]); exit(1); } else if (argc == 7) for (i=0;i<5;i++) V[i] = strtod(argv[i+2],NULL); /* read polarrequirements vector */ read_non_fixed_vector(argv[1],PC,fixed,V); /* compute square distance-matrix */ calc_matrix(PC, matrix); /* print polar-requirement vector including fixed values */ printf("\n\n PC Vector PC genetic Code\n"); for (i=0;i. The array PC is initialized with the values from the file for nonfixed blocks and values from array V for fixed blocks. returns 0 in case of success, otherwise 1 */ int read_non_fixed_vector(char *filename, float PC[NUM_ACIDS], int fixed[NUM_ACIDS], float V[5]) { FILE *fp = fopen(filename, "r"); int i; /* counters for loops */ int f=0; /* counts the number of times, a fixed value was used. */ if (fp == NULL) { fprintf(stderr, "Could not polar requirements file!\n"); return 1; } for (i = 0; i < NUM_ACIDS; i++) { if (fixed[i]) { PC[i] = V[f]; f++; } else { if (fscanf(fp, "%f ", &PC[i]) == EOF) { fprintf(stderr, "File contains no polar req. vector!\n"); fclose(fp); return 1; } } } return 0; } /* calculates square distance-matrix from PC-vector */ void calc_matrix(float PC[NUM_ACIDS], float matrix[NUM_ACIDS][NUM_ACIDS]) { int i,j; for (i=0;i for every triplet code (translated by to blocknumber)*/ void print_pc_code(float PC[NUM_ACIDS],gcode code) { int i,j,k; for (i=0;i<4;i++) { for (j=0;j<4;j++) { for (k=0;k<4;k++) if (code[i][j][k] == STOP) printf(" STOP"); else printf("%8.4f",PC[code[i][j][k]]); printf("\n"); } printf("\n\n"); } } /* prints a blockstructure */ int printblockstruct( gcode block_code, int *fixed ) { int i,j,k; for (i=0;i<4;i++) { for (j=0;j<4;j++) { for (k=0;k<4;k++) { if (block_code[i][j][k] == STOP) printf("%s\t","STOP"); else { if (fixed[block_code[i][j][k]] == 1) printf("%s\t","FIX"); else printf("%s\t","VAR"); } } printf("\n"); } printf("\n\n"); } return 0; }