RNAlib-2.0.2
|
00001 #ifndef __VIENNA_RNA_PACKAGE_UTILS_H__ 00002 #define __VIENNA_RNA_PACKAGE_UTILS_H__ 00003 00012 #define VRNA_INPUT_ERROR 1U 00013 00016 #define VRNA_INPUT_QUIT 2U 00017 00020 #define VRNA_INPUT_MISC 4U 00021 00027 #define VRNA_INPUT_FASTA_HEADER 8U 00028 00032 #define VRNA_INPUT_SEQUENCE 16U 00033 00037 #define VRNA_INPUT_CONSTRAINT 32U 00038 00042 #define VRNA_INPUT_NO_TRUNCATION 256U 00043 00046 #define VRNA_INPUT_NO_REST 512U 00047 00050 #define VRNA_INPUT_NO_SPAN 1024U 00051 00054 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U 00055 00058 #define VRNA_INPUT_BLANK_LINE 4096U 00059 00062 #define VRNA_INPUT_NOSKIP_COMMENTS 128U 00063 00066 #define VRNA_INPUT_COMMENT 8192U 00067 00068 00069 00070 00074 #define VRNA_CONSTRAINT_PIPE 1U 00075 00078 #define VRNA_CONSTRAINT_DOT 2U 00079 00082 #define VRNA_CONSTRAINT_X 4U 00083 00086 #define VRNA_CONSTRAINT_ANG_BRACK 8U 00087 00090 #define VRNA_CONSTRAINT_RND_BRACK 16U 00091 00094 #define VRNA_CONSTRAINT_MULTILINE 32U 00095 00098 #define VRNA_CONSTRAINT_NO_HEADER 64U 00099 00102 #define VRNA_CONSTRAINT_ALL 128U 00103 00107 #define MIN2(A, B) ((A) < (B) ? (A) : (B)) 00108 00111 #define MAX2(A, B) ((A) > (B) ? (A) : (B)) 00112 00115 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C))) 00116 00119 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C))) 00120 00121 00125 #define XSTR(s) STR(s) 00126 00129 #define STR(s) #s 00130 00131 #ifndef FILENAME_MAX_LENGTH 00132 00138 #define FILENAME_MAX_LENGTH 80 00139 00145 #define FILENAME_ID_LENGTH 42 00146 #endif 00147 00148 00149 #ifdef HAVE_CONFIG_H 00150 #include <config.h> 00151 #ifndef HAVE_STRDUP 00152 char *strdup(const char *s); 00153 #endif 00154 #endif 00155 #ifdef WITH_DMALLOC 00156 /* use dmalloc library to check for memory management bugs */ 00157 #include "dmalloc.h" 00158 #define space(S) calloc(1,(S)) 00159 #else 00160 00167 /*@only@*/ /*@notnull@*/ 00168 void *space(unsigned size) /*@ensures MaxSet(result) == (size-1);@*/; 00169 00177 /*@only@*/ /*@notnull@*/ 00178 void *xrealloc(/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p, 00179 unsigned size) /*@modifies *p @*/ /*@ensures MaxSet(result) == (size-1) @*/; 00180 #endif 00181 00188 /*@exits@*/ 00189 void nrerror(const char message[]); 00190 00198 void warn_user(const char message[]); 00199 00203 void init_rand(void); 00204 00213 extern unsigned short xsubi[3]; 00214 00221 double urn(void); 00222 00230 int int_urn(int from, int to); 00231 00232 void filecopy(FILE *from, FILE *to); /* inefficient `cp' */ 00233 00242 /*@observer@*/ 00243 char *time_stamp(void); 00244 00252 /*@only@*/ /*@notnull@*/ 00253 char *random_string(int l, const char symbols[]); 00254 00263 int hamming(const char *s1, const char *s2); 00264 00274 int hamming_bound(const char *s1, const char *s2, int n); 00275 00286 /*@only@*/ /*@null@*/ 00287 char *get_line(FILE *fp); 00288 00289 int skip_comment_lines(char **line); 00290 00311 unsigned int get_input_line(char **string, 00312 unsigned int options); 00313 00314 unsigned int get_multi_input_line(char **string, 00315 unsigned int options); 00316 00369 unsigned int read_record( char **header, 00370 char **sequence, 00371 char ***rest, 00372 unsigned int options); 00373 00385 char *pack_structure(const char *struc); 00386 00396 char *unpack_structure(const char *packed); 00397 00407 short *make_pair_table(const char *structure); 00408 00415 short *copy_pair_table(const short *pt); 00416 00422 short *alimake_pair_table(const char *structure); 00423 00429 short *make_pair_table_snoop(const char *structure); 00430 00442 int bp_distance(const char *str1, 00443 const char *str2); 00444 00450 void print_tty_input_seq(void); 00451 00460 void print_tty_input_seq_str(const char *s); 00461 00467 void print_tty_constraint_full(void); 00468 00485 void print_tty_constraint(unsigned int option); 00486 00494 void str_DNA2RNA(char *sequence); 00495 00501 void str_uppercase(char *sequence); 00502 00516 int *get_iindx(unsigned int length); 00517 00532 int *get_indx(unsigned int length); 00533 00534 void getConstraint( char **cstruc, 00535 const char **lines, 00536 unsigned int option); 00537 00549 void constrain_ptypes(const char *constraint, 00550 unsigned int length, 00551 char *ptype, 00552 int *BP, 00553 int min_loop_size, 00554 unsigned int idx_type); 00555 00556 unsigned int *make_referenceBP_array(short *reference_pt, 00557 unsigned int turn); 00558 00559 unsigned int *compute_BPdifferences( short *pt1, 00560 short *pt2, 00561 unsigned int turn); 00562 00563 #endif