int main(int argc, char *argv[]){ struct RNAheat_args_info args_info; char *string, *input_string, *ns_bases, *c, *ParamFile, *rec_sequence, *rec_id, **rec_rest, *orig_sequence; int i, length, l, sym; float T_min, T_max, h; int mpoints, istty, noconv = 0; unsigned int input_type; unsigned int rec_type, read_opt; string = ParamFile = ns_bases = NULL; T_min = 0.; T_max = 100.; h = 1; mpoints = 2; dangles = 2; /* dangles can be 0 (no dangles) or 2, default is 2 */ rec_type = read_opt = 0; rec_id = rec_sequence = orig_sequence = NULL; rec_rest = NULL; /* ############################################# # check the command line parameters ############################################# */ if(RNAheat_cmdline_parser(argc, argv, &args_info) != 0) exit(1); /* do not take special tetra loop energies into account */ if(args_info.noTetra_given) tetra_loop=0; /* set dangle model */ if(args_info.dangles_given){ if((args_info.dangles_arg != 0) && (args_info.dangles_arg != 2)) vrna_message_warning("required dangle model not implemented, falling back to default dangles=2"); else dangles = args_info.dangles_arg; } /* do not allow weak pairs */ if(args_info.noLP_given) noLonelyPairs = 1; /* do not allow wobble pairs (GU) */ if(args_info.noGU_given) noGU = 1; /* do not allow weak closing pairs (AU,GU) */ if(args_info.noClosingGU_given) no_closingGU = 1; /* do not convert DNA nucleotide "T" to appropriate RNA "U" */ if(args_info.noconv_given) noconv = 1; /* set energy model */ if(args_info.energyModel_given) energy_set = args_info.energyModel_arg; /* take another energy parameter set */ if(args_info.paramFile_given) ParamFile = strdup(args_info.paramFile_arg); /* Allow other pairs in addition to the usual AU,GC,and GU pairs */ if(args_info.nsp_given) ns_bases = strdup(args_info.nsp_arg); /* Tmin */ if(args_info.Tmin_given) T_min = args_info.Tmin_arg; /* Tmax */ if(args_info.Tmax_given) T_max = args_info.Tmax_arg; /* step size */ if(args_info.stepsize_given) h = args_info.stepsize_arg; /* ipoints */ if(args_info.ipoints_given){ mpoints = args_info.ipoints_arg; if (mpoints < 1) mpoints = 1; if (mpoints > 100) mpoints = 100; } /* free allocated memory of command line data structure */ RNAheat_cmdline_parser_free (&args_info); /* ############################################# # begin initializing ############################################# */ if (ParamFile!=NULL) read_parameter_file(ParamFile); if (ns_bases != NULL) { nonstandards = vrna_alloc(33); c=ns_bases; i=sym=0; if (*c=='-') { sym=1; c++; } while (*c!='\0') { if (*c!=',') { nonstandards[i++]=*c++; nonstandards[i++]=*c; if ((sym)&&(*c!=*(c-1))) { nonstandards[i++]=*c; nonstandards[i++]=*(c-1); } } c++; } } istty = isatty(fileno(stdout))&&isatty(fileno(stdin)); read_opt |= VRNA_INPUT_NO_REST; if(istty){ vrna_message_input_seq_simple(); read_opt |= VRNA_INPUT_NOSKIP_BLANK_LINES; } /* ############################################# # main loop: continue until end of file ############################################# */ while( !((rec_type = vrna_file_fasta_read_record(&rec_id, &rec_sequence, &rec_rest, NULL, read_opt)) & (VRNA_INPUT_ERROR | VRNA_INPUT_QUIT))){ /* ######################################################## # init everything according to the data we've read ######################################################## */ if(rec_id && !istty) printf("%s\n", rec_id); length = (int)strlen(rec_sequence); /* convert DNA alphabet to RNA if not explicitely switched off */ if(!noconv) vrna_seq_toRNA(rec_sequence); /* store case-unmodified sequence */ orig_sequence = strdup(rec_sequence); /* convert sequence to uppercase letters only */ vrna_seq_toupper(rec_sequence); if(istty) printf("length = %d\n", length); /* ######################################################## # done with 'stdin' handling ######################################################## */ heat_capacity(rec_sequence, T_min, T_max, h, mpoints); (void) fflush(stdout); /* clean up */ if(rec_id) free(rec_id); free(rec_sequence); free(orig_sequence); rec_id = rec_sequence = orig_sequence = NULL; rec_rest = NULL; /* print user help for the next round if we get input from tty */ if(istty) vrna_message_input_seq_simple(); } return EXIT_SUCCESS; }
int main(int argc, char *argv[]){ struct RNAheat_args_info args_info; char *string, *input_string, *ns_bases, *c, *ParamFile; int i, length, l, sym; float T_min, T_max, h; int mpoints, istty, noconv = 0; unsigned int input_type; string = ParamFile = ns_bases = NULL; T_min = 0.; T_max = 100.; h = 1; mpoints = 2; dangles = 2; /* dangles can be 0 (no dangles) or 2, default is 2 */ /* ############################################# # check the command line parameters ############################################# */ if(RNAheat_cmdline_parser(argc, argv, &args_info) != 0) exit(1); /* do not take special tetra loop energies into account */ if(args_info.noTetra_given) tetra_loop=0; /* set dangle model */ if(args_info.dangles_given){ dangles = args_info.dangles_arg; if(dangles % 2){ warn_user("using default dangles = 2"); dangles = 2; } } /* do not allow weak pairs */ if(args_info.noLP_given) noLonelyPairs = 1; /* do not allow wobble pairs (GU) */ if(args_info.noGU_given) noGU = 1; /* do not allow weak closing pairs (AU,GU) */ if(args_info.noClosingGU_given) no_closingGU = 1; /* do not convert DNA nucleotide "T" to appropriate RNA "U" */ if(args_info.noconv_given) noconv = 1; /* set energy model */ if(args_info.energyModel_given) energy_set = args_info.energyModel_arg; /* take another energy parameter set */ if(args_info.paramFile_given) ParamFile = strdup(args_info.paramFile_arg); /* Allow other pairs in addition to the usual AU,GC,and GU pairs */ if(args_info.nsp_given) ns_bases = strdup(args_info.nsp_arg); /* Tmin */ if(args_info.Tmin_given) T_min = args_info.Tmin_arg; /* Tmax */ if(args_info.Tmax_given) T_max = args_info.Tmax_arg; /* step size */ if(args_info.stepsize_given) h = args_info.stepsize_arg; /* ipoints */ if(args_info.ipoints_given){ mpoints = args_info.ipoints_arg; if (mpoints < 1) mpoints = 1; if (mpoints > 100) mpoints = 100; } /* free allocated memory of command line data structure */ RNAheat_cmdline_parser_free (&args_info); /* ############################################# # begin initializing ############################################# */ if (ParamFile!=NULL) read_parameter_file(ParamFile); if (ns_bases != NULL) { nonstandards = space(33); c=ns_bases; i=sym=0; if (*c=='-') { sym=1; c++; } while (*c!='\0') { if (*c!=',') { nonstandards[i++]=*c++; nonstandards[i++]=*c; if ((sym)&&(*c!=*(c-1))) { nonstandards[i++]=*c; nonstandards[i++]=*(c-1); } } c++; } } istty = isatty(fileno(stdout))&&isatty(fileno(stdin)); /* ############################################# # main loop: continue until end of file ############################################# */ do { /* ######################################################## # handle user input from 'stdin' ######################################################## */ if(istty) print_tty_input_seq(); /* skip fasta headers and comments */ while((input_type = get_input_line(&input_string, 0)) & VRNA_INPUT_FASTA_HEADER){ printf(">%s\n", input_string); /* skip fasta headers and comments */ free(input_string); } /* break on any error, EOF or quit request */ if(input_type & (VRNA_INPUT_QUIT | VRNA_INPUT_ERROR)){ break;} /* else assume a proper sequence of letters of a certain alphabet (RNA, DNA, etc.) */ else{ string = strdup(input_string); length = (int) strlen(string); free(input_string); } if(noconv) str_RNA2RNA(string); else str_DNA2RNA(string); if (istty) printf("length = %d\n", length); heat_capacity(string, T_min, T_max, h, mpoints); free(string); (void) fflush(stdout); } while (1); return 0; }