RNAlib-2.0.7
|
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 00028 #define VRNA_INPUT_FASTA_HEADER 8U 00029 00034 #define VRNA_INPUT_SEQUENCE 16U 00035 00040 #define VRNA_INPUT_CONSTRAINT 32U 00041 00046 #define VRNA_INPUT_NO_TRUNCATION 256U 00047 00051 #define VRNA_INPUT_NO_REST 512U 00052 00056 #define VRNA_INPUT_NO_SPAN 1024U 00057 00061 #define VRNA_INPUT_NOSKIP_BLANK_LINES 2048U 00062 00066 #define VRNA_INPUT_BLANK_LINE 4096U 00067 00071 #define VRNA_INPUT_NOSKIP_COMMENTS 128U 00072 00076 #define VRNA_INPUT_COMMENT 8192U 00077 00078 00079 00080 00084 #define VRNA_CONSTRAINT_PIPE 1U 00085 00088 #define VRNA_CONSTRAINT_DOT 2U 00089 00092 #define VRNA_CONSTRAINT_X 4U 00093 00096 #define VRNA_CONSTRAINT_ANG_BRACK 8U 00097 00100 #define VRNA_CONSTRAINT_RND_BRACK 16U 00101 00104 #define VRNA_CONSTRAINT_MULTILINE 32U 00105 00108 #define VRNA_CONSTRAINT_NO_HEADER 64U 00109 00112 #define VRNA_CONSTRAINT_ALL 128U 00113 00114 00115 00124 #define VRNA_OPTION_MULTILINE 32U 00125 00126 00130 #define MIN2(A, B) ((A) < (B) ? (A) : (B)) 00131 00134 #define MAX2(A, B) ((A) > (B) ? (A) : (B)) 00135 00138 #define MIN3(A, B, C) (MIN2( (MIN2((A),(B))) ,(C))) 00139 00142 #define MAX3(A, B, C) (MAX2( (MAX2((A),(B))) ,(C))) 00143 00144 00148 #define XSTR(s) STR(s) 00149 00152 #define STR(s) #s 00153 00154 #ifndef FILENAME_MAX_LENGTH 00155 00161 #define FILENAME_MAX_LENGTH 80 00162 00168 #define FILENAME_ID_LENGTH 42 00169 #endif 00170 00171 00172 #ifdef HAVE_CONFIG_H 00173 #include <config.h> 00174 #ifndef HAVE_STRDUP 00175 char *strdup(const char *s); 00176 #endif 00177 #endif 00178 #ifdef WITH_DMALLOC 00179 /* use dmalloc library to check for memory management bugs */ 00180 #include "dmalloc.h" 00181 #define space(S) calloc(1,(S)) 00182 #else 00183 00190 /*@only@*/ /*@notnull@*/ 00191 void *space(unsigned size) /*@ensures MaxSet(result) == (size-1);@*/; 00192 00200 /*@only@*/ /*@notnull@*/ 00201 void *xrealloc(/*@null@*/ /*@only@*/ /*@out@*/ /*@returned@*/ void *p, 00202 unsigned size) /*@modifies *p @*/ /*@ensures MaxSet(result) == (size-1) @*/; 00203 #endif 00204 00211 /*@exits@*/ 00212 void nrerror(const char message[]); 00213 00221 void warn_user(const char message[]); 00222 00226 void init_rand(void); 00227 00236 extern unsigned short xsubi[3]; 00237 00244 double urn(void); 00245 00253 int int_urn(int from, int to); 00254 00255 void filecopy(FILE *from, FILE *to); /* inefficient `cp' */ 00256 00265 /*@observer@*/ 00266 char *time_stamp(void); 00267 00275 /*@only@*/ /*@notnull@*/ 00276 char *random_string(int l, const char symbols[]); 00277 00286 int hamming(const char *s1, const char *s2); 00287 00297 int hamming_bound(const char *s1, const char *s2, int n); 00298 00309 /*@only@*/ /*@null@*/ 00310 char *get_line(FILE *fp); 00311 00312 int skip_comment_lines(char **line); 00313 00334 unsigned int get_input_line(char **string, 00335 unsigned int options); 00336 00337 unsigned int get_multi_input_line(char **string, 00338 unsigned int options); 00339 00392 unsigned int read_record( char **header, 00393 char **sequence, 00394 char ***rest, 00395 unsigned int options); 00396 00397 00398 /* \brief Extract a dot-bracket structure string from (multiline)character array 00399 * 00400 * This function extracts a dot-bracket structure string from the 'rest' array as 00401 * returned by read_record() and returns it. All occurences of comments within the 00402 * 'lines' array will be skipped as long as they do not break the structure string. 00403 * If no structure could be read, this function returns NULL. 00404 * 00405 * \see read_record() 00406 * 00407 * \param lines The (multiline) character array to be parsed 00408 * \param length The assumed length of the dot-bracket string (passing a value < 1 results in no length limit) 00409 * \param option Some options which may be passed to alter the behavior of the function, use 0 for no options 00410 * \return The dot-bracket string read from lines or NULL 00411 */ 00412 char *extract_record_rest_structure(const char **lines, 00413 unsigned int length, 00414 unsigned int option); 00415 00427 char *pack_structure(const char *struc); 00428 00438 char *unpack_structure(const char *packed); 00439 00449 short *make_pair_table(const char *structure); 00450 00457 short *copy_pair_table(const short *pt); 00458 00464 short *alimake_pair_table(const char *structure); 00465 00471 short *make_pair_table_snoop(const char *structure); 00472 00484 int bp_distance(const char *str1, 00485 const char *str2); 00486 00492 void print_tty_input_seq(void); 00493 00502 void print_tty_input_seq_str(const char *s); 00503 00509 void print_tty_constraint_full(void); 00510 00527 void print_tty_constraint(unsigned int option); 00528 00536 void str_DNA2RNA(char *sequence); 00537 00543 void str_uppercase(char *sequence); 00544 00558 int *get_iindx(unsigned int length); 00559 00574 int *get_indx(unsigned int length); 00575 00576 void getConstraint( char **cstruc, 00577 const char **lines, 00578 unsigned int option); 00579 00591 void constrain_ptypes(const char *constraint, 00592 unsigned int length, 00593 char *ptype, 00594 int *BP, 00595 int min_loop_size, 00596 unsigned int idx_type); 00597 00598 unsigned int *make_referenceBP_array(short *reference_pt, 00599 unsigned int turn); 00600 00601 unsigned int *compute_BPdifferences( short *pt1, 00602 short *pt2, 00603 unsigned int turn); 00604 00605 #endif