/* Code by anonomous and Ethan Wolf 1995. */ /************************************************************************/ /* get_defaults() is called in main() of sc2seq.c to get the default */ /* values for parameters of the program, such as input/output files and */ /* options. */ /************************************************************************/ #include #include #include #include "scio.h" #include "switches.h" #include "interface.h" /** Returns pointer to first occurance of chrs[0]. If that not present, * returns pointer to first occurance of chrs[1]... If none of * characters in chrs[] are present then it returns NULL. * This is used to remove whitspace, tabs, returns. **/ static char *strchrs(char *str, char *chrs) { char *ret=NULL; while(*chrs) { if(ret=strchr(str,*chrs)) return ret; chrs++; } return ret; } /************************************************************************/ /* Reads in .paircoil file of default values that are normally input to */ /* sc2seq in the command line. */ /* Any required value not read in here is expected on the command line. */ void get_defaults(char *command_line_config, char *input_location, int *mode, double *bound, FILE **fgin, FILE **fpin, FILE **ftotal_like, FILE **fout, FILE **flog, FILE **fout_coils, int *by_coil_or_seq, char likelihoods[MAX_TABLE_NUMBER][MAXLINE], char *pir_name, char *lib, char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM], int *functnum, int combine_dist[MAX_TABLE_NUMBER], char *print, int *main_method, int *main_preprocessor_method, int *main_table, int *offset_to_use, int *avg_max, int *Coil_Score, int *ps_res_per_line, char class_sc_filenames[2][MAX_CLASS_NUMBER][MAXLINE], char gaussian_parameters[2][MAXLINE], int num_dist[MAX_TABLE_NUMBER], double init_class_prob[MAX_CLASS_NUMBER], int *table_to_remove_from, char *command_line, int window_length[MAX_TABLE_NUMBER], double scale0s[MAX_TABLE_NUMBER], double scale0p[MAX_TABLE_NUMBER]) { char buf[500], *tmp, name[500]; FILE *config; FILE *printfile; int i, number_likelihoods=0; char *input_name; int lib_numb=0; /******** A hack so I don't have to eliminate all the stuff using these ****/ /******** pointers, since no longer pass them into function. ****/ int num_tab=0, *number_tables, number_classes=0, number_max_classes=0; number_tables= &num_tab; /****************************************************************************/ strcpy(gaussian_parameters[0], "~/MULTICOIL/CONVERSION_FILES/gauss_param28+"); if (command_line) { /* Don't use options in config file. */ if (!strcmp(command_line,"dimer")) { *table_to_remove_from = 0; printf("Input data is all removed from table 1\n"); *mode |= POS_MODE; printf("pos\n"); } else if (!strcmp(command_line,"trimer")) { *table_to_remove_from = 1; printf("Input data is all removed from table 2\n"); *mode |= POS_MODE; printf("pos\n"); } else if (!strcmp(command_line, "dimer-1")) { *mode |= TST_MODE0; printf("Input is data from table 1\n"); *mode |= POS_MODE; printf("pos\n"); } else if (!strcmp(command_line, "trimer-1")) { *mode |= TST_MODE1; printf("Input is data from table 2\n"); *mode |= POS_MODE; printf("pos\n"); } else if (!strcmp(command_line, "negatives")) { printf("Not doing pos mode"); } else if (!strcmp(command_line, "config_file")) { printf("Doing pos options as in config file\n"); command_line =NULL; } else { /* Bad command line input. **/ usage("paircoil"); exit(-1); } } /************************** For Automating output file name. ****/ /** Strip off directories to get just the program name. **/ i=strlen(input_location); while ((i>=0) && (input_location[i] != '/') ) i--; input_name= &input_location[i+1]; /***************************/ /* What directory to look for paircoil defauts in. Set environment */ /* variable MULTICOIL_CONFIG to be a path to this file. */ if (command_line_config) { /** Read config location at command line. **/ strcpy(buf, command_line_config); fprintf(stderr,"config = %c",buf); } else if (tmp=getenv("MULTICOIL_CONFIG")) { strcpy(buf,tmp); } else { strcpy(buf,getenv("HOME")); strcat(buf,"/MULTICOIL/multicoil_config"); } if (config=fopen(buf,"r")) { printf("Config file %s\n", buf); while (fgets(buf,500,config)) { if (!command_line) { /** Read from file since it wasn't **/ /** a command line param. **/ if(!strncmp(buf,"pos",3)) { /* If "pos" is in the .paircoil */ *mode |= POS_MODE; /* default file, then the test */ printf("pos\n"); /* file is assumed to be a .pos */ } /* file, where each seq has its */ else if(!strncmp(buf,"remove all input from table",27)) { sscanf(buf,"remove all input from table %d",table_to_remove_from); (*table_to_remove_from)--; printf("Input is data is all removed from table %d\n", (*table_to_remove_from) +1); } else if(!strncmp(buf,"input pos1",10)) { *mode |= TST_MODE0; printf("Input is data from table 1\n"); } else if(!strncmp(buf,"input pos2",10)) { *mode |= TST_MODE1; printf("Input is data from table 2\n"); } } /**** Now do the rest of the possible non-command line options. *****/ if(!strncmp(buf,"genbnk",6)) { /* Get location of genbnk file */ sscanf(buf,"genbnk = %s",name); /* and open it. */ *fgin = sopen(name,"r"); /*** printf("genbnk = %s\n",name); ***/ } else if(!strncmp(buf,"table",5)) { /* Get location of postable file */ sscanf(buf,"table %d = %s",&i, name); fpin[i-1] = sopen(name,"r"); /*** printf("table %d = %s\n",i,name); ***/ (*number_tables)++; } else if(!strncmp(buf,"pir",3)) { /* Get location of pir file */ sscanf(buf,"pir = %s",pir_name); /**** printf("pir = %s\n",pir_name); ***/ } else if(!strncmp(buf,"printfile",9)) { /* File to output printouts to*/ sscanf(buf,"printfile = %s",print); printf("printfile = %s\n",print); printfile=sopen(print,"w"); /* We are going to append to this, */ sclose(printfile); /* So first make it empty. */ } else if(!strncmp(buf,"likelihoods",11)) { sscanf(buf,"likelihoods %d = %s",&i, likelihoods[number_likelihoods]); /**** printf("likelihoods %d = %s\n",number_likelihoods, likelihoods[number_likelihoods]); ***/ /* likelihood lines. */ number_likelihoods++; likelihoods[number_likelihoods][0]= ','; } else if(!strncmp(buf,"class scores combo",18)) { sscanf(buf,"class scores combo %d with init prob %lf = %s",&i, &init_class_prob[number_classes], class_sc_filenames[0][number_classes]); printf("combo class scores %d = %s with init prob %lf\n", i,class_sc_filenames[0][number_classes], init_class_prob[number_classes]); /* likelihood lines. */ number_classes++; } else if(!strncmp(buf,"class scores max",16)) { sscanf(buf,"class scores max %d with init prob %lf = %s",&i, &init_class_prob[number_max_classes], class_sc_filenames[1][number_max_classes]); printf("max class scores %d = %s with init prob %lf\n", i,class_sc_filenames[1][number_max_classes], init_class_prob[number_max_classes]); /* likelihood lines. */ number_max_classes++; } else if(!strncmp(buf,"gauss_param =",13)) sscanf(buf,"gauss_param = %s",gaussian_parameters[0]); else if(!strncmp(buf,"gauss_param combo",17)) { sscanf(buf,"gauss_param combo = %s",gaussian_parameters[0]); /**** printf("gauss_param combo = %s\n",gaussian_parameters[0]); ****/ } else if(!strncmp(buf,"gauss_param max",15)) { sscanf(buf,"gauss_param max = %s",gaussian_parameters[1]); /*** printf("gauss_param max = %s\n",gaussian_parameters[1]); ***/ } else if(!strncmp(buf,"no GUI",6)) { *mode |= NO_GUI; printf("NO GUI\n"); } else if(!strncmp(buf,"pair_lib",8)) { /* Read in a variable number */ char *end; /* of distances to be used in */ int val; /* pair scores. The number */ /* of variables is stored in */ printf("pair_lib = "); /* in the global variable */ tmp = strchr(buf, '='); /* functnum. The distances */ tmp++; /* are stored in */ /* strip leading whitespace */ /* lib[0],...,lib[functnum-1]. */ while(!isdigit(*tmp)&&*tmp) tmp++; while(end = strchrs(tmp, " \t\n\r")) { *end = 0; end++; /* strip leading whitespace */ while(*tmp&&!isdigit(*tmp)) tmp++; if(*tmp) { val = atoi(tmp); lib[(*functnum)++] = val-1; /** scscore.c needs takes residues **/ /** at dist lib +1 apart. **/ printf("%d ", val); } tmp = end; } printf("\n"); } else if(!strncmp(buf,"multi_lib",9)) { /* Read in a variable number */ if (! (*mode & LIB_AT_COMMAND_LINE)) { /* This flags that **/ /** got it at command line. **/ int first_table, last_table; int the_table; int combine_distances =1; if (!strncmp(buf,"multi_lib dim",13)) { combine_distances = 0; if (!strncmp(buf,"multi_lib dim =",15)) { first_table=0; last_table=NUMBER_TABLES; } /* All tables get same lib. **/ else { sscanf(buf,"multi_lib dim %d", &last_table); first_table = last_table-1; } } else if (!strncmp(buf,"multi_lib =",11)) { combine_distances = 0; first_table=0; last_table= NUMBER_TABLES; } /* All tables get same lib. **/ else { sscanf(buf,"multi_lib %d", &last_table); first_table = last_table-1; } for (the_table=first_table; the_table