# include "pdb.h" char **e_argv ; int e_argc = -1; int next_file_argument =1; char *d_getopt( char *what, int with_arg) { int ii ; for (ii = 1; ii < e_argc ; ii++) { char *arg = e_argv[ii] ; if(*arg == '-') { if (arg[1] == '-') { next_file_argument = ii + 1; return NULL ; } if(!strncmp(arg+1, what,8) ) { if (with_arg) { if (ii +2 > next_file_argument) next_file_argument = ii+2; return e_argv[ii +1] ; } else { if (ii +1 > next_file_argument) next_file_argument = ii+1; return arg; } } } } return NULL ; } void print_options_message() { printf("Standard options are : \n\ -a atoms_types : atom_types is a file name contain definitions of atom types. \n\ -r residues : residues is a file name contain residue definitions.\n\ -R : use the radii from the original Richards code ( as opposed to CHC values).\n\ -d debug : set the dbugging switch to debug\n\ -s : set selection by atoms, directly or from a file. \n\ -resi : set selection by residue. \n\ -resf : set selection by residue from a file. \n\ -sscheck arg : check ss bonds : 0)not check, 1)if no SSBOND records, 2)always\n\ -dicheck arg : set the distance check used by volume \n\ -h : print this message \n " ) ; } extern int deal_with_disorder ; extern int handle_missing_atom_definition ; extern char * selection_argument ; extern char * residue_selection_argument ; extern char * residue_selection_file ; extern double distance_check ; void initialize_selection () { residue_selection_argument = command_line_arg("residues") ; residue_selection_file = command_line_arg("resfile") ; selection_argument = command_line_arg("s") ; } extern int give_warning ; extern int check_sulphur_bridges ; void do_initialization (int argc, char **argv) { char *types_file = NULL ; char *res_file = NULL; int c ; int chc = 1 ; e_argv = argv ; e_argc = argc ; if (argc >= 1) { if(d_getopt("h",0) != NULL) { print_options_message() ; call_exit(0) ; } types_file = d_getopt("a",1) ; res_file = d_getopt("r",1) ; if(command_line_option("R")) chc = 0 ; if(command_line_option("w")) give_warning = 1 ; { char * a =d_getopt("d",1) ; if (a != NULL) debugging = atoi(a) ; } } SET_INT_FROM_OPTION(check_sulphur_bridges, "sscheck") ; SET_INT_FROM_OPTION(handle_missing_atom_definition, "missing") ; SET_DOUBLE_FROM_OPTION(distance_check, "dicheck") ; initialize_selection () ; initial_residues(types_file,res_file,chc) ; } file_records *read_next_file(format) { int index = next_file_argument ; if (index >= e_argc) return NULL; next_file_argument++ ; while(1) { file_records *ff = open_and_read_pdb(e_argv[index],format) ; if (ff == NULL) switch(action_flag) { case ACTION_NMR : if (read_nmr_files == 0) continue ; break ; } return ff ; } } file_records * read_next_file_checked(format) { int cc = next_file_argument ; file_records * file = read_next_file (format) ; if (file == NULL) { if (cc == next_file_argument) return NULL ; else serious_error (ARG_TYPE_STRING, "Failed to open input", e_argv[cc]) ; return NULL; } else return file ; } file_records * read_next_file_and_check(format) { int cc = next_file_argument ; file_records * file = read_next_file (format) ; if (file == NULL) serious_error (ARG_TYPE_STRING, "Failed to open input", (cc == next_file_argument) ? "No argument" :e_argv[cc]) ; return file ; } file_records *read_all_files (int format) { file_records *file1 = read_next_file (format) ; file_records * file2 ; if (file1 == NULL) return NULL ; while ((file2 = read_next_file (format)) != NULL) file1 = merge_files_and_purge(file1 ,file2) ; return file1 ; } char * command_line_arg( char *cc) { return d_getopt( cc, 1) ; } int command_line_option( char *cc) { return d_getopt( cc, 0) == NULL ? 0 : 1 ; } double double_from_option(char * string, double the_default) { char * a = command_line_arg(string); if (a == NULL) return the_default ; else return atof(a) ; }