Next version of JABA
[jabaws.git] / binaries / src / tcoffee / t_coffee_source / util_lib_header.h
1 #include <time.h>
2 #include <signal.h>
3 #include <errno.h>
4 #include <sys/times.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <unistd.h>
8 typedef struct
9     {
10     char *name;
11     char *path;
12     char *suffix;
13     char *full;
14     }
15 Fname;
16
17 struct Tmpname
18     {
19     char *name;
20     struct Tmpname *next;
21     };
22 /*********************************************************************/
23 /*                                                                   */
24 /*                                  DICHOTOMY                        */
25 /*                                                                   */
26 /*                                                                   */
27 /*********************************************************************/
28 double dichotomy (double value, double target_value, double middle, double *bottom,double *top);
29 /*********************************************************************/
30 /*                                                                   */
31 /*                                   QSORT                        */
32 /*                                                                   */
33 /*                                                                   */
34 /*********************************************************************/
35
36 void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
37 /*int    memcmp ( const void *a, const void * b, size_t size);
38 void * memcpy (       void *a,       void * b, size_t size);
39 */
40 /*********************************************************************/
41 /*                                                                   */
42 /*                                   HEAPSORT                        */
43 /*                                                                   */
44 /*                                                                   */
45 /*********************************************************************/
46 FILE *hsort_file     ( FILE *fp ,int n,int len, size_t size,int first_comp_field, int n_comp_fields,int (*compare)(const void *, const void*,int,int,size_t),void * (*copy)(void *,void*,size_t));
47 void ** hsort_array ( void **ra,int n,int len, size_t size, int first_comp_field, int n_comp_fields,int (*compare)(const void *, const void*,int,int,size_t),void * (*copy)(void *,void*,size_t));
48 /**********************************************************************/
49 /*                                                                    */
50 /*                         HSORT WRAPPERS                             */
51 /*                                                                    */
52 /*                                                                    */
53 /**********************************************************************/
54 void **hsort_list_array ( void **L, int len, size_t size, int entry_len,int first_comp_field, int n_comp_fields);  
55 FILE  *hsort_list_file  ( FILE *fp, int len, size_t size, int entry_len,int first_comp_field, int n_comp_fields);  
56 int hsort_cmp ( const void *a, const void *b, int first, int clen, size_t size);
57 void *hsort_cpy(void*to, void *from, size_t size);
58
59 void test_hsort_list_array();
60
61 /*********************************************************************/
62 /*                                                                   */
63 /*                         CEDRIC BSEARCH                            */
64 /*                                                                   */
65 /*                                                                   */
66 /*********************************************************************/
67 void * bsearch_file ( const void *key,int *p,int comp_first,int comp_len, FILE *fp ,int len, int entry_len,size_t el_size, int (*compare)(const void *, const void*,int, int, size_t));
68 void * bsearch_array( const void *key,int *p,int comp_first,int comp_len,void**list,int len, int entry_len,size_t el_size, int (*compare)(const void *, const void*,int, int, size_t));
69
70 /*********************************************************************/
71 /*                                                                   */
72 /*                     MY  B_SEARCH_FILE FUNCTIONS                   */
73 /*                                                                   */
74 /*                                                                   */
75 /*********************************************************************/          
76 void **search_in_list_file  ( void *key,int *p, int comp_len,FILE *fp, int len, size_t size, int entry_len);
77 void **search_in_list_array ( void *key,int *p, int comp_len,void **L , int len, size_t size, int entry_len);
78
79 /*********************************************************************/
80 /*                                                                   */
81 /*                         SORT/COMPARE/SEARCH FUNCTIONS             */
82 /*                                                                   */
83 /*                                                                   */
84 /*********************************************************************/
85
86 int **search_in_list_int ( int *key, int k_len, int **list, int ne);
87 void sort_float ( float **V,int N_F, int F, int left, int right);
88 int cmp_float ( const float **a, const float **b);
89 void sort_int_1D ( int *L, int n);
90 char** sort_string_array (char **V, int n);
91      
92 void sort_int ( int **V,int N_F, int F, int left, int right);
93 void sort_list_int ( int **V,int N_F, int F, int left, int right);
94 void sort_list_int2 ( int **V,int *list,int N_F, int left, int right);
95 void sort_int_inv ( int **V,int N_F, int F, int left, int right);
96 void sort_list_int_inv ( int **V,int N_F, int F, int left, int right);
97 int cmp_int ( const int**a, const int**b);
98 int cmp_list_int (const int**a, const int**b);
99 int cmp_list_int2 (const int**a, const int**b);
100
101 int name_is_in_list ( char *name, char **name_list, int n_name, int len);
102 char * check_list_for_dup ( char **list, int ne);
103 FILE *get_number_list_in_file ( FILE *fp, int *list, int *n, int *max_len);
104
105
106 /*********************************************************************/
107 /*                                                                   */
108 /*                         QUANTILE                                  */
109 /*                                                                   */
110 /*                                                                   */
111 /*********************************************************************/
112 int quantile ( int argc, char *argv[]);
113
114 int quantile_rank (int **list,int field, int n, float p);
115 /*********************************************************************/
116 /*                                                                   */
117 /*                         DUPLICATION                               */
118 /*                                                                   */
119 /*                                                                   */
120 /*********************************************************************/
121 short  *  set_short ( short *, int n,...);
122 char   *  set_char  ( char  *, int n,...);
123 int    *  set_int   ( int   *, int n,...);
124 float  *  set_float ( float *, int n,...);
125 double *  set_double( double*, int n,...);
126
127 short  *  ga_memcpy_short ( short  *array1, short  *array2, int n);
128 int    *  ga_memcpy_int   ( int    *array1, int    *array2, int n);
129 float  *  ga_memcpy_float ( float  *array1, float  *array2, int n);
130 double *  ga_memcpy_double( double *array1, double *array2, int n);
131
132 short  ** duplicate_short ( short  **array , int len, int field);
133 int    ** duplicate_int   ( int    **array , int len, int field);
134 char   ** duplicate_char  ( char   **array , int len, int field);
135 char    * duplicate_string ( char *string);
136 float  ** duplicate_float ( float  **array , int len, int field);
137 double ** duplicate_double( double **array , int len, int field);
138
139 short  ** copy_short ( short  **array1, short  **array2, int len, int number_field);
140 char   ** copy_char  ( char   **array1, char   **array2, int len, int number_field);
141 int    ** copy_int   ( int    **array1, int    **array2, int len, int number_field);
142 float  ** copy_float ( float  **array1, float  **array2, int len, int number_field);
143 double ** copy_double( double **array1, double **array2, int len, int number_field);
144
145 /*********************************************************************/
146 /*                                                                   */
147 /*                        CONCATENATION                              */
148 /*                                                                   */
149 /*                                                                   */
150 /*********************************************************************/
151 Alignment ** cat_aln_list ( Alignment **list_to_cat,int first, int end, Alignment **rec_list);
152
153 /*********************************************************************/
154 /*                                                                   */
155 /*                         NUMBER ARRAY ANALYSE                      */
156 /*                                                                   */
157 /*                                                                   */
158 /*********************************************************************/
159 FILE * output_array_int (int  **array, int len, int nf ,FILE *fp);
160 short  return_max_short (short ** array, int len_array, int field);
161 char  return_max_char( char  ** array, int len_array, int field);
162 int  return_max_int( int   ** array, int len_array, int field);
163 float  return_max_float( float ** array, int len_array, int field);
164 double return_max_double( double** array, int len_array, int field);
165
166 short  return_min_short (short ** array, int len_array, int field);
167 char  return_min_char( char  ** array, int len_array, int field);
168 int  return_min_int( int   ** array, int len_array, int field);
169 float  return_min_float( float ** array, int len_array, int field);
170 double return_min_double( double** array, int len_array, int field);
171
172 short  return_max_coor_short (short ** array, int len_array, int field, int *coor);
173 char  return_max_coor_char( char  ** array, int len_array, int field, int *coor);
174 int  return_max_coor_int( int   ** array, int len_array, int field, int *coor);
175 float  return_max_coor_float( float ** array, int len_array, int field, int *coor);
176 double return_max_coor_double( double** array, int len_array, int field, int *coor);
177
178 short  return_min_coor_short (short ** array, int len_array, int field, int *coor);
179 char  return_min_coor_char( char  ** array, int len_array, int field, int *coor);
180 int  return_min_coor_int( int   ** array, int len_array, int field, int *coor);
181 float  return_min_coor_float( float ** array, int len_array, int field, int *coor);
182 double return_min_coor_double( double** array, int len_array, int field, int *coor);
183
184 short  return_2Dmax_short (short ** array, int start, int len_array, int first_field, int number_field);
185 char  return_2Dmax_char( char  ** array, int start, int len_array, int first_field, int number_field);
186 int  return_2Dmax_int( int   ** array, int start, int len_array, int first_field, int number_field);
187 float  return_2Dmax_float( float ** array, int start, int len_array, int first_field, int number_field);
188 double return_2Dmax_double( double** array, int start, int len_array, int first_field, int number_field);
189
190 short  return_2Dmin_short (short ** array, int start, int len_array, int first_field, int number_field);
191 char  return_2Dmin_char( char  ** array, int start, int len_array, int first_field, int number_field);
192 int  return_2Dmin_int( int   ** array, int start, int len_array, int first_field, int number_field);
193 float  return_2Dmin_float( float ** array, int start, int len_array, int first_field, int number_field);
194 double return_2Dmin_double( double** array, int start, int len_array, int first_field, int number_field);
195
196 short  return_2Dmax_coor_short ( short ** array,int start1, int end1, int start2, int end2, int *i, int *j );
197 char  return_2Dmax_coor_char( char  ** array, int start1, int end1, int start2, int end2, int *i, int *j);
198 int  return_2Dmax_coor_int( int   ** array, int start1, int end1, int start2, int end2, int *i, int *j);
199 float  return_2Dmax_coor_float( float ** array, int start1, int end1, int start2, int end2, int *i, int *j);
200 double return_2Dmax_coor_double( double** array, int start1, int end1, int start2, int end2, int *i, int *j);
201
202 short  return_2Dmin_coor_short ( short ** array, int start1, int end1, int start2, int end2, int *i, int *j);
203 char  return_2Dmin_coor_char( char  ** array, int start1, int end1, int start2, int end2, int *i, int *j);
204 int  return_2Dmin_coor_int( int   ** array, int start1, int end1, int start2, int end2, int *i, int *j);
205 float  return_2Dmin_coor_float( float ** array, int start1, int end1, int start2, int end2, int *i, int *j);
206 double return_2Dmin_coor_double( double** array, int start1, int end1, int start2, int end2, int *i, int *j);
207
208 double return_wmean_short ( short ** array, int len, int wfield, int field);
209 double return_wmean_char  ( char  ** array, int len, int wfield, int field);
210 double return_wmean_int   ( int   ** array, int len, int wfield, int field);
211 double return_wmean_float ( float ** array, int len, int wfield, int field);
212 double return_wmean_double( double** array, int len, int wfield, int field);
213
214 double return_mean_short  ( short ** array, int len, int field);
215 double return_mean_char   ( char  ** array, int len, int field);
216 double return_mean_int    ( int   ** array, int len, int field);
217 double return_mean_float  ( float ** array, int len, int field);
218 double return_mean_double ( double** array, int len, int field);
219
220 short  return_sum_short ( short ** array, int len, int field);
221 char   return_sum_char  ( char  ** array, int len, int field);
222 int    return_sum_int   ( int   ** array, int len, int field);
223 float  return_sum_float ( float ** array, int len, int field);
224 double return_sum_double( double** array, int len, int field);
225
226 short  return_sd_short ( short ** array, int len, int field, short mean);
227 char   return_sd_char  ( char  ** array, int len, int field, char mean);
228 int    return_sd_int   ( int   ** array, int len, int field, int mean);
229 float  return_sd_float ( float ** array, int len, int field, float mean);
230 double return_sd_double( double** array, int len, int field, double mean);
231
232 double return_z_score ( double x, double sum, double sum2, double n);
233 double* return_r (double **list, int n);
234 short*  invert_list_short ( short * array, int len );
235 char*   invert_list_char  ( char  * array, int len );
236 int*    invert_list_int   ( int   * array, int len );
237 float*  invert_list_float ( float * array, int len );
238 double* invert_list_double( double* array, int len );
239
240 void   swap_short ( short * array, short * array2,int len );
241 void   swap_char  ( char  * array, char  * array2,int len );
242 void   swap_int   ( int   * array, int   * array2,int len );
243 void   swap_float ( float * array, float * array2,int len );
244 void   swap_double( double* array, double* array2,int len );
245
246 short  return_max_short_hor (short  ** array, int len_array, int field);
247 char   return_max_char_hor  (char   ** array, int len_array, int field);
248 int    return_max_int_hor   (int    ** array, int len_array, int field);
249 float  return_max_float_hor (float  ** array, int len_array, int field);
250 double return_max_double_hor(double ** array, int len_array, int field);
251
252 short  return_min_short_hor ( short ** array, int len_array, int field);
253 char   return_min_char_hor  ( char  ** array, int len_array, int field);
254 int    return_min_int_hor   ( int   ** array, int len_array, int field);
255 float  return_min_float_hor ( float ** array, int len_array, int field);
256 double return_min_double_hor( double** array, int len_array, int field);
257
258 short  best_short (int n, ...);
259 int    best_int   (int n, ...);
260 char   best_char  (int n, ...);
261 float  best_float (int n, ...);
262 double best_double(int n, ...);
263
264 int  is_defined_short (int n, ...);
265 int  is_defined_int   (int n, ...);
266 int  is_defined_char  (int n, ...);
267 int  is_defined_float (int n, ...);
268 int  is_defined_double(int n, ...);
269
270
271 int max_int (int*i, ...);
272
273 int return_maxlen ( char ** array, int number);
274 int return_minlen ( char ** array, int number);
275
276 float return_mean_diff_float ( float **array, int len, int field,float mean);
277
278
279 void inverse_int ( int**array, int len, int field, int max, int min);
280 void inverse_float ( float**array, int len, int field, int max, int min);
281 void inverse_2D_float ( float **array, int start, int len, int start_field, int number_field, float max,float min);
282
283
284
285
286 void   **recycle   (void   **A, int l, int cycle);
287
288 /*********************************************************************/
289 /*                                                                   */
290 /*                         SHELL INTERFACES                          */
291 /*                                                                   */
292 /*                                                                   */
293 /*********************************************************************/
294 char* getenv4debug ( const char *var);
295 char* get_env_variable ( const char *var, int mode);
296 void setenv_func ( char *string_name, char *string_value);
297 void get_pwd ( char *name);
298 char *pg2path (char *pg);
299 int pg_is_installed ( char *pg);
300 /*********************************************************************/
301 /*                                                                   */
302 /*                           MISC                                    */  
303 /*                                                                   */
304 /*********************************************************************/
305 char *num2plot (int value, int max, int line_len);
306 int   perl_strstr ( char *string, char *pattern);
307 float grep_function ( char *pattern, char *file);
308 void crash_if ( int val, char *s);
309 void crash ( char *s);
310 int ** make_recursive_combination_table ( int tot_n_param, int *n_param, int *nc, int**table, int field);
311 /*********************************************************************/
312 /*                                                                   */
313 /*                         STRING PROCESSING                         */
314 /*                                                                   */
315 /*                                                                   */
316 /*********************************************************************/
317 char *strnrchr ( char *s,char x, int n);
318 int intlen (int n);
319 char * update_string (char *string1, char *string2);
320 char* strcatf  (char *string1,char *string2, ...);
321 char *vcat (char *v1, char *v2);
322
323 int strget_param ( char *string, char *param_name, char *param_value, char *format, ...);
324 char * lstrstr ( char *in, char *token);
325 char * vstrstr ( char *in, char *token);
326 int strscanf (char *in, char *token, char *format, ...);
327 int match_motif ( char *string, char **motif);
328
329 char *after_strstr (char *string, char *token);
330
331 char ** push_string (char *val, char **stack, int *nval, int mode);
332 int vsrand (int val);
333 int  *randomize_list (int *list, int len, int ncycle);
334 int vstrcmp (const char *s1, const char *s2);
335 int vstrncmp (const char *s1, const char *s2, int n);
336 FILE *print_array_char (FILE *out, char **array, int n, char *sep);
337
338 char *extract_suffixe ( char *array);
339 char * path2filename ( char *array);
340 char *filename2path (char *name);
341 Fname* parse_fname ( char *array);
342
343 void string_array_convert ( char **array, int n_strings, int ns, char **sl);
344 void string_convert( char *string, int ns, char **sl);
345 int convert ( char c, int ns, char **sl);
346 int convert2 ( char c, char *list);
347
348 void string_array_upper ( char **string, int n);
349 void string_array_lower ( char **string, int n);
350 char *upper_string ( char *string);
351 char *lower_string ( char *string);
352 char * substitute_double ( char *string, char *token);
353 char * substitute ( char *string, char *token, char *replacement);
354 char * substitute_char ( char *string, char token, char replacement);
355 char * substituteN ( char *string, char *token, char *replacement, int N);
356 char * tild_substitute ( char *string, char *token, char *replacement);
357
358
359 char ** clean_string ( int n, char **string);
360
361 int str_overlap ( char *string1, char *string2, char x);
362 int get_string_line ( int start, int n_lines, char *in, char *out);
363 FILE * output_string_wrap ( int wrap,char *string, FILE *fp);
364 char * extract_char ( char * array, int first, int len);
365 int check_cl4t_coffee (int argv, char **argc);
366
367 char** break_list ( char **argv, int *argc, char *separators);
368 char** merge_list ( char **argv, int *argc);
369 int *name_array2index_array ( char **list1, int n1, char **list2, int n2);
370 char ** get_list_of_tokens ( char *string, char *separators, int *n_tokens);
371 char **ungap_array(char ** array, int n);
372 void ungap ( char *seq);
373 int seq2len (char *seq, char *pset, char *nset);
374 int seq2res_len (char *seq);
375 void remove_charset ( char *seq, char *set);
376 char *remove_charset_from_file (char *fname, char *set);
377 char *mark_internal_gaps(char *seq, char symbol);
378
379 char *list2string  (char **list, int n);
380 char *list2string2 (char **list, int n, char* sep);
381
382 char ** string2list (char *string);
383 char ** string2list2(char *string, char *separators);
384 int *  string2num_list( char *string);
385 int *  string2num_list2( char *string, char *separators);
386 char **char_array2number ( char ** array, int n);
387 char *char2number ( char * array);
388 long atop(char *);
389 char *invert_string (char *string);
390 char *invert_string2 (char *string);
391 char *string2inverted_string (char *string);
392 /* Analyse and Compare Strings*/
393 int isblanc ( char *buf);
394 /*int islower (char c);
395 int isupper (char c);
396 */
397 void splice_out ( char *seq, char x);
398 char* splice_out_seg ( char *seq,int pos, int len);
399
400 int is_number ( char *buf);
401 int is_alpha_line ( char *buf);
402 int is_alnum_line ( char *buf);
403 int case_insensitive_strcmp ( char *string1, char *string2);
404 int get_string_sim ( char *string1, char *string2, char *ignore);
405
406 int is_gap ( char x);
407 int is_gop (int p, char *s);
408
409 int is_aa  ( char x);
410 int is_dna ( char x);
411 int is_rna ( char x);
412
413
414
415 char * get_alphabet   ( char *seq, char *alphabet);
416 int is_in_set ( char r, char *list);
417 int array_is_in_set (char *array, char *set);
418 char * generate_void ( int x);
419 char * generate_null ( int x);
420 char * generate_string ( int x, char y);
421
422
423 char * translate_string (char *string, char *in, char*out);
424 int get_longest_string  (char **array,int n, int *len, int *index);
425 int get_shortest_string (char **array,int n, int *len, int *index);
426 /*EDIT STRING*/
427 char **pad_string_array ( char **array, int n, int len, char pad);
428 char * crop_string (char *string, int start, int end);
429 int get_distance2char ( char *x, char *list);
430
431 /*********************************************************************/
432 /*                                                                   */
433 /*                         TIME        FUNCTIONS                     */
434 /*                                                                   */
435 /*                                                                   */
436 /*********************************************************************/
437 FILE *print_program_information (FILE *fp, char *comment);
438 FILE* print_cpu_usage (FILE *fp, char *comment);
439 void print_exit_success_message ();
440 void print_exit_failure_message ();
441
442 int  get_time  ();
443 int get_ctime  ();
444 int  reset_time();
445 int increase_ref_time(int increase);
446 /*********************************************************************/
447 /*                                                                   */
448 /*                         SYSTEM CALLS                              */
449 /*                                                                   */
450 /*                                                                   */
451 /*********************************************************************/ 
452 pid_t **declare_pidtable ();
453 pid_t set_pid (pid_t p);
454 pid_t vfork();
455 pid_t vwait (pid_t *p);
456 int   vwait_npid (int submited, int max, int min);
457 int kill_child_pid();
458
459 int safe_system (const char * commande);
460 pid_t  vwaitpid (pid_t p, int *status, int options);
461
462 int evaluate_sys_call_io ( char *out_file, char *com, char *fonc);
463 void HERE (char *string, ...);
464 void printf_exit  (int exit_code, FILE *fp, char *string, ...);
465 int printf_file ( char *file, char *mode, char *string, ...);
466 int printf_fork ( FILE *fp,char *string,...);
467 int printf_system (char *string, ...);
468 int printf_system_direct (char *string, ...);
469 int my_system_cl (int argc, char *argv[]);
470 int my_system ( char *command);
471 int unpack_perl_script (char *name, char ***unpacked, int n);
472 void unpack_all_perl_script (char *script);
473 /*********************************************************************/
474 /*                                                                   */
475 /*                         IO FUNCTIONS                              */
476 /*                                                                   */
477 /*                                                                   */
478 /*********************************************************************/
479 FILE * print_command_line (FILE *fp );
480 int getpid_ref();
481 char ** standard_initialisation       ( char **in_argv, int *in_argc);
482 char ** standard_initialisation_start ( char **in_argv, int *in_argc);
483 char ** standard_initialisation_end   ( char **in_argv, int *in_argc);
484 /*
485 by default : dir_4_tcoffee: $HOME/.t_coffee
486 tmp: dir_4_tcoffee/tmp OR TMP_4_TCOFFEE
487 cache: idem
488 methods: idem
489 mcoffee: idem
490 */
491 int get_nproc ();
492 char *get_os();
493 char *get_plugins_4_tcoffee (char *mode);
494 char *get_home_4_tcoffee();
495 char *get_dir_4_tcoffee();
496 char *get_tmp_4_tcoffee();
497 char *get_cache_4_tcoffee();
498 char *get_methods_4_tcoffee();
499 char *get_mcoffee_4_tcoffee();
500
501
502
503 void myexit (int signal);
504 FILE *fatal_exit ( FILE *fp, int exit_signal, char *string, ...);
505 int set_warning_mode ( int mode);
506 FILE *add_warning (FILE *fp, char *string, ...);
507 void output_warning_list();
508
509 int   count_n_res_in_array  (char *array, int len);
510 int   count_n_gap_in_array  (char *array, int len);
511 int count_n_symbol_in_array ( char *array, char *array_list, int len);
512 char* count_strings_in_file ( char *in, char *out);
513 char** count_strings ( char **array, int len);
514 int ** count_int_strings ( int **array, int len, int s);
515
516 int   get_first_non_white_char (char *name);
517 int   count_n_char_x_in_file(char *name, char x);
518 int   count_n_char_in_file(char *name);
519 int   count_n_line_in_file(char *name);
520 int measure_longest_line_in_file ( char *name );
521 int file_cat ( char *fname1, char *fname2);
522 FILE* display_file_content (FILE *output, char *name);
523 int   cat_file (char *file1, char *file2);
524 char ***file2list   (char *name, char *sep);
525 char ** file2lines  (char *name);
526 char *  file2string (char *name);
527 char *string2file ( char *s, char *f, char *m);
528 char *chomp (char *name);
529 int get_cl_param (int argc, char **argv, FILE **fp,char *para_name, int *set_flag, char *type, int optional, int max_n_val,char *usage, ...);
530 char ** get_parameter ( char *para_name, int *np, char *fname);
531
532 char *get_t_coffee_environement (char *file);
533 char *set_path_4_plugins (char *);
534 int add_package2_tcoffee_env (char *package);
535
536
537 char *Proxy(int input_mode, int set_mode);
538 char *proxy_message ();
539 char *input_proxy ();
540 char *get_proxy();
541 char *get_proxy_from_env();
542 int set_proxy (char *proxy);
543
544 char *input_name ();
545 char *Email4cl(int input_mode, int set_mode);
546 char *Email(int input_mode, int set_mode);
547 char *input_email ();
548 char *get_email_from_env ();
549 char *get_email ();
550 int set_email (char *email);
551 int   cputenv (char*, ...);
552 char *file_putenv (char *file);
553 int check_dir_getenv ( char *string);
554
555 char* set_string_variable (char *var, char* v);
556 char* get_string_variable (char *var);
557 char* unset_string_variable (char *var);
558 char* store_string_variable (char *var, char * v, int mode);
559
560 int int_variable_isset (char *var);
561 int set_int_variable (char *var, int v);
562 int get_int_variable (char *var);
563 int unset_int_variable (char *var);
564 int store_int_variable (char *var, int v, int mode);
565
566 void check_vtmpnam ();
567 int flag_file2remove_is_on ();
568 void set_file2remove_off();
569 void set_file2remove_on();
570 char *set_file2remove_extension(char *extension, int mode);
571 char * add2file2remove_list ( char *name);
572
573
574
575 FILE * vtmpfile();
576 void initiate_vtmpnam (char *s);
577 char * vtmpnam ( char *s);
578 char *  tmpnam_2 (char *s);
579 char *  vremove ( char *s);
580 char *  vremove2 ( char *s);
581 void error_exit ();
582 void clean_exit();
583 void main_exit ();
584 int  log_function (char *fname);
585    
586 void   clean_function ( );
587 void   sig_clean_function ( int x);
588 char * prepare_cache ( const char *mode);
589 char * get_cache_dir();
590 void update_cache ();
591 void ignore_cache();
592
593 FILE * vfopen ( char *name, char *mode);
594 FILE * vfclose (FILE *fp);
595 int echo ( char *string, char *fname);
596
597 int **get_file_block_pattern (char *fname, int *n_blocks, int max_n_line);
598
599 int token_is_in_file (char *fname, char *token);
600 FILE * find_token_in_file_nlines ( char *fname, FILE * fp, char *token, int n_line);
601 FILE * find_token_in_file ( char *fname, FILE * fp, char *token);
602 char * vfgets (char *buf, FILE *fp);
603
604 FILE * set_fp_after_char ( FILE *fp, char x);
605 FILE * set_fp_id ( FILE *fp, char *id);
606 FILE * skip_commentary_line_in_file ( char com, FILE *fp);
607 char * strip_file_from_comments (char *com, char *in_file);
608
609 int check_for_update ( char *web_address);
610 int url2file (char *address, char *out);
611 int wget (char *address, char *out);
612 int curl (char *address, char *out);
613         
614
615 int simple_check_internet_connection  (char *address);
616 int check_internet_connection  (int mode);
617 int check_environement_variable_is_set ( char *variable, char *description, int fatal);
618 int check_program_is_installed ( char *program_name, char *current_path, char *path_variable, char *where2getit, int fatal);
619 FILE * display_output_filename ( FILE *io, char *type, char *format, char *name, int check_output);
620 FILE * display_input_filename ( FILE *io, char *type, char *format, char *name, int check_output);
621 int filename_is_special ( char *fname);
622 char *check_file_exists ( char *fname);
623 int my_mkdir ( char *dir);
624 int file_is_empty(char *fname);
625 int file_exists (char *path,char *fname);
626 int isexec (char *fname);
627 int isdir  (char *fname);
628 int rrmdir (char *fname);
629 char * ls_l(char *path,char *fname);
630
631 void create_file ( char *name);
632 void delete_file ( char *fname);
633 int  util_rename ( char* from, char *to);
634 int  util_copy   ( char* from, char *to);
635 FILE * output_completion4halfmat ( FILE *fp,int n, int tot, int n_eports, char *s);
636 FILE * output_completion ( FILE *fp,int n, int tot, int n_eports, char *s);
637 void * null_function (int a, ...);
638 int  btoi ( int nc,...);
639 /*********************************************************************/
640 /*                                                                   */
641 /*                         Geometric FUNCTIONS                    */
642 /*                                                                   */
643 /*                                                                   */
644 /*********************************************************************/
645
646 float get_geometric_distance ( float ** matrix, int ncoor, int d1, int d2, char *mode);
647 /*********************************************************************/
648 /*                                                                   */
649 /*                         MATHEMATICAL FUNCTIONS                    */
650 /*                                                                   */
651 /*                                                                   */
652 /*********************************************************************/
653 double log_addN ( int N, double *L);
654 double log_add6 (double a, double b, double c, double d, double e, double f );
655 double log_add5 (double a, double b, double c, double d, double e);
656 double log_add4 (double a, double b, double c, double d);
657 double log_add3 (double a, double b, double c);
658 double log_add2 (double a, double b);
659
660 float factorial_log ( int start, int end);
661 float M_chooses_Nlog ( int m, int N);
662 double factorial ( int start, int end);
663 double M_chooses_N ( int m, int N);
664 float my_int_log(int a);
665 /*********************************************************************/
666 /*                                                                   */
667 /*                         Fast Log Additions (adapted from Probcons)*/
668 /*                                                                   */
669 /*                                                                   */
670 /*********************************************************************/
671 double EXP(double x);
672 float LOOKUP (float x);
673 void LOG_PLUS_EQUALS (float *x, float y);
674 float LOG_ADD (float x, float y);
675 float LOG_ADD3 (float x1, float x2, float x3);
676 float LOG_ADD4 (float x1, float x2, float x3, float x4);
677 float LOG_ADD5 (float x1, float x2, float x3, float x4, float x5);
678 float LOG_ADD6 (float x1, float x2, float x3, float x4, float x5, float x6);
679 float LOG_ADD7 (float x1, float x2, float x3, float x4, float x5, float x6, float x7);
680 ///////////////////////////////////////////////////////////////////////////////////////////
681 // Hash function
682 ////////////////////////////////////////////////////////////////////////////////////////////
683 unsigned long hash_file(char* file);  //returns the hash value for key 
684 ///////////////////////////////////////////////////////////////////////////////////////////
685 // Generating lists through recirsive exploration
686 ////////////////////////////////////////////////////////////////////////////////////////////
687 int **generate_array_int_list (int len, int min, int max, int step, int *n, char *filename);
688 char ***generate_array_string_list (int len, char ***alp, int *alp_size, int *n, char *file, int mode);
689 float rates2sensitivity (int tp, int tn, int fp, int fn, float *sp, float *sn, float *sen2, float *best);
690 float profile2sensitivity (char *pred, char *ref, float *sp, float *sn, float *sen2, float *b);       
691 float profile2evalue (char *pred, char *ref);
692 //isexec lib
693 #include <stdio.h>
694
695 unsigned long linrand(unsigned long r);
696 unsigned long addrand(unsigned long r);
697 void addrandinit(unsigned long s);
698
699 unsigned long mult(unsigned long p,unsigned long q);
700     
701
702 struct Job_TC
703     {
704       int jobid;
705       int status;
706       
707       struct  Job_TC *c;
708       struct  Job_TC *p;
709       struct  Job_io_TC *io;
710       struct  Job_control_TC *control;
711       
712       struct  Job_param_TC *param;
713         
714       /*memory mangement*/
715       char **pl;
716       int np;
717 };
718 typedef struct Job_TC Job_TC;
719
720 struct Job_control_TC
721     {
722       
723       struct Job_TC* (*submitF) (struct Job_TC*);
724       struct Job_TC* (*retrieveF)(struct Job_TC*);
725       char *mode;
726 };
727 typedef struct Job_control_TC Job_control_TC;
728
729 struct Job_io_TC
730     {
731       char *in;
732       char *out;
733       struct Constraint_list *CL;
734       struct Alignment *A;
735 };
736 typedef struct Job_io_TC Job_io_TC;
737
738 struct Job_param_TC
739 {
740   char *method;
741   struct TC_method *TCM; 
742   char *temp_c;
743   char *aln_c;
744   char *seq_c;
745   char *aln_mode;
746 };
747 typedef struct Job_param_TC Job_param_TC;
748
749 Job_TC* print_lib_job ( Job_TC *job,char *string, ...);
750 Job_TC *print_lib_job2 ( Job_TC* job, int n, char **name, char **value);
751
752
753 /*Stack Manipulation*/
754 Job_TC *free_queue  (Job_TC *job);
755 Job_TC *free_job  (Job_TC *job);
756 Job_TC * queue2heap (Job_TC*job);
757 Job_TC * queue2last (Job_TC*job);
758 int queue2n (Job_TC*job);
759 Job_TC * descend_queue (Job_TC*job);
760 Job_TC *queue_cat  (Job_TC *P, Job_TC *C);
761 Job_TC *delete_job (Job_TC *job);
762 /*Job Control*/
763 struct Job_TC* submit_job ( Job_TC *job);
764 struct Job_TC* retrieve_job ( Job_TC *job);
765 Job_TC*** split_job_list (Job_TC *job, int ns);
766 struct Dps_result
767     {
768       int njobs;
769       struct Dps_job **dps_job;
770 };
771 typedef struct Dps_result Dps_result;
772
773 struct Dps_job
774     {
775       int JobId;
776       struct Constraint_list *CL;
777       char *input_file;
778       char *output_file;
779 };
780 typedef struct Dps_job Dps_job;
781
782 struct Dps_result *seq2list_DPS (struct Constraint_list *CL,char *method, char *aln_command, char *seq_command, char *weight, Dps_result *dps_result);
783 struct Constraint_list * gather_results_DPS ( Dps_result *DPS, struct Constraint_list *CL);
784 Dps_result *declare_dps_result ( int naln, Dps_result *dps);
785 #define SEQ1 0
786 #define SEQ2 1
787 #define R1 2
788 #define R2 3
789 #define WE 4
790 #define CONS 5
791 #define MISC 6
792 #define LIST_N_FIELDS 7
793 #define CLIST_TYPE int
794
795 /*********************************************************************************************/
796 /*                                                                                           */
797 /*         FUNCTIONS Typedef                                                                 */
798 /*                                                                                           */
799 /*********************************************************************************************/
800 typedef int (*Profile_cost_func) (int*, int *,struct Constraint_list *);
801 typedef int (*Col_cost_func)(Alignment*, int **, int, int*, int, int **, int, int*, int, struct Constraint_list *);
802 typedef int (*Pair_cost_func)(struct Constraint_list *, int, int, int, int);
803 typedef int (*Pwfunc) (Alignment *, int*, int **,struct Constraint_list *);
804
805 /*********************************************************************************************/
806 /*                                                                                           */
807 /*         STRUCTURES FOR PDB ANALYSIS                                                       */
808 /*                                                                                           */
809 /*********************************************************************************************/
810 typedef struct 
811     {
812       char *use_seqan;
813 }
814 TC_param;
815 typedef struct 
816     {
817       char blast_server[FILENAMELEN+1];
818       char db[FILENAMELEN+1];
819       int min_cov;
820       int min_id;
821       int max_id;
822 }
823 Blast_param;
824
825 typedef struct
826     {
827         int   n_excluded_nb;
828         
829         float similarity_threshold;
830         float rmsd_threshold;
831         float md_threshold;
832         int   distance_on_request;
833         char  *comparison_io;
834         int    print_rapdb;
835         float maximum_distance;/*Diameter of the bubble used to identify the Calpha Neighborhood*/
836         int   N_ca;            /*Number of Calpha to be looked at on both side*/
837         float max_delta ;      /*Maximum value for delta to be positive*/ 
838         char *local_mode;
839         int   scale;             /*Value substracted to the pdb score in the bubble mode*/
840         int   n_extra_param;
841         char **extra_param;
842       char  *evaluate_mode;
843       char  *color_mode;
844       float filter;
845       int filter_aln;
846       int irmsd_graph;
847       int nirmsd_graph;
848       
849       
850     }
851 Pdb_param;
852
853 typedef struct
854     {
855         int num;
856         int res_num;/*Residue number from 1 to N*/
857         char res[4];
858         char type[4];
859         float  x;
860         float  y;
861         float  z;
862     }
863 Atom;
864
865 typedef struct
866     {
867       
868       Atom*CA;
869       Atom *C;
870       Atom *N;
871       Atom *CB;
872     }
873 Amino_acid;
874
875
876 typedef struct
877     {
878     /*Distances used for the Neighbour mode*/
879         int    **nb;       /*Neighbors of each Ca ( sorted by distance) given as atoms*/
880                            /*nb[x][0] contains the number of neighbor atoms*/
881         float  **d_nb;     /* contains the distances between atom y=nb[x][5] and Ca x*/
882                            /* !!!d_nb[x][0] is empty, the array starts at +1 to folow nb*/
883         int max_nb;        /* Largest neigborhood*/ 
884 }
885 Struct_nb;
886
887 typedef struct 
888     {
889         
890         int   len;         /*Number of Calpha Carbons*/
891         int   n_atom;      /*Number of atoms*/
892         char  *name;       /*Name of the sequence*/
893         char  *seq;        /*Sequence ( Complete)*/
894         Atom  **structure; /*Atoms*/
895         Atom  **ca;        /*List of pointers to the Calpha Atoms from 0 to N-1*/
896         Amino_acid **peptide_chain;/*List of pointers to the Calpha Atoms from 0 to N-1*/
897       
898         
899         Struct_nb *Chain;
900         Struct_nb *Bubble;
901         Struct_nb *Transversal;
902         
903         float ** ca_dist;
904         Pdb_param *pdb_param;
905 }
906
907 Ca_trace;
908 /*********************************************************************************************/
909 /*                                                                                           */
910 /*         MOCA: Data structure for domains and alignments                                   */
911 /*                                                                                           */
912 /*********************************************************************************************/
913 struct Moca
914 {
915   /*Normalisation factor: value by which each constraint weight is decreased*/
916       int moca_scale;
917   /*Functions used for domain extraction:*/
918       /*Function for evaluating the score of a domain: returns 0 if not acceptable, value if OK*/
919       int (*evaluate_domain)(Alignment*,struct Constraint_list *);
920       int moca_threshold;
921
922       /*Function for hiding previously used residues*/
923       int  ** (*cache_cl_with_domain)(Alignment*, struct Constraint_list *);
924       int  **forbiden_residues; /*List of residues already used for domain construction*/
925       
926       
927       /*Function for trunkating the result into a non-overlapping alignment*/
928       Alignment* (*make_nol_aln)(Alignment*, struct Constraint_list *);
929      
930       /*Parameters Coordinates of the first motif to extract*/
931       int moca_start;
932       int moca_len;
933       int moca_interactive;
934       
935 };
936 typedef struct Moca Moca;
937 /*********************************************************************************************/
938 /*                                                                                           */
939 /*         CONSTRAINT LISTS                                                                  */
940 /*                                                                                           */
941 /*********************************************************************************************/
942 struct Distance_matrix
943 {
944   char mode[100];
945   char sim_mode[100];
946   char nseq;
947   int     **similarity_matrix; /*Pairwise ID levels: 1-10000*/ 
948   int     **score_similarity_matrix; /*Pairwise ID levels: 1-10000*/ 
949   int     **distance_matrix; /*Pairwise ID levels: 1-10000*/ 
950 };
951 typedef struct Distance_matrix Distance_matrix;
952 struct Constraint_list
953     {
954       /*In Case of Modif, synchronize with:
955         util_declare/declare_constraint_list
956         util_declare/cache_dp_value4constraint_list
957         util_declare/duplicate_constraint_list
958         util_declare/free_constraint_list
959       */
960
961       //Generic parameters
962       TC_param *TC;
963
964       int copy_mode;
965       struct Constraint_list *pCL; 
966       Sequence *S;         /*Total sequences*/
967       Sequence *STRUC_LIST; /*Name of the sequences with a Structure*/
968       char align_pdb_param_file[FILENAMELEN+1];
969       char align_pdb_hasch_mode[FILENAMELEN+1];
970      
971
972       Weights  *W;         /*Sequence Weights*/
973       Distance_matrix *DM; /*Accurate Distance Matrix*/
974       Distance_matrix *ktupDM; /*Fast Distance Matrix*/
975       Fname *RunName;
976       
977       int *translation;   
978       char **  out_aln_format;
979       int    n_out_aln_format;
980
981       
982       /*Packing Sequence: To use with domain analysis*/
983       int **packed_seq_lu;
984       
985       /*DATA*/
986       FILE *fp;           /*File used for i/o if disk being used*/
987       int *L;            /*Array used for storing Lib if mem being used*/
988       int **M;            /*substitution matrix*/
989       char rna_lib[FILENAMELEN+1];  /*name of a file containing the RNA libraries*/
990       
991       /*List Information*/      
992       int ne;             /*Number of elements in the list*/
993       char list_name[1000];    /*Name of the list*/
994       int  entry_len;     /*Size of an entry in el_size*/
995       size_t el_size;     /*Size of each elements in an entry in bytes*/
996       
997       /*Normalisation information*/
998       int normalise;
999       int max_ext_value;
1000       int max_value;
1001       int overweight;
1002       int filter_lib;
1003       
1004       /*Pair wise alignment method*/
1005       int   pw_parameters_set;
1006       int   gop;
1007       int   gep;
1008       int   f_gop;
1009       int   f_gep;
1010       int   nm_gop;
1011       int   nm_gep;
1012       
1013       int   nomatch;
1014       
1015       int   TG_MODE;
1016       int   F_TG_MODE;
1017
1018       char  dp_mode[FILENAMELEN+1];
1019       int   reverse_seq;
1020       int   maximise;
1021       char  matrix_for_aa_group[FILENAMELEN+1];
1022       char  method_matrix[FILENAMELEN+1];
1023       float diagonal_threshold;
1024       int ktup;
1025       int use_fragments;
1026       int fasta_step;
1027       int lalign_n_top;
1028       int sw_min_dist;
1029       char **matrices_list;
1030       int n_matrices;
1031       char tree_mode[FILENAMELEN+1];
1032
1033       char distance_matrix_mode[FILENAMELEN+1];
1034       char distance_matrix_sim_mode[FILENAMELEN+1];
1035       
1036       Alignment *tree_aln;
1037       
1038       /*Functions used for dynamic programming and Evaluation*/
1039       int no_overaln;
1040       /*1 Function for evaluating the cost of a column*/
1041       Col_cost_func get_dp_cost;
1042       Profile_cost_func profile_mode;
1043       char profile_comparison [FILENAMELEN+1];
1044       
1045       /*2 Function for evaluating the cost of a pair of residues*/
1046       Pair_cost_func evaluate_residue_pair;
1047       /*3 Function for making dynamic programming*/
1048       Pwfunc pair_wise;
1049       
1050       /*
1051       int (*get_dp_cost)(Alignment*, int **, int, int*, int, int **, int, int*, int, struct Constraint_list *);
1052       int (*evaluate_residue_pair)(struct Constraint_list *, int, int, int, int);
1053       int (*pair_wise)(Alignment *, int*, int **,struct Constraint_list *);
1054       */
1055
1056       int weight_field;
1057       int max_n_pair; /*maximum number of pairs when aligning two profiles*/
1058
1059       /*Extend a sequence against itself*/
1060       
1061       /*Threading parameters*/
1062       Blast_param *Prot_Blast;
1063       Blast_param *Pdb_Blast;
1064       Blast_param *DNA_Blast;
1065       /*Split parameters*/
1066       int split;
1067       int split_nseq_thres;
1068       int split_score_thres;
1069       /*Check Structural Status*/
1070       int check_pdb_status;
1071       /*log*/
1072       char method_log[1000];
1073       char evaluate_mode[1000];
1074       char method_evaluate_mode[100];
1075 /*Parameters for domain extraction*/      
1076       Moca *moca;
1077 /*Functions for hiding forbiden pairs of residues*/
1078       int ****forbiden_pair_list;     /* pair_list[S1][S2][L1][L2]=1 ->forbiden*/
1079                                      /* pair_list[S1][S2][L1][L2]=0 ->allowed*/
1080                                      /* pair_list[S1][S2][L1]=NULL  ->all pairs S1L1, S2 allowed */
1081                                      /* S-> sequences, 0..N   */
1082                                      /* L-> residues , 1..L-1 */
1083
1084 /*extention properties:  copy*/
1085       int *seq_for_quadruplet;
1086       int nseq_for_quadruplet;
1087       
1088 /*extention properties: Do Not copy*/
1089       int extend_jit;               /*Extend only on request*/
1090       int extend_threshold;         /*Do not extend pairs below the Theshold*/
1091       int do_self;                  /*Extend a sequence against itself*/
1092       char extend_clean_mode[100];  
1093       char extend_compact_mode[100];
1094       
1095       
1096 /*Lookup table parameteres*/
1097 /*!!!!!do not copy in duplication*/
1098       /*Residue Index contains residue_index[nseq][seq_len][0]->number of links*/
1099       /*[seq][res][x  ]->target seq (0->N-1)*/
1100       /*[seq][res][x+1]->traget res (1->len*/
1101       /*[seq][res][x+2]->target weight */
1102       /*It is automatically recomputed when L residue_indexed is set to 0*/
1103       int residue_indexed;
1104       int ***residue_index;
1105       int residue_field;        
1106
1107       /*Index of the pairs of sequences within L*/
1108       int seq_indexed;
1109       int **start_index;
1110       int **end_index;
1111       int max_L_len;
1112       int chunk;
1113       
1114       
1115             
1116       /*PDB STRUCTURE ALIGNMENTS*/      
1117       Ca_trace ** T;    /*This structure contains the PDB trace for sequences with a known Struc T[Nseq]*/
1118
1119        /*MISC*/
1120       int cpu;
1121       FILE *local_stderr;
1122       char  multi_thread[100];
1123       char  lib_list[FILENAMELEN+1];
1124 };
1125
1126 typedef struct Constraint_list Constraint_list;
1127
1128 struct TC_method 
1129 {
1130   
1131   char executable[FILENAMELEN+1];
1132   char executable2[FILENAMELEN+1];
1133   char in_flag[FILENAMELEN+1];
1134   char in_flag2[FILENAMELEN+1];
1135   char out_flag[FILENAMELEN+1];
1136   char aln_mode[FILENAMELEN+1];
1137   char out_mode[FILENAMELEN+1];
1138   char seq_type[FILENAMELEN+1];
1139   char weight[FILENAMELEN+1];
1140   char matrix[FILENAMELEN+1];
1141   int gop;
1142   int gep;
1143   int minid;
1144   int maxid;
1145   char param[1000];
1146   char param1[1000];
1147   char param2[1000];
1148   
1149   Constraint_list *PW_CL;
1150 };
1151 typedef struct TC_method TC_method;
1152
1153 /*********************************************************************/
1154 /*                                                                   */
1155 /*                         PRODUCE IN LIST                             */
1156 /*                                                                   */
1157 /*                                                                   */
1158 /*********************************************************************/
1159 Constraint_list *produce_list ( Constraint_list *CL, Sequence *S, char * method,char *weight,char *mem_mode);   
1160 Job_TC* method2job_list ( char *method, Sequence *S,char *weight, char *lib_list, Distance_matrix *DM, Constraint_list *CL);
1161
1162 Job_TC *job_list2multi_thread_job_list (Job_TC* ojob, char *mt, Constraint_list *CL);
1163 Job_TC *retrieve_lib_job ( Job_TC *job);
1164 Job_TC *submit_lib_job ( Job_TC *job);
1165 int add_method_output2method_log (char *l, char *command,Alignment *A, Constraint_list *CL, char *iofile);
1166
1167 int check_seq_type (TC_method *M, char *slist,Sequence *S);
1168 int check_profile_seq_type (Sequence *S, int i, char t);
1169 char **method_list2method4dna_list ( char **list, int n);
1170 int is_in_pre_set_method_list (char *fname);
1171 char *** display_method_names (char *mode, FILE *fp);
1172
1173 char *method_name2method_file (char *method);
1174 char *make_aln_command(TC_method *m, char *seq, char *aln);
1175 struct TC_method* method_file2TC_method ( char *fname);
1176 char *method_file_tag2value (char *method, char *tag);
1177 int TC_method2method_file( struct TC_method*, char *fname );
1178 /*********************************************************************/
1179 /*                                                                   */
1180 /*                         WRITE IN LIST                             */
1181 /*                                                                   */
1182 /*                                                                   */
1183 /*********************************************************************/
1184 int dump_constraint_list (Constraint_list *CL);
1185 int vread_clist ( Constraint_list *CL, int a, int b );
1186 int vwrite_clist ( Constraint_list *CL, int a, int b, CLIST_TYPE x);
1187 Constraint_list *index_constraint_list ( Constraint_list *CL);
1188 Constraint_list *index_res_constraint_list ( Constraint_list *CL, int field);
1189 Constraint_list * progressive_index_res_constraint_list ( Alignment *A, int *ns, int **ls, Constraint_list *CL);
1190 char ** reindex_constraint_list (char **profile, int np,char **list, int *inL, Sequence *S);
1191 /*********************************************************************/
1192 /*                                                                   */
1193 /*                         ENTRY MANIPULATION                        */
1194 /*                                                                   */
1195 /*                                                                   */
1196 /*********************************************************************/
1197 Constraint_list * add_list_entry2list (Constraint_list *CL, int n_para, ...);
1198 Constraint_list * evaluate_constraint_list_reference ( Constraint_list *CL);
1199 Constraint_list *add_entry2list ( CLIST_TYPE *entry, Constraint_list *CL);
1200 Constraint_list *insert_entry2list ( CLIST_TYPE *entry, int pos,Constraint_list *CL);
1201 CLIST_TYPE* extract_entry(CLIST_TYPE * entry, int pos, Constraint_list *CL);
1202 /*********************************************************************/
1203 /*                                                                   */
1204 /*                         LIST EXTENTION                            */
1205 /*                                                                   */
1206 /*                                                                   */
1207 /*********************************************************************/
1208 Constraint_list *extend_list_pair (Constraint_list *CLin,char *store_mode, int s1, int s2);
1209 Constraint_list *extend_list (Constraint_list *CLin, char *store_mode,char *clean_mode, char *compact_mode,int do_self, Sequence *SUBSET);
1210 void get_bounds (Constraint_list *CL, int s1, int s2, int *start, int *end);
1211 int ** fill_pos_matrix (Constraint_list *CL, int beg, int end, int slen, int **pos, int *len, int mirrored);
1212
1213 /*********************************************************************/
1214 /*                                                                   */
1215 /*                         SEARCH IN LIST (ARRAY AND FILE)           */
1216 /*                                                                   */
1217 /*                                                                   */
1218 /*********************************************************************/
1219 FILE * compare_list (FILE *OUT, Constraint_list *CL1,Constraint_list *CL2);
1220 //CLIST_TYPE *search_in_list_constraint(int *key, int k_len, int **L, int ne, int ***start_index, int ***end_index);
1221 CLIST_TYPE *main_search_in_list_constraint ( int *key,int *p,int k_len,Constraint_list *CL);
1222 Constraint_list *sort_constraint_list_inv (Constraint_list *CL, int start, int len);
1223 Constraint_list *invert_constraint_list (Constraint_list *CL, int start,int len);
1224 Constraint_list * sort_constraint_list (Constraint_list *CL, int start, int len);
1225 Constraint_list * sort_constraint_list_on_n_fields (Constraint_list *CL, int start, int len, int first_field, int n_fields);
1226
1227 /*********************************************************************/
1228 /*                                                                   */
1229 /*                         INPUT/OUTPUT                              */
1230 /*                                                                   */
1231 /*                                                                   */
1232 /*********************************************************************/
1233 Constraint_list* read_n_constraint_list(char **fname,int n_list, char *in_mode,char *mem_mode,char *weight_mode,char *type, FILE *local_stderr, Constraint_list *CL, char *seq_source);
1234 Constraint_list* read_constraint_list(Constraint_list *CL,char *fname,char *in_mode,char *mem_mode,char *weight_mode);
1235 Constraint_list * read_constraint_list_raw_file(Constraint_list *CL, char *fname);
1236
1237 int        read_cpu_in_n_list(char **fname, int n);
1238 int read_seq_in_list ( char *fname,  int *nseq, char ***sequences, char ***seq_name);
1239
1240 Sequence * read_seq_in_n_list(char **fname, int n, char *type, char *SeqMode);
1241
1242 int        read_cpu_in_list ( char *fname);
1243 int ** read_list ( char *fname, int **list,int *ne, int *nseq, int *cpu, char ***sequences, char ***seq_name);
1244
1245 char * expand_constraint_list_file ( char *file);
1246 Constraint_list * read_constraint_list_file(Constraint_list *CL, char *fname);
1247 Constraint_list * fast_read_constraint_list_file(Constraint_list *CL, char *fname);
1248
1249 /*********************************************************************/
1250 /*                                                                   */
1251 /*                         EXTENDED LIST OUTPUT                      */
1252 /*                                                                   */
1253 /*                                                                   */
1254 /*********************************************************************/ 
1255 FILE * save_extended_constraint_list      (  Constraint_list *CL, char *mode, FILE *fp) ;
1256 FILE * save_extended_constraint_list_pair (  Constraint_list *CL, char *mode, char* seq1, char * seq2,FILE *fp);
1257
1258 /*********************************************************************/
1259 /*                                                                   */
1260 /*                         LIST OUTPUT                               */
1261 /*                                                                   */
1262 /*                                                                   */
1263 /*********************************************************************/ 
1264 int constraint_list2raw_file ( Constraint_list *CL, char *fname, char *fmode);
1265 FILE * save_raw_constraint_list   ( FILE *fp,Constraint_list *CL, int start,int len, int *translation);
1266 FILE * save_constraint_list ( Constraint_list *CL,int start, int len, char *fname, FILE *fp,char *mode,Sequence *S);
1267 FILE * save_sub_list_header ( FILE *OUT, int n, char **name, Constraint_list *CL);
1268 FILE * save_list_header ( FILE *OUT,Constraint_list *CL);
1269 FILE * save_list_footer (FILE *OUT,Constraint_list *CL);
1270 FILE * save_constraint_list_ascii ( FILE *OUT,Constraint_list *CL, int start,int len, int *translation);
1271 FILE * save_constraint_list_bin   ( FILE *OUT,Constraint_list *CL, int start,int len, int *translation);
1272
1273 /*********************************************************************/
1274 /*                                                                   */
1275 /*                         LIST CONVERTION                           */
1276 /*                                                                   */
1277 /*                                                                   */
1278 /*********************************************************************/         
1279 Constraint_list * shrink_constraint_list (Constraint_list *CL);
1280 Constraint_list * relax_constraint_list (Constraint_list *CL);
1281 Constraint_list * filter_constraint_list (Constraint_list *CL, int field, int T);
1282 int constraint_list_is_connected ( Constraint_list *CL);
1283
1284 int *seqpair2weight (int s1, int s2, Alignment *A,Constraint_list *CL, char *weight_mode, int *weight);
1285 Constraint_list *aln_file2constraint_list (char *alname, Constraint_list *CL,char *weight_mode);
1286 Constraint_list *aln2constraint_list      (Alignment *A, Constraint_list *CL,char *weight_mode);
1287
1288 double **list2mat (Constraint_list *CL,int s1,int s2, double *min, double *max);
1289 Constraint_list * constraint_list2bin_file(Constraint_list *clist);
1290 FILE * bin_file2constraint_list ( Constraint_list *CL, FILE *fp, char *name);
1291
1292 int **list2residue_total_weight ( Constraint_list *CL);
1293 int **list2residue_total_extended_weight ( Constraint_list *CL);
1294 int **list2residue_partial_extended_weight ( Constraint_list *CL);
1295 /*******************************************************************************************/
1296 /*                                                                                         */
1297 /*                                                                                         */
1298 /*                              clean functions                                            */
1299 /*                                                                                         */
1300 /*                                                                                         */
1301 /*                                                                                         */
1302 /*******************************************************************************************/
1303 Constraint_list *clean ( char *clean_mode,Constraint_list *C,int start, int len);
1304 Constraint_list * clean_shadow ( Constraint_list *CL, int start, int len);
1305
1306 /*********************************************************************/
1307 /*                                                                   */
1308 /*                         LIST FUNCTIONS                            */
1309 /*                                                                   */
1310 /*                                                                   */
1311 /*********************************************************************/ 
1312 Constraint_list *merge_constraint_list   ( Constraint_list *SL, Constraint_list *ML, char *mode);
1313 CLIST_TYPE return_max_constraint_list ( Constraint_list *CL, int field);
1314 Constraint_list *modify_weight( Constraint_list *CL,int start, int end,  char *modify_mode);
1315 Constraint_list *compact_list (Constraint_list *CL, int start, int len, char *compact_mode);
1316 Constraint_list *rescale_list_simple (Constraint_list *CL,int start, int len,int new_min, int new_max);
1317 Constraint_list *rescale_list (Constraint_list *CL,int start, int len,int max1, int max2);
1318 Constraint_list* filter_list (Constraint_list *CL, int start, int len,int T);
1319 Constraint_list *undefine_list (Constraint_list *CL);
1320 int ** seq2defined_residues ( Sequence *S, Constraint_list *CL);
1321 int ** aln2defined_residues ( Alignment *A, Constraint_list *CL);
1322 /*********************************************************************/ 
1323 /*          DEBUG                                                    */
1324 /*                                                                   */
1325 /*********************************************************************/ 
1326 void print_CL_mem(Constraint_list *CL, char *function);
1327 int constraint_list_is_sorted ( Constraint_list *CL);
1328 void check_seq_pair_in_list(Constraint_list *CL,int seq1, int seq2);
1329 /******************************************************************/
1330 /*                    NEW METHODS                                 */
1331 /*                                                                */
1332 /*                                                                */
1333 /******************************************************************/
1334
1335 Constraint_list * align_coding_nucleotides (char *seq, char *method, char *weight, char *mem_mode, Constraint_list *CL);
1336 /*********************************************************************************************/
1337 /*                                                                                           */
1338 /*         FUNCTION FOR PRUNING THE LIST                                                   */
1339 /*                                                                                           */
1340 /*********************************************************************************************/
1341 char * list2prune_list (Sequence *S, int **sm);
1342 /*********************************************************************************************/
1343 /*                                                                                           */
1344 /*         FUNCTION FOR WEIGHTING THE LIST                                                   */
1345 /*                                                                                           */
1346 /*********************************************************************************************/
1347 Constraint_list *weight_constraint_list(Constraint_list * CL, char *seq_weight);
1348 Weights* compute_t_coffee_weight(Constraint_list * CL);
1349 Constraint_list *re_weight_constraint_list(Constraint_list * CL,Weights *W);
1350
1351
1352 Distance_matrix *cl2distance_matrix (Constraint_list *CL, Alignment *A,  char *mode, char *sim_mode, int print);
1353 Distance_matrix *seq2distance_matrix (Constraint_list *CL, Alignment *A,  char *mode, char *sim_mode, int print);
1354
1355 /*********************************************************************************************/
1356 /*                                                                                           */
1357 /*         MULTI_THREAD                                                                      */
1358 /*                                                                                           */
1359 /*********************************************************************************************/
1360 int run_multi_thread_file (char *fname, char *config);
1361 /*********************************************************************/
1362 /*                                                                   */
1363 /*                        RNA FUNCTIONS                              */
1364 /*                                                                   */
1365 /*                                                                   */
1366 /*********************************************************************/
1367 char * seq2rna_lib ( Sequence *S, char *name);
1368 Constraint_list *read_rna_lib ( Sequence *S, char *fname);
1369 Constraint_list *rna_lib_extension ( Constraint_list *CL, Constraint_list *R);
1370 char *** produce_method_file ( char *method);
1371 typedef struct
1372     {
1373       int   p1;
1374       int   p2;
1375       int   p3;
1376       int   p4;
1377       int   t;
1378       int   f;
1379       char  mode[20];//lower, unalign
1380       char  model[20];//fsa1 fsa2
1381 }
1382 OveralnP;
1383
1384 //RNA
1385
1386 int **    alifold_list2cov_list (Alignment *A, int **list);
1387 int ** update_RNAfold_list (Alignment *A, int **pos, int s, int **l);
1388 int ** vienna2list ( char *seq);
1389 Alignment *compare_RNA_fold ( Alignment *A, Alignment *B);
1390
1391 Alignment *alifold2analyze (Alignment *A, Alignment *ST, char *mode);
1392 Alignment *alifold2cov_aln (Alignment *A, int **l, int ug);
1393 Alignment *alifold2cov_stat (Alignment *A, int **l, int ug);
1394 Alignment *alifold2cov_list (Alignment *A, int **l, int ug);
1395 Alignment *alifold2cov_cache (Alignment *inA,  int **l, int ug);
1396
1397
1398 Alignment *add_alifold2aln  (Alignment *A, Alignment *ST);
1399 Alignment *aln2alifold(Alignment *A);
1400
1401 //end
1402 Alignment * aln2bootstrap (Alignment *A, int n);
1403 Alignment * aln2sample    (Alignment *A, int n);
1404 Alignment * aln2random_aln (Alignment *A, char *mode);
1405 Alignment *aln2scale (Alignment *A, char *offset);
1406 Alignment* aln2case_aln (Alignment *A, char *upper, char *lower);
1407 Alignment*aln2gap_cache (Alignment *A, int val);
1408 Alignment *score_aln2score_ascii_aln (Alignment *A, Alignment *C);
1409 int **aln2resindex ( Alignment *A, Alignment *B, FILE *fp);
1410 int **index_seq_res      ( Sequence *S1, Sequence *S2, int **name_index);
1411 int **index_seq_name ( Sequence *S1, Sequence *S2);
1412 int *get_name_index (char **l1, int n1, char **l2, int n2);
1413
1414 int* get_res_index (char *seq1, char *seq2);
1415 int * pos2list (int * pos, int len, int *nl);
1416   int *list2pos (int *list, int nl, int len);
1417
1418
1419 int change_residue_coordinate ( char *in_seq1, char *in_seq2, int v);
1420
1421 int ** minimise_repeat_coor (int **coor, int nseq, Sequence *S);
1422 int ** get_nol_seq( Constraint_list *CL,int **coor, int nseq, Sequence *S);
1423
1424
1425 int compare_pos_column( int **pos1,int p1, int **pos2,int p2, int nseq);
1426
1427
1428
1429 char * seq2alphabet (Sequence *S);
1430 char *aln2alphabet (Alignment *A);
1431 char *array2alphabet (char **array, int n, char *forbiden);
1432
1433 //TM Predictions
1434 char* alnpos2hmmtop_pred (Alignment *A, Alignment *Pred, int pos, int mode);
1435 Alignment * aln2hmmtop_pred (Alignment *A);
1436 char * seq2tmstruc ( char *seq);
1437
1438 char * set_blast_default_values();
1439 char      *  seq2pdb   ( Sequence *S);
1440 Alignment *  seq2blast ( Sequence *S);
1441
1442 Sequence * seq2unique_name_seq ( Sequence *S);
1443 Alignment * aln2unique_name_aln ( Alignment *S);
1444 int name_list2unique_name_list (int n, char **name);
1445 Sequence *seq2clean_seq ( Sequence *S, char *alp);//remove all alp characters from seq
1446
1447  
1448 int       ** seq2aln_pos      (Alignment *A, int *n, int **ls);
1449 Alignment *padd_aln ( Alignment *A);
1450 char **padd_string ( char **string, int n,char pad);
1451
1452 Alignment *local_maln2global_maln (char *seq, Alignment *A);
1453
1454 Alignment * seq2profile (Sequence *S, int index);
1455
1456 Sequence *remove_empty_sequence (Sequence *S);
1457 Alignment *  aln2profile (Alignment * A);
1458 Alignment * aln2collapsed_aln (Alignment * A, int n, char **string);
1459 Alignment* aln2sub_aln_file (Alignment *A, int n, char **string);
1460 Alignment* aln2sub_seq (Alignment *A, int n, char **string);
1461
1462 int       ** aln2inv_pos  (Alignment *A);
1463 int        * seq2inv_pos ( char *seq);
1464 int       ** aln2pos_simple   (Alignment *A, int n_nseq, ...);
1465 int       ** aln2pos_simple_2 (Alignment *A);
1466 Alignment ** split_seq_in_aln_list ( Alignment **aln, Sequence *S, int l_seq, char **seq_list);
1467
1468 Sequence * fill_sequence_struc ( int nseq, char **sequences, char **seq_name);
1469
1470 int  seq_list2in_file ( TC_method *M, Sequence *S, char *list, char *file);
1471 int  seq_list2fasta_file( Sequence *S,  char *list, char *file);
1472 Structure * seq2struc    ( Sequence *S, Structure *ST);
1473 Alignment *strings2aln (int nseq,...);
1474
1475 Alignment * seq2aln      ( Sequence *S, Alignment *A,int rm_gap);
1476 Alignment  *seq_coor2aln ( Sequence *S, Alignment *A, int **coor, int nseq);
1477
1478 Alignment *stack_aln (Alignment *A, Alignment *B);
1479 Alignment *chseqIaln(char *name, int seq_n, int start,int len,Sequence *S, int seqIaln, Alignment *A);
1480
1481
1482 char *dna_aln2cons_seq ( Alignment *A);
1483 char *aln2cons_seq ( Alignment *A, int ns, int *ls, int n_groups, char **group_list);
1484 char *aln2cons_maj ( Alignment *A, int ns, int *ls, int n_groups, char **group_list);
1485 Alignment *aln2conservation ( Alignment *A, int threshold,char *seq);
1486
1487 char *sub_aln2cons_seq_mat ( Alignment *A,int ns, int *ls, char *mat_name);
1488 char *aln2cons_seq_mat ( Alignment*A, char *mat_name);
1489 Alignment *aln2short_aln( Alignment *A, char *list, char *new, int spacer);
1490 Sequence  *keep_residues_in_seq ( Sequence *S,char *list, char replacement);
1491 Alignment *keep_residues_in_aln ( Alignment *A,char *list, char replacement);
1492 Alignment *filter_keep_residues_in_aln ( Alignment *A,Alignment *ST, int use_cons, int value, char *list, char replacement);
1493
1494 Alignment *aln_convert (Alignment *A, Alignment *ST, int use_cons, int value,int n, ...);
1495 Alignment *aln2number (Alignment *A);
1496 Alignment * filter_aln ( Alignment *A, Alignment *ST, int value);
1497 Alignment * filter_aln_lower_upper ( Alignment *A, Alignment *ST,int use_cons, int value);
1498 Alignment * filter_aln_upper_lower ( Alignment *A, Alignment *ST, int use_cons,int value);
1499 Alignment * filter_aln_switchcase ( Alignment *A, Alignment *ST, int use_cons, int value);
1500
1501 Alignment * STseq2STaln ( Alignment *A, Alignment *ST);
1502 Alignment * merge_annotation   ( Alignment *A, Alignment *ST, char *seq);
1503 Alignment * filter_aln_convert ( Alignment *A, Alignment *ST, int use_cons,int value, int n_symbol,char** symbol_list);
1504 int aln2ngap (Alignment *A);
1505
1506 int  * count_in_aln ( Alignment *A, Alignment *ST, int value, int n_symbol,char **symbol_list, int *table);
1507 void count_misc (Alignment*A, Alignment *B);
1508
1509 Alignment * trim_aln_with_seq ( Alignment *S, Alignment *P);
1510 Alignment * add_align_seq2aln ( Alignment *A, char *seq, char *seq_name);
1511 Sequence  * aln2seq    ( Alignment *A);
1512 Sequence  * aln2seq_main    ( Alignment *A, int mode);
1513 Alignment * thread_profile_files2aln (Alignment *A, char *template_file, Fname *F);
1514 Alignment * expand_aln (Alignment *A);
1515 Alignment * aln2expanded_aln (Alignment *A);
1516 Alignment * expand_number_aln (Alignment *A,Alignment *EA);
1517 Alignment * remove_gap_column ( Alignment *A, char *mode);
1518 Alignment*  ungap_sub_aln        ( Alignment *A, int nseq, int *ls);
1519 Sequence *  ungap_seq       ( Sequence *A);
1520 Alignment * insert_gap_col (Alignment *A, int p, int l);
1521 Alignment * unalign_residues (Alignment *A, int i1, int i2);
1522 Alignment * unalign_aln (Alignment *A, Alignment *C, int t);
1523 Alignment * unalign_aln_pos (Alignment *A, int s, int p, int l);
1524
1525 Alignment *degap_aln (Alignment *A);
1526
1527 Alignment * ungap_aln_n        ( Alignment *A, int n);
1528 Alignment * ungap_aln        ( Alignment *A);
1529 void compress_aln     ( Alignment *A);
1530 Alignment* condense_aln (Alignment *A);
1531
1532 Alignment * probabilistic_rm_aa ( Alignment *A, int pos, int len);
1533 Alignment * aln_gap2random_aa(Alignment *A);
1534 Alignment * make_random_aln(Alignment *A,int nseq, int len, char *alphabet);
1535 Alignment * add_random_sequence2aln( Alignment *A, char *alphabet);
1536
1537 int ** trim_aln_borders            ( char **seq1, char **seq2, int nseq);
1538 Sequence * trim_aln_seq      ( Alignment  *A, Alignment *B);
1539 Sequence * trim_aln_seq_name ( Alignment  *A, Alignment *B);
1540 Sequence *get_defined_residues( Alignment *A);
1541
1542
1543 Alignment *thread_defined_residues_on_aln ( Alignment *A, Sequence *S1);
1544 Sequence *seq2number (Sequence *S);
1545 Sequence * merge_seq    ( Sequence *IN, Sequence *OUT);
1546 char * seq_name2coor ( char *s, int *start, int *end, char sep);
1547 Alignment *seq_name2removed_seq_name(Sequence *S, Alignment *NA, float **diff);
1548 int seq_name2index (char *name, Sequence *S);
1549
1550 Sequence *extract_one_seq(char *n,int start, int end, Alignment *S,int keep_name);
1551 Sequence  * extract_sub_seq( Sequence  *COOR, Sequence *S);
1552
1553
1554 Sequence * add_prf2seq  (char *alnfile, Sequence *S);
1555 int prf_in_seq ( Sequence *S);
1556 Sequence * add_sequence ( Sequence *IN, Sequence *OUT, int i);
1557 Sequence  * trim_seq     ( Sequence   *A, Sequence  *B);
1558 Sequence  * reorder_seq  ( Sequence   *A, char **name, int nseq);
1559 Sequence  * reorder_seq_2  ( Sequence   *A, int **name,int field, int nseq);
1560
1561 char * concatenate_seq ( Sequence *S, char *conc, int *order);
1562 Sequence * swap_header ( Sequence *S, Sequence *H);
1563
1564 Alignment *aln2jacknife (Alignment *A, int nseq, int len);
1565 char ** name2random_subset (char **in_name, int n_in, int n_out);
1566 Alignment * aln2random_order   ( Alignment  *A);
1567 Alignment * aln2scramble_seq  ( Alignment  *A);
1568
1569 Alignment * reorder_aln        ( Alignment  *A, char **name, int nseq);
1570
1571 char ** rm_name_tag (char **name, int nseq, char *tag);
1572
1573 /******************************************************************************/
1574 /*                          TEMPLATE MANAGEMENENT                             */
1575 /******************************************************************************/
1576 char * string_contains_template_tag (char *string);
1577 Sequence * seq2template_type(Sequence *Seq);
1578
1579 Sequence * vremove_seq_template_files (Sequence *S);
1580 Sequence * display_seq_template_files (Sequence *S);
1581 Sequence * handle_seq_template_file (Sequence *S, char *mode);
1582 int handle_X_template_files ( X_template *T, char *mode);
1583
1584
1585 Sequence * seq2template_seq ( Sequence *S, char *template_file, Fname *F);
1586 char * seq2template_file (Sequence *S, char *file);
1587 int seq2template_file2 (Sequence *S, char *file, char *mode);
1588
1589 Sequence * profile_seq2template_seq ( Sequence *S, char *template_file, Fname *F);
1590 int seq2n_X_template ( Sequence *S, char *type);
1591
1592 struct X_template *fill_X_template (char *name, char *p, char *type);
1593 FILE * display_seq_template (Sequence *S, FILE *io);
1594 char *template_type2type_name (char *type);
1595 char *template_type2short_type_name (char *type);
1596
1597
1598 FILE * display_sequence_templates ( Sequence *S, int i, FILE *io);
1599 FILE * display_X_template (struct X_template *X, FILE *io);
1600
1601 struct X_template* free_X_template ( struct X_template *X);
1602
1603 struct X_template *fill_P_template (char *name, char *p, Sequence *S);
1604 struct X_template *fill_F_template (char *name, char *p, Sequence *S);
1605 struct X_template *fill_S_template ( char *name,char *p, Sequence *S);
1606 struct X_template *fill_R_template (char *name, char *p, Sequence *S);
1607 struct X_template *fill_G_template (char *name, char *p, Sequence *S);
1608 struct X_template *fill_T_template (char *name, char *p, Sequence *S);
1609 struct X_template *fill_E_template (char *name, char *p, Sequence *S);
1610 struct X_template *fill_U_template (char *name, char *p, Sequence *S);
1611
1612 char *seq2T_value ( Sequence *S, int i, char *param_name, char *template_type);
1613 char *profile2P_template_file (Sequence *S, int n);
1614 Alignment * seq2R_template_profile (Sequence *S, int n);
1615 char *seq2P_pdb_id (Sequence *S, int n);
1616 char      * seq2P_template_file (Sequence *S, int n);
1617 char      * seq2T_template_string (Sequence *S, int n);
1618 char      * seq2E_template_string (Sequence *S, int n);
1619 int       * seq2U_template (Sequence *S, int n);
1620
1621 struct X_template * seq_has_template ( Sequence *S, int n, char *type);
1622
1623 /******************************************************************************/
1624 /*                          ALIGNMENT MANIPULATION                            */
1625 /******************************************************************************/
1626
1627 char *aln_column2string (Alignment *A, int p);
1628 Alignment * fix_aln_seq  ( Alignment *A, Sequence *S);
1629 Alignment * rotate_aln ( Alignment *A, char *name);
1630 Alignment * invert_aln ( Alignment *A);
1631 char * complement_string (char *s);
1632 Alignment * complement_aln ( Alignment *A);
1633 Alignment * extract_nol_local_aln( Alignment *A, int start, int max_end);
1634 Alignment * aln2block   (Alignment  *A, int start, int end, Alignment *B);
1635 Alignment * alnpos2block   (Alignment  *A, int*pos, Alignment *B);
1636
1637 Alignment * extract_aln          ( Alignment *A, int start, int end);
1638 Alignment * extract_aln2          ( Alignment *A, int start, int end, char *seq_name);
1639 Alignment * extract_aln3          ( Alignment *A, char *filename);
1640 Alignment * alnpos_list2block (Alignment *A, int n, char **in_list);
1641
1642 Alignment * trunkate_local_aln   ( Alignment *A);
1643 int get_nol_aln_border ( Alignment *A, int start, int direction);
1644 Alignment ** trim_local_aln ( Alignment *A, int **List, int ne, int **residue_list, Sequence *S);
1645
1646 Alignment * aln_cat ( Alignment *A, Alignment *B);
1647 Alignment * concatenate_aln ( Alignment *A, Alignment *B, char *sep);
1648 char * extract_defined_seq ( char *in, int in_of, int in_start, int *aa_def, int dir, int *out_start, char *out_seq);
1649 int verify_aln ( Alignment *A, Sequence *S, char * error);
1650 Alignment * remove_end (Alignment *A);
1651
1652 Alignment *adjust_est_aln ( Alignment *PW, Alignment *M, int s);
1653 Alignment * rename_seq_in_aln (Alignment *A, char ***list);
1654 Sequence * rename_seq_in_seq (Sequence *A, char ***list);
1655 /********************************************************************/
1656 /*                                                                  */
1657 /*                   FLOAT SIMILARITIES                             */
1658 /*                                                                  */
1659 /*                                                                  */
1660 /*                                                                  */
1661 /********************************************************************/
1662 float get_seq_fsim ( char *string1, char *string2, char *ignore, char *similarity_groups, int **matrix, int mode);
1663 float get_seq_fsim2 ( char *string1, char *string2, char *ignore, char *in_mode);
1664 float ** get_fsim_aln_array ( Alignment *A, char *mode);
1665 /********************************************************************/
1666 /*                                                                  */
1667 /*                   ALIGNMENT ANALYSES                             */
1668 /*                                                                  */
1669 /*                                                                  */
1670 /*                                                                  */
1671 /********************************************************************/
1672 int **sim_array2dist_array ( int **p, int max);
1673 int **dist_array2sim_array ( int **p, int max);
1674 int **normalize_array (int **p, int max, int norm);
1675
1676 int aln2most_similar_sequence ( Alignment *A, char *mode);
1677 int aln2coverage ( Alignment *A, int ref_seq);
1678
1679 double aln2entropy (Alignment *A, int *in_ls, int in_ns, float gap_threshold);
1680 int sub_aln2sim ( Alignment *A, int *ns, int **ls, char *mode);
1681 int sub_aln2max_sim ( Alignment *A, int *ns, int **ls, char *mode);
1682 int aln2sim     ( Alignment *A, char *mode);
1683 int seq2idscore_sim ( char *seq1, char *seq2);
1684
1685 int aln_is_aligned ( Alignment *A);
1686 int* get_cdna_seq_winsim ( int *cache, char *string1, char *string2, char *ignore, char *mode, int *w);
1687 int  get_cdna_seq_sim    ( int *cache, char *string1, char *string2, char *ignore, char *mode);
1688
1689 int seq2aln2sim    (char *seq1, char *seq2, char *mode_aln, char *mode_id);
1690 int* get_seq_winsim( char *string1, char *string2, char *ignore, char *mode, int *w);
1691 int  get_seq_sim ( char *string1, char *string2, char *ignore, char *mode);
1692 int  get_seq_sim_2 ( char *string1, char *string2, char *ignore, char **gr, int ng);
1693 int  get_seq_sim_3 ( char *string1, char *string2, char *ignore, int **mat);
1694
1695
1696 int *** get_winsim_aln_array ( Alignment *A, char *mode, int ***w);
1697 int ** get_sim_master_aln_array ( Alignment *A,int n, char *mode);
1698
1699 int ** seq2sim_mat (Sequence *S, char *mode);
1700 int ** seq2cov_mat (Sequence *S, char *mode);
1701 int ** seq2comp_mat (Sequence *S, char *mode, char *comp_mode);
1702
1703 int logid_score (int sim, int len);
1704 int ** fast_aln2sim_mat (Alignment *A, char *mode);
1705 int ** fast_aln2sim_list (Alignment *A, char *mode, int *ns, int **ls);
1706
1707 int ** aln2sim_mat (Alignment *A, char *mode); 
1708 int **aln2cov (Alignment *A);
1709 int ** get_dist_aln_array ( Alignment *A, char *mode);
1710 int ** get_raw_sim_aln_array ( Alignment *A, char *mode);
1711 int ** get_sim_aln_array ( Alignment *A, char *mode);
1712 int generic_get_seq_sim  ( char *seq1, char *seq2, int *cache, char *mode);  
1713 Alignment * grep_seq (Alignment *S,char *field, char *mode, char *string);
1714 Alignment* modify_seq (Alignment *S,char *field, char *string1, char *string2);
1715
1716 Sequence * seq2filter (Sequence *S_in, int min, int max);
1717 int ** get_cov_aln_array ( Alignment *A, char *mode);
1718 int ** get_cov_master_aln_array ( Alignment *A,int n, char *mode);
1719
1720
1721 int * get_aln_col_weight ( Alignment *A, char *mode);
1722 int analyse_aln_column   ( Alignment *B, int col);
1723
1724 int sub_aln2nseq_prf ( Alignment *A, int ns, int *ls);
1725 int **aln2count_mat   (Alignment *A);
1726 int **sub_aln2count_mat2   (Alignment *A, int ns, int *ls);
1727 int **sub_aln2count_mat3   (char **al, int n);
1728 int **aln2count_mat2   (Alignment *A);
1729 char *aln2random_seq (Alignment *A, int noise1, int noise2, int noise3, int gap_noise);
1730
1731 Alignment * master_trimseq( Alignment *A, Sequence *S,char *mode);
1732 Alignment * trimseq( Alignment *A, Sequence *S, char *mode);
1733 Alignment *simple_trimseq (Alignment *A,Alignment*K, char *mode, char *seq);
1734 Alignment *sim_filter (Alignment *A, char *in_mode, char *seq_list);
1735
1736 float ** get_weight ( Alignment *A, Sequence *S, char *mode);
1737 float **seq2pwsim (        Alignment *A, Sequence *S, char *mode);
1738 Alignment * trimseq( Alignment *A, Sequence *S,char *mode);
1739 Alignment * tc_trimseq( Alignment *A, Sequence *S,char *mode);
1740 Alignment* seq2subseq3( Alignment *A, Sequence *S,int use_aln, int lower_sim,int upper_sim, int min_nseq, int trim_direction, char *weight_mode, float ***sim_weight, int *seq_list);
1741 Alignment* seq2subseq2( Alignment *A, Sequence *S,int use_aln, int lower_sim,int upper_sim, int max_nseq, int trim_direction, char *weight_mode, float ***weight_table, int *seq_list);
1742 float extreme_seq (int direction, Alignment *A,float **sim_weight,int *seq_list, int *seq_index);
1743
1744
1745 Alignment* seq2subseq1( Alignment *A, Sequence *S,int use_aln, int percent,int max_nseq,int max_diff, char *weight_mode);
1746 /********************************************************************/
1747 /*                                                                  */
1748 /*                      AMINO ACID FUNCTIONS                        */
1749 /*                                                                  */
1750 /*                                                                  */
1751 /*                                                                  */
1752 /********************************************************************/
1753 char** string2alphabet (char *string, int depth, int *falp_size);
1754 int is_in_same_group_aa ( char r1, char r2, int n_group, char **gl, char *mode);
1755 int find_group_aa_distribution (char *col, int nseq,int n_group, char **gl,  int *distrib, char *mode );
1756 char** make_group_aa (int *ngroup, char *mode);
1757 char** make_group_aa_upgma (char *mat, int max_size);
1758
1759
1760 char * test_gene2prot (Constraint_list *CL, int s1);
1761 Alignment* gene2prot (Alignment *A);
1762 Alignment * dna_aln2_3frame_cdna_aln(Alignment *A,int *ns,int **l_s);
1763
1764 int ** get_sim_aln_array_normal_distribution ( Alignment *A, char *mode, int *STD, int *CENTER);
1765 double normal(double x, double mean, double std);
1766 int generic_get_seq_sim_normal_distribution ( char *seq1, char *seq2, int*cache, char *mode, int *STD, int *CENTER);
1767 int get_seq_sim_distribution ( char *string1, char *string2, char *ignore, char *in_mode, int *STD, int *CENTER);
1768
1769 Alignment *aln2clean_pw_aln (Alignment *A,OveralnP *F);
1770 char **pw_aln2clean_pw_aln (char ** aln,OveralnP *F);
1771 int  * pw_aln2clean_aln_weight ( char *seq1, char *seq2, int w, OveralnP *F);
1772
1773 float* aln2pred  ( Alignment *A, Alignment*B, char *mode);
1774 float* analyze_overaln ( Alignment *A, Alignment *B, char *mode, int f,int p1,int p2, int p3,int filter);
1775
1776
1777 Alignment * mark_exon_boundaries  (Alignment *A, Alignment *E);
1778
1779 struct orp
1780 {
1781   char name[100];
1782   char mode[100];
1783   int ncomp;
1784   int nseq;
1785   int len;
1786   
1787   Alignment *A;
1788   Alignment *P;
1789   Alignment *S;
1790   
1791   int *pos;
1792   char ***motif;
1793   float sp;
1794   float sn;
1795   float sen2;
1796   float best;
1797   int tp;
1798   int tn;
1799   int fp;
1800   int fn;
1801
1802   int offset;
1803   float evalue;
1804   struct orp *PR; 
1805 };
1806
1807 typedef struct orp ORP;
1808
1809 typedef Alignment * (*filter_func) (Alignment *, Alignment*, int,int, char *);
1810 /************************************************************************************/
1811 /*                ALIGNMENT ANALYZE     : SAR                                            */
1812 /************************************************************************************/
1813 int display_simple_sar_analyze_pair_col (Alignment *A, Alignment *SAR, char *mode);
1814 int **simple_sar_analyze_pair_col ( Alignment *inA, Alignment *SAR, char *mode);
1815 int ***simple_sar_predict ( Alignment *inA, Alignment *SAR, char *mode);
1816 int display_simple_sar_analyze_col ( Alignment *inA, Alignment *SAR, char *mode);
1817 Alignment *sar_analyze4  (Alignment *A, Alignment *SAR, char *name);/*28/08/06*/
1818 Alignment *sar_analyze3  (Alignment *A, Alignment *SAR, char *name);
1819 Alignment *sar_analyze2  (Alignment *A, Alignment *SAR, char *name);
1820 Alignment *sar_analyze  (Alignment *A, Alignment *SAR, char *name);
1821 int aln2sar_column_list ( Alignment *A, char *filter);
1822 float get_sar_sim (char *seq1, char *seq2);
1823 float get_sar_sim2 (char *seq1, char *seq2);
1824 Alignment *aln2weighted_sar_score ( Alignment *A,Alignment *B, char *weight_file, char *compound);
1825 float seq2weighted_sar_score ( char *seq, int **weight);
1826
1827 int sarset2subsarset ( Alignment *A, Alignment *S, Alignment **subA, Alignment **subS, Alignment *SUB);
1828 int sar2subsar (Alignment *A, Alignment *S, Alignment **subA, Alignment **subS, char **slist, int nl);
1829 int sar2subsar_file ( Alignment *A, Alignment *S, char *aln, char *sar);
1830
1831 Alignment *weight2sar (Alignment *A, Alignment *SAR, char *weight_file, int limit);
1832 Alignment * sar2simpred (Alignment *A, Alignment *SAR, char *pos, char *compound, int L,int U );
1833 Alignment * sar2simpred2 (Alignment *A, Alignment *SAR, char *seqlist, char *posfile, char *compound, int L1 );
1834
1835 Alignment *display_sar ( Alignment *A, Alignment *SAR, char *compound);
1836 NT_node sar2tree (Alignment *A, char *mode);
1837 /************************************************************************************/
1838 /*                ALIGNMENT ANALYZE     : SAR FOR OR                                */
1839 /************************************************************************************/
1840
1841 Alignment * or_scan (Alignment *A, Alignment *B, char *param);
1842 Alignment * or_sar  (Alignment *A, Alignment *B, char *param, int print);
1843 ORP * or_loo ( Alignment *inA, Alignment *inS, char *mode, int *pos,int print);
1844
1845
1846 ORP * combine_n_predictions (ORP **R,Alignment *A, Alignment *B);
1847 ORP* combine_2_predictions ( ORP *IN, ORP *TO,Alignment *A, Alignment *B);
1848 ORP * display_or_summary (ORP *CP, char *mode, FILE *fp, int print);
1849
1850 Alignment * or_comp_loo ( Alignment *inA, Alignment *inS, char *mode, int *pos,int print);
1851 int * or_comp_pos ( Alignment *inA, Alignment *inS, char *mode,int print);
1852 float or_id_evaluate ( Alignment *A, Alignment *S, char *mode, int *pos, int print);
1853 char* or_id_evaluate2  ( Alignment *A, Alignment *S, char *mode, int *pos, int print, float *score);
1854 float or_loo_evaluate ( Alignment *A, Alignment *S, char *mode, int *pos, int print);
1855 float or_loo_evaluate2 ( Alignment *A, Alignment *S, char *mode, int *pos, int print);
1856
1857 Alignment * or_test ( Alignment *inA, Alignment *inS, char *mode);
1858 Alignment * or_jack(Alignment *A, Alignment *S, char *param);
1859 Alignment * or_predict(Alignment *A, Alignment *S, char *mode);
1860 Alignment * or_aln2pos_aln (Alignment *A, Alignment *S, char *mode);
1861 ORP* or_self_predict(Alignment *inA, Alignment *inS, char *mode, int *pos, int print);
1862 Alignment * or_sim(Alignment *A, Alignment *S, char *mode);
1863
1864 Alignment *display_pos (Alignment *A, Alignment *B, int *pos, char *mode);
1865
1866 float evaluate_prediction  (Alignment *R, Alignment *P, char *mode, int print);
1867 ORP* new_evaluate_prediction  (ORP *P, char *mode, int print);
1868
1869 Alignment * aln2prediction (Alignment *A,char ***motif, int *pos);
1870 int *   aln2predictive_positions (Alignment *A, Alignment *B, char *mode, int print);
1871 int *   aln2predictive_positions_mat  (Alignment *A, Alignment *B, char *mode, int print);
1872 int *   aln2predictive_positions_scan (Alignment *A, Alignment *B, char *mode, int print);
1873 char *** compounds2motifs (Alignment *A, Alignment *B, int *pos, int depth, char *mode, int print);
1874 char ** compound2motif (Alignment *A, Alignment *B, int *pos, int depth, int c, char *mode, int print);
1875 double pos2sim (Alignment *A, Alignment *B, int *pos);
1876 double  sar_aln2r (Alignment *A, Alignment *B, int *pos, int print);
1877 double sar_aln2delta (Alignment *A, Alignment *B, int *pos, int print);
1878 Alignment * jack_sar(Alignment *A, Alignment *S, char *param);
1879 Alignment *set_sar (Alignment *A, Alignment *S, char *param);
1880 char * get_compound_name (int c, char *mode);
1881 Alignment *get_prediction_target (Alignment *A, Alignment *S, char *param);
1882 int *   file2pos_list (Alignment *A, char *posfile);
1883 ORP * declare_or_prediction ( int ncomp, int nseq, int len);
1884 void free_orp_list ( ORP**P);
1885 void free_orp ( ORP*P);
1886 double evaluate_sar_score1 ( int len, int n11, int n1a, int n1b);
1887 double evaluate_sar_score2 ( int len, int n11, int n1a, int n1b);
1888
1889 Sequence * compare_sar_sequence( Sequence *S1, Sequence *S2, int depth);
1890 Constraint_list * mask_list_with_aln (Alignment *A,int start, int len,Constraint_list *CL, int new_value);
1891 Constraint_list* mask_list_with_aln_pair (Alignment *A,int start, int end,Constraint_list *CL,int new_value);
1892 Constraint_list *mask_entry( Constraint_list *CL, int p, int new_value);
1893 Constraint_list *prepare_list_and_seq4sw(Constraint_list *I, int n_seq, char **seq_name);
1894 int ** get_undefined_list (Constraint_list *CL);
1895 int      is_never_undefined (Constraint_list *CL,int r);
1896 int* do_analyse_list ( Constraint_list *CL);
1897
1898
1899
1900 void print_list(Constraint_list *CL);
1901 void print_pair (Constraint_list *CL,int p);
1902 int** bin_list (Constraint_list *CL,int field, int Threshold);
1903 void   save_full_list (Constraint_list *CL, char*fname);
1904 FILE * output_list ( Constraint_list *CL, FILE *fp);
1905 FILE * output_pair (Constraint_list *CL,int p, FILE *fp);
1906 NT_node ** seq2cw_tree ( Sequence *S, char *file);
1907 NT_node ** make_nj_tree (  Alignment *A,int **distances,int gop, int gep, char **out_seq, char **out_seq_name, int out_nseq, char *tree_file, char *tree_mode);
1908 NT_node ** make_upgma_tree (  Alignment *A,int **distances,int gop, int gep, char **out_seq, char **out_seq_name, int out_nseq, char *tree_file, char *tree_mode);
1909
1910 NT_node ** int_dist2nj_tree (int **distances, char **out_seq_name, int out_nseq,  char *tree_file);
1911 NT_node ** float_dist2nj_tree (float **distances, char **out_seq_name, int out_nseq,  char *tree_file);
1912 NT_node ** dist2nj_tree (double **distances, char **out_seq_name, int out_nseq,  char *tree_file);
1913
1914 NT_node ** int_dist2upgma_tree (int **mat, Alignment *A, int nseq, char *fname);
1915 NT_node upgma_merge (int **mat, NT_node *NL, int *used, int *n, int N);
1916
1917 void nj_tree(char **tree_description, int nseq);
1918 void fast_nj_tree(char **tree_description);
1919 void slow_nj_tree(char **tree_description);
1920
1921 void print_phylip_tree(char **tree_description, FILE *tree, int bootstrap);
1922 void two_way_split(char **tree_description, FILE *tree, int start_row, int flag, int bootstrap);
1923 void guide_tree(char *fname, double **saga_tmat, char **sag_seq_name, int saga_nseq);
1924
1925
1926
1927 NT_node split2upgma_tree (Split **S, Alignment *A, int nseq, char *fname);
1928 NT_node split_upgma_merge (Alignment *A, Split **S, NT_node *NL, int *used, int *n, int N);
1929 float get_split_dist ( Alignment *A, NT_node L, NT_node R, Split **S) ;
1930
1931 Alignment * upgma_tree_aln  (Alignment*A, int nseq, Constraint_list *CL);
1932 int ** dist_mat2best_split (int **mat, int nseq);
1933 typedef struct Tmpname Tmpname;
1934 struct Memcontrol
1935     {
1936       size_t size;
1937       size_t size_element;
1938       char check[3];
1939       struct Memcontrol *p;
1940       struct Memcontrol *n;
1941     };
1942 typedef struct Memcontrol Memcontrol;
1943 void free_pair_wise();//Frees static memory in the pair_wise functions
1944 /************************************************************************/
1945 /*                                                                      */
1946 /*            CONSTRAINT_LIST                                           */
1947 /*                                                                      */
1948 /*                                                                      */
1949 /************************************************************************/
1950 Constraint_list *free_constraint_list4lib_computation (Constraint_list *CL);
1951 Constraint_list *duplicate_constraint_list4lib_computation (Constraint_list *CL);
1952 Constraint_list * declare_constraint_list_simple ( Sequence *S);
1953 Constraint_list * declare_constraint_list ( Sequence *S, char *name, int *L, int ne,FILE *fp, int **M);
1954 Constraint_list *cache_dp_value4constraint_list ( char mode[],Constraint_list *CL);
1955 Constraint_list *duplicate_constraint_list_soft (Constraint_list *CL);
1956 Constraint_list *duplicate_constraint_list      (Constraint_list *CL);
1957 Constraint_list *copy_constraint_list      (Constraint_list *CL, int mode);
1958 Sequence        * free_constraint_list (Constraint_list *CL);
1959 Constraint_list * free_constraint_list_full (Constraint_list *CL);
1960 Distance_matrix * free_distance_matrix ( Distance_matrix *DM);
1961 Distance_matrix * duplicate_distance_matrix ( Distance_matrix *DMin);
1962 /************************************************************************/
1963 /*                                                                      */
1964 /*            Blast_param Functions                                            */
1965 /*                                                                      */
1966 /*                                                                      */
1967 /************************************************************************/
1968 Blast_param * duplicate_blast_param ( Blast_param*B);
1969 Blast_param * free_blast_param ( Blast_param*B);
1970 /************************************************************************/
1971 /*                                                                      */
1972 /*            TC_param Functions                                            */
1973 /*                                                                      */
1974 /*                                                                      */
1975 /************************************************************************/
1976 TC_param * duplicate_TC_param ( TC_param*B);
1977 TC_param * free_TC_param ( TC_param*B);
1978 /************************************************************************/
1979 /*                                                                      */
1980 /*            MOCA Functions                                            */
1981 /*                                                                      */
1982 /*                                                                      */
1983 /************************************************************************/
1984 Moca * duplicate_moca ( Moca *m);
1985 Moca * free_moca ( Moca *m);
1986 /************************************************************************/
1987 /*                                                                      */
1988 /*            PDB Functions                                             */
1989 /*                                                                      */
1990 /*                                                                      */
1991 /************************************************************************/
1992 Structure       * declare_structure ( int n, char **array);
1993 Structure       * extend_structure ( Structure *S);
1994 /************************************************************************/
1995 /*                                                                      */
1996 /*            Weights Functions                                         */
1997 /*                                                                      */
1998 /*                                                                      */
1999 /************************************************************************/
2000 Weights* declare_weights ( int nseq);
2001 Weights* duplicate_weights (Weights *W);
2002 Weights* free_weights ( Weights* W);
2003
2004 FILE* print_mem_usage (FILE *fp, char *comment);
2005 void set_max_mem (int m);
2006 int verify_memory (int s);
2007 int my_assert ( void *p, int index);
2008
2009 void * vmalloc ( size_t size);
2010 void * vcalloc ( size_t nobj, size_t size);
2011 void * vcalloc_nomemset ( size_t nobj, size_t size);
2012 void * sub_vcalloc ( size_t nobj, size_t size, int MODE);
2013
2014 void * vrealloc ( void *p, size_t size);
2015 void   vfree2 ( void **p);
2016 void   vfree ( void *p);
2017 void * free_arrayN (void *p, int ndim);
2018 void   vfree_all ();
2019 /*********************************************************************/
2020 /*                                                                   */
2021 /*                          SIZES                                    */
2022 /*                                                                   */
2023 /*                                                                   */
2024 /*********************************************************************/
2025 void write_size_short (int x, short  *array, int offset);
2026 void write_size_char  (int x, char   *array, int offset);
2027 void write_size_int   (int x, int    *array, int offset);
2028 void write_size_float (int x, float  *array, int offset);
2029 void write_size_double(int x, double *array, int offset);
2030
2031 int read_size_short ( void  *array, size_t size  );
2032 int read_size_char  ( void  *array, size_t size );
2033 int read_size_int   ( void  *array, size_t size );
2034 int read_size_float ( void  *array, size_t size );
2035 int read_size_double( void  *array, size_t size );
2036 int read_array_size_new ( void  *array);
2037 int read_array_size ( void  *array, size_t size );
2038 int read_array_new ( void  *array);
2039 int is_dynamic_memory ( void *array);
2040
2041 /*********************************************************************/
2042 /*                                                                   */
2043 /*                          REALLOCATION                             */
2044 /*                                                                   */
2045 /*                                                                   */
2046 /*********************************************************************/
2047 void **realloc_arrayN(int ndim,void **main_array,size_t size, ...);
2048 void **realloc_arrayN2 ( int ndim, void ** p, int *A, size_t size);
2049
2050
2051 void ** realloc_array (void **array,size_t size, int first, int second, int ext1, int ext2);
2052 short     ** realloc_short     ( short     **array, int first, int second, int ext1, int ext2);
2053 char      ** realloc_char      ( char      **array, int first, int second, int ext1, int ext2);
2054 int       ** realloc_int       ( int       **array, int first, int second, int ext1, int ext2);
2055 float     ** realloc_float     ( float     **array, int first, int second, int ext1, int ext2);
2056 double    ** realloc_double    ( double    **array, int first, int second, int ext1, int ext2);
2057 Alignment ** realloc_aln_array ( Alignment **array, int ext1);
2058 /*The new realloc is recommended*/
2059 short     ** new_realloc_short     ( short     **array, int ext1, int ext2);
2060 char      ** new_realloc_char      ( char      **array, int ext1, int ext2);
2061 int       ** new_realloc_int       ( int       **array, int ext1, int ext2);
2062 float     ** new_realloc_float     ( float     **array, int ext1, int ext2);
2063 double    ** new_realloc_double    ( double    **array, int ext1, int ext2);
2064
2065
2066 void * declare_arrayNnomemset (int ndim, size_t size, ...);
2067 void *declare_arrayN2nomemset ( int ndim, int *A, size_t size);
2068
2069 void * declare_arrayN (int ndim, size_t size, ...);
2070 void *declare_arrayN2 ( int ndim, int *A, size_t size);
2071
2072
2073 void      ** declare_array     (int first, int second, size_t size);
2074 short     ** declare_short     ( int first, int second);
2075 char      ** declare_char      ( int first, int second);
2076 int       ** declare_int       ( int first, int second);
2077 float     ** declare_float     ( int first, int second);
2078 double    ** declare_double    ( int first, int second);
2079
2080 void      ** declare_array_nomemset     (int first, int second, size_t size);
2081 short     ** declare_short_nomemset      ( int first, int second);
2082 char      ** declare_char_nomemset       ( int first, int second);
2083 int       ** declare_int_nomemset        ( int first, int second);
2084 float     ** declare_float_nomemset      ( int first, int second);
2085 double    ** declare_double_nomemset     ( int first, int second);
2086
2087
2088 Alignment ** declare_aln_array ( int first);
2089
2090 short     **  free_short    ( short     **array, int first);
2091 int       **  free_int      ( int       **array, int first);
2092 char      **  free_char     ( char      **array, int first);
2093 double    ** free_double    ( double    **array, int first);
2094 float     ** free_float     ( float     **array, int first);
2095 Alignment ** free_aln_array ( Alignment **array);
2096
2097 long aln_stack (Alignment *A, int mode);
2098 Sequence  *free_Alignment     ( Alignment *A);
2099 Sequence  *free_aln     ( Alignment *A);
2100 Alignment *declare_Alignment  ( Sequence  *S);
2101 Alignment *realloc_alignment  ( Alignment *A, int new_len);
2102 Alignment *realloc_alignment2 ( Alignment *A, int new_nseq, int new_len);
2103
2104 Alignment *declare_aln  ( Sequence  *S);
2105 Alignment *declare_aln2 (int nseq, int len);
2106 Alignment *realloc_aln  ( Alignment *A, int new_len);
2107 Alignment *realloc_aln2 ( Alignment *A, int new_nseq, int new_len);
2108 Alignment *update_aln_random_tag (Alignment *A);
2109
2110 Alignment *copy_aln ( Alignment *A, Alignment *B);
2111 Alignment* extract_sub_aln2 ( Alignment *A, int nseq, char **list);
2112 Alignment* extract_sub_aln ( Alignment *A, int nseq, int *list);
2113 Alignment* shrink_aln      ( Alignment *A, int nseq, int *list);
2114
2115 Profile   *copy_profile   (Profile *P1);
2116 Profile   *declare_profile(char *alphabet, int len);
2117 Profile * free_profile ( Profile *P);
2118
2119 Sequence  * declare_sequence ( int min, int max, int nseq);
2120 Sequence * realloc_sequence   (Sequence *OUT, int new_nseq, int max_len);
2121 Sequence * duplicate_sequence (Sequence *S );
2122 Sequence * add_sequence ( Sequence *IN, Sequence *OUT, int i);
2123 void free_sequence ( Sequence *LS, int nseq);
2124
2125
2126
2127 Fname *declare_fname ();
2128 Fname *free_fname ( Fname *F);
2129 /*********************************************************************************************/
2130 /*                                                                                           */
2131 /*         STRUCTURES FOR HSEARCH                                                            */
2132 /*                                                                                           */
2133 /*********************************************************************************************/
2134 #define FIND           0
2135 #define ADD            1
2136 #define REMOVE         2
2137 #define DECLARE        3
2138 #define MARK           4
2139 #define UNMARK         5
2140 #define FREE           6
2141 #define FREE_STACK     7
2142 #define FREE_ALL       8
2143 #define FREE_MARK      9
2144 #define INFO           10
2145      
2146 struct HaschT
2147 {
2148   int ne;
2149   struct Hasch_entry **p;
2150 };
2151 typedef struct HaschT HaschT;
2152
2153 struct Hasch_entry
2154 {
2155   struct Hasch_entry *n;
2156   struct Hasch_entry *p;
2157   int k;
2158   struct Hasch_data  *data;
2159   struct Hasch_data * (*free_data)(struct Hasch_data *); 
2160   struct Hasch_data * (*declare_data)(struct Hasch_entry*);
2161   int tag;
2162 };
2163 typedef struct Hasch_entry Hasch_entry;
2164 struct Char_node
2165 {
2166  struct Char_node **c;
2167  int key;
2168  
2169 };
2170 typedef struct Char_node Char_node;
2171
2172 HaschT * hcreate ( int n_elements,struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2173 HaschT *hdestroy (HaschT *T,struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2174 Hasch_entry* hsearch (HaschT *T, int k, int action, struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2175 Hasch_entry * extract_hasch_entry_from_list (Hasch_entry *e, struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2176 Hasch_entry * insert_hasch_entry_in_list (Hasch_entry *p, Hasch_entry *e, Hasch_entry *n, struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2177 Hasch_entry * allocate_hasch_entry (Hasch_entry *e, int action,struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) );
2178
2179
2180
2181
2182  
2183 int string2key (char *s, Char_node *n);
2184 Char_node * declare_char_node (int action);
2185 char * process_repeat (char *aln, char *seq, char *pdb);
2186 char     * normalize_pdb_file  (char *name, char *seq,char *out_file);
2187 Ca_trace * trim_ca_trace (Ca_trace *st, char *seq );
2188
2189 Ca_trace * read_ca_trace (char *file, char *seq_field );
2190 Ca_trace * simple_read_ca_trace (char *file );
2191 Ca_trace * hasch_ca_trace             ( Ca_trace *T);
2192 Ca_trace * hasch_ca_trace_nb          ( Ca_trace *T);
2193 Ca_trace * hasch_ca_trace_bubble      ( Ca_trace *T);
2194 Ca_trace * hasch_ca_trace_transversal ( Ca_trace *TRACE);
2195
2196 float get_atomic_distance ( Atom *A, Atom*B);
2197 float ** measure_ca_distances(Ca_trace *T);
2198
2199 float** print_contacts ( char  *file1, char *file2, float T);
2200 char *  map_contacts ( char  *file1, char *file2, float T);
2201 int * identify_contacts (Ca_trace *ST1,Ca_trace *ST2, float T);
2202 Sequence *seq2contacts ( Sequence *S, float T);
2203 char *string2contacts (char *seq,char *name,char *comment, float T);
2204 char **struc2nb (char *name,char *seq, char *comment, float Threshold, char *atom_list, char *output);
2205 char **struclist2nb (char *name,char *seq, char *comment, float Threshold, char *atom_list, char *output);
2206
2207 typedef struct
2208 {   Alignment *A;
2209     Alignment *B;
2210     Alignment *sim_A;
2211     Sequence  *S;
2212     Structure *ST;
2213 /*PARAMETERS*/
2214     char ***grep_list;
2215     int n_greps;
2216
2217     char *sim_aln;
2218     char *alignment1_file;
2219     char *alignment2_file;
2220     
2221     char *io_format;
2222
2223     int n_structure;
2224     char **struct_file;
2225     char **struct_format;
2226     int *n_symbol;
2227     char ***symbol_list;
2228
2229 /*LIST VARIABLES*/
2230     int **code_A;
2231     int **code_B;
2232     int n_elementsA;
2233     int n_elementsB;
2234     
2235     int **end_index;
2236     int **start_index;
2237 /*RESULTS_VARIABLES*/
2238     int **tot_count;
2239     int **pos_count;
2240     int ***pw_tot_count;
2241     int ***pw_pos_count;
2242     int *glob;
2243     int **pw_glob;
2244 /*IO VARIABLES*/
2245     int n_categories;
2246     char ***category;
2247     char *category_list;
2248     int *n_sub_categories;
2249     char sep_l;
2250     char sep_r;
2251 /*Sims VARIABLES*/
2252     float **sim;
2253     float **sim_param;
2254     char *sim_matrix;
2255     
2256     int sim_n_categories;
2257     char ***sim_category;
2258     char *sim_category_list;
2259     int *sim_n_sub_categories;
2260 }Result;
2261
2262
2263 #define MAX_N_CATEGORIES 100
2264 #define MAX_N_STRUC      100
2265     
2266
2267     
2268
2269 int aln_compare (int argc, char *argv[]);
2270 int **analyse_distance ( Alignment *A, int **dis);
2271
2272 Structure * read_structure (char *fname, char *format, Alignment *A,Alignment *B, Structure *ST, int n_symbols, char **symbol_table);
2273
2274
2275 int is_in_struct_category ( int s1, int s2, int r1, int r2, Structure *ST, char **cat, int n_sub_cat);
2276 char * get_structure_residue (int s, int r, Structure *S);
2277 int parse_category_list ( char *category_list, char ***category, int *sub_n_categories);
2278 int struc_matches_pattern ( char *struc, char *pattern);
2279 float **get_aln_compare_sim ( Alignment *A, Structure *S, char **cat, int n_cat, char *matrix);
2280 float **analyse_sim ( Alignment *A, float **dis);
2281
2282 /*Output*/
2283 FILE *output_format (char *iof, FILE *fp, Result *R);
2284 FILE *output_pair_wise_sequence_results (FILE *fp,  Result *R);
2285 FILE *output_sequence_results (FILE *fp,  Result *R);
2286 FILE *output_total_results (FILE *fp,  Result *R);
2287 FILE *output_header (FILE *fp, Result *R);
2288 FILE *output_large_header ( FILE *fp, Result *R);
2289
2290 /*Parameter Checking*/
2291 int is_a_struc_format (char *format);
2292 void get_separating_char ( char s, char *l, char *r);
2293 void output_informations ();
2294
2295 int check_configuration4program();
2296 typedef struct
2297     {
2298       Alignment *A;
2299       Weights *W;
2300       Sequence *S;
2301       int **M;
2302       Structure *RNA_ST;
2303       NT_node T;
2304       Constraint_list *CL;
2305       char format[100];
2306       char file[100];
2307       int rm_gap;
2308       
2309 }Sequence_data_struc;
2310
2311 typedef struct
2312     {
2313         char **symbol_list;
2314         int n_symbol;
2315         char *coor_file;
2316         int rm_gap;
2317         int keep_case;
2318         int keep_name;
2319         int use_consensus;
2320 }Action_data_struc;
2321
2322 /*Control of alignment sizes*/
2323 int  set_landscape_msa (int len);
2324 int get_msa_line_length (int line, int aln_len);
2325
2326 int seq_reformat (int argc, char **argv);
2327
2328 Sequence_data_struc *read_data_structure ( char *in_format, char *in_file,Action_data_struc *RAD); 
2329 Alignment * main_read_aln ( char *name, Alignment *A);
2330 Sequence  * read_sequences ( char *name);
2331 Sequence  * read_alifold   ( char *name);
2332 Alignment *alifold2aln     ( char *name);
2333 Sequence  * main_read_seq ( char *mname);
2334 int output_format_aln ( char *format, Alignment *A, Alignment *EA,char *name);
2335 int main_output   ( Sequence_data_struc *D1, Sequence_data_struc *D2, Sequence_data_struc *DST, char *out_format, char *out_file);
2336
2337 char * identify_seq_format ( char *file);
2338 char * name2type_name ( char *name);
2339 char identify_format (char **fname);
2340 char **identify_list_format ( char **list, int n);
2341
2342 int type_is_exon_boundaries(char **seq, int n);
2343
2344 int format_is_oligo  ( char *file);
2345 int format_is_msf  ( char *file);
2346 int format_is_fasta( char *file);
2347 int format_is_fasta_aln( char *file);
2348 int format_is_fasta_seq( char *file);
2349 int is_pir_name (char *name);
2350 int format_is_pir  ( char *file);
2351 int format_is_pir_aln( char *file);
2352 int format_is_pir_seq( char *file);
2353 int pir_name (char *name);
2354 int format_is_conc_aln (char *file);
2355 int format_is_saga  ( char *file);
2356 int format_is_swissprot (char *name);
2357
2358 int is_seq ( char *name);
2359 int is_aln ( char *name);
2360 int has_pdb (char *name);
2361 int is_stockhom_aln ( char *name);
2362 int is_blast_file (char *name);
2363 int is_sap_file (char *name);
2364 int is_pdb_file ( char *name);
2365 int is_simple_pdb_file ( char *name);
2366 char *fix_pdb_file (char *name);
2367
2368 int is_pdb_name ( char *name);
2369 char* get_pdb_id(char *name);
2370 char* get_pdb_struc(char *name, int start, int end);
2371 char*  seq_is_pdb_struc ( Sequence *S, int i);
2372 char* is_pdb_struc ( char *name); /*Returns NULL if not a PDB structure Or a the name of a file containing a PDB structure*/
2373 int is_matrix (char *name);
2374
2375 int is_lib (char *name);
2376 int is_lib_01 (char *name);
2377 int is_lib_02 (char *name);
2378 int is_lib_list ( char *name);
2379 int is_single_seq_weight_file (char *fname);
2380 int is_newick (char *name);
2381
2382 int is_method ( char *file);
2383
2384 char *format_name2aln_format_name (char *name);
2385 int is_in_format_list ( char *name);
2386 int is_out_format_list ( char *name);
2387 int is_struc_in_format_list ( char *name);
2388 int is_struc_out_format_list ( char *name);
2389 /*******************************************************************************************/
2390 /*                                                                                         */
2391 /*                                                                                         */
2392 /*                               INPUT MISC                                               */
2393 /*                                                                                         */
2394 /***************************************************************************************** */
2395
2396 char *** read_rename_file ( char *fname, int mode);
2397 void get_barton_list_tc_seq ( char *in_file);
2398 int process_barton_entry (char *buf, char *name);  
2399
2400 Structure *read_rna_struc_number ( Alignment *A, char *fname);
2401 char ** read_lib_list (char *name, int *n);
2402 /*******************************************************************************************/
2403 /*                                                                                         */
2404 /*                                                                                         */
2405 /*                               INPUT WEIGHTS                                             */
2406 /*                                                                                         */
2407 /***************************************************************************************** */
2408 Weights* get_amps_sd_scores ( char *fname);
2409 Weights *read_seq_weight (char **name, int nseq, char* seq_weight);
2410 /*******************************************************************************************/
2411 /*                                                                                         */
2412 /*                                                                                         */
2413 /*                               INPUT SEQUENCES                                            */
2414 /*                                                                                         */
2415 /***************************************************************************************** */
2416 char ***read_group ( char *file);
2417 Sequence* get_pdb_sequence           ( char *fname);
2418 Sequence* get_struc_gor              ( char *fname);
2419 Sequence* get_dialign_sequence       ( char *fname);
2420 Sequence* get_pima_sequence          ( char *fname);
2421 Sequence* get_sequence_dali          ( char *fname);
2422 Sequence* get_pir_sequence           ( char *fname, char *comment_name);
2423 Sequence* perl_reformat2fasta        ( char *perl_script, char *file);
2424
2425 Sequence* get_fasta_tree             ( char *fname, char *comment_name);
2426 Sequence* get_fasta_sequence         ( char *fname, char *comment_name);
2427 Sequence* get_fasta_sequence_num     ( char *fname, char *comment_name);
2428 Sequence* get_fasta_sequence_raw     ( char *fname, char *comment_name);
2429 Sequence *get_file_list ( char *fname);
2430 Sequence *get_tree_file_list ( char *fname);
2431
2432 Sequence* get_gor_sequence           ( char *fname, char *comment_name);
2433 Sequence* get_swissprot_sequence     ( char *fname, char *comment_name);
2434 int  fscanf_seq_name ( FILE *fp, char *sname);
2435
2436 void read_check ( Alignment *A, char *check_file);
2437 void read_stockholm_aln ( char *fname, Alignment *A);
2438 void read_aln ( char *fname, Alignment *A);
2439 void read_number_aln ( char *fname, Alignment *A);
2440 Alignment *read_blast_aln  ( char *fname, Alignment *A);
2441 void read_msf_aln ( char *fname, Alignment *A);
2442 void read_amps_aln ( char *in_file, Alignment *A);
2443 int get_amps_seq_name ( char **name, char* fname);
2444 Alignment *read_gotoh_aln ( char *fname, Alignment *A);
2445
2446 void undump_msa ( Alignment *A, char *tmp);
2447 void dump_msa ( char *file,Alignment *A, int nseq, int *lseq);
2448 /*******************************************************************************************/
2449 /*                                                                                         */
2450 /*                                                                                         */
2451 /*                               OUTPUT MATRICES                                           */
2452 /*                                                                                         */
2453 /***************************************************************************************** */
2454 int output_freq_mat ( char *outfile, Alignment *A);
2455 /*******************************************************************************************/
2456 /*                                                                                         */
2457 /*                                                                                         */
2458 /*                               OUTPUT P-Values                                           */
2459 /*                                                                                         */
2460 /***************************************************************************************** */   
2461 float output_maln_pval ( char *outfile, Alignment *A);
2462 /*******************************************************************************************/
2463 /*                                                                                         */
2464 /*                                                                                         */
2465 /*                               OUTPUT WEIGHTS                                            */
2466 /*                                                                                         */
2467 /***************************************************************************************** */
2468 void  output_similarities (char *file, Alignment *A, char *mode);
2469 void  output_similarities_pw (char *file, Alignment *A, Alignment *B, char *mode);
2470 Alignment * similarities_file2aln ( char *file);
2471 int** input_similarities (char *file, Alignment *A, char *mode);
2472
2473 void output_statistics (char *file, Alignment *A, char *mode);
2474 void output_pw_weights4saga ( Weights *W, float **w_list, char *wfile);
2475 int  output_seq_weights ( Weights *W, char *wfile);
2476 FILE * display_weights (Weights *W, FILE *fp);
2477 /*******************************************************************************************/
2478 /*                                                                                         */
2479 /*                                                                                         */
2480 /*                               OUTPUT SEQ                                                */
2481 /*                                                                                         */
2482 /***************************************************************************************** */
2483 char** clean_seq_names (char **names, int n, int mode);
2484 char *clean_seq_name (char *name, int mode);
2485
2486
2487 void output_pir_seq1 (char *fname, Alignment*A );
2488 void output_pir_seq (char *fname, Alignment*A );
2489 void output_gor_seq (char *fname, Alignment*A );
2490 void output_mult_fasta_seq (char *fname, Alignment*A, int n );
2491
2492 void main_output_fasta_seq ( char *fname, Alignment *A, int header);
2493 void output_fasta_tree ( char *fname, Alignment *A);
2494
2495 void output_fasta_seq1 (char *fname, Alignment*A );
2496 char *output_fasta_seqX (char *name, char *mode, Sequence *S, Alignment *A, int i);
2497
2498 void output_pir_check (char *fname,int nseq, char **A );
2499 void output_fasta_seq (char *fname, Alignment*A );
2500 void output_gotoh_seq (char *fname, Alignment*A );
2501 void output_est_prf   (char *fname, Alignment *A);
2502 void output_gor_seq (char *fname, Alignment*A );
2503 /*******************************************************************************************/
2504 /*                                                                                         */
2505 /*                                                                                         */
2506 /*                               OUTPUT ALN                                                */
2507 /*                                                                                         */
2508 /***************************************************************************************** */
2509 void output_pir_aln    ( char *fname,Alignment*A);
2510 void output_model_aln  ( char *fname,Alignment*A );
2511 char * output_fasta_sub_aln (char *fname, Alignment*A, int ns, int *ls  );
2512 char * output_fasta_sub_aln2 (char *fname, Alignment*A, int *ns, int **ls  );
2513
2514 void ouput_suchard_aln ( char *fname,Alignment*A);
2515 void output_fasta_aln  ( char *fname,Alignment*A);
2516 void output_msf_aln    ( char *fname,Alignment*B);
2517 FILE * output_generic_interleaved_aln (FILE *fp, Alignment *B, int line, char gap, char *mode);
2518 void output_stockholm_aln (char *file, Alignment *A, Alignment *ST);
2519 void output_clustal_aln( char *name, Alignment*B);
2520 void output_strict_clustal_aln( char *name, Alignment*B);
2521 void output_generic_clustal_aln( char *name, Alignment*B, char *format);
2522 void output_saga_aln   ( char *name, Alignment*B);
2523 void output_phylip_aln ( char *name, Alignment*B);
2524 void output_mocca_aln  ( char *name, Alignment*B,Alignment*S);
2525 void output_rnalign    (char *out_file, Alignment*A,Sequence *STRUC);
2526 void output_pw_lib_saga_aln (char *lib_name, Alignment *A );
2527 void output_lib        (char *lib_name, Alignment *A );
2528 void output_compact_aln( char *name, Alignment *B);
2529
2530 void print_sub_aln ( Alignment *B, int *ns, int **ls);
2531 void print_aln ( Alignment *B);
2532 FILE * output_aln( Alignment *B, FILE *fp);
2533
2534
2535 FILE * output_aln_score ( Alignment *B, FILE *fp);
2536 FILE * output_aln_with_res_number ( Alignment *B, FILE *fp);
2537
2538
2539 FILE* output_Alignment ( Alignment *B, FILE *fp);
2540 FILE* output_Alignment_without_header ( Alignment *B, FILE *fp);
2541 FILE * output_Alignment_score ( Alignment *B, FILE *fp);
2542 FILE * output_Alignment_with_res_number ( Alignment *B, FILE *fp);
2543 void output_constraints ( char *fname, char *mode, Alignment *A);
2544
2545 Alignment *input_conc_aln ( char *name, Alignment *A);
2546 void output_conc_aln ( char *name, Alignment *B);
2547 void output_glalign       ( char *name, Alignment *B, Alignment *S);
2548 void output_lalign_header( char *name, Alignment *B);
2549 void output_lalign       ( char *name, Alignment *B);
2550 void output_lalign_aln   ( char *name, Alignment *B);
2551
2552 /**************************************************************************************************/
2553 /*                                                                                                */
2554 /*                                                                                                */
2555 /*                               INPUT/OUTPUT MATRICES                                                  */
2556 /*                                                                                                */
2557 /**************************************************************************************************/
2558 int is_blast_matrix (char *fname);
2559 int is_pavie_matrix (char *fname);
2560 int is_clustalw_matrix (char *fname);
2561
2562 int is_distance_matrix_file (char *name);
2563 int is_similarity_matrix_file (char *name);
2564
2565 void aln2mat (Sequence *S);
2566 void aln2mat_diaa (Sequence *S);
2567 int **seq2latmat ( Sequence *S, char *fname);
2568 int output_mat (int **mat, char *fname, char *alp, int offset);
2569 int ** read_blast_matrix ( char *mat_name);
2570 int output_blast_mat (int **mat, char *fname);
2571 double* mat2cmp (int **mat1, int **mat2);
2572
2573 void output_pavie_mat (int **mat, char *fname, double gep, char *alp);
2574 int ** read_pavie_matrix ( char *mat_name);
2575
2576 /****************************************************************************************************/
2577 /***************************                                    *************************************/
2578 /***************************             PROCESSING             *************************************/
2579 /***************************                                    *************************************/
2580 /*******************************************************************************************/
2581 /*                                                                                         */
2582 /*                                                                                         */
2583 /*                              THREADING                                                  */
2584 /***************************************************************************************** */
2585
2586
2587
2588
2589 Structure * declare_rna_structure_num (Sequence *SA);
2590
2591 char *thread_aa_seq_on_dna_seq( char *s);
2592 void thread_seq_struc2aln ( Alignment *A, Sequence *ST);
2593 Alignment *thread_dnaseq_on_prot_aln (Sequence *S, Alignment *A);
2594 void cache_id ( Alignment *A);
2595
2596
2597
2598 int process_est_sequence ( Sequence *S, int *cluster_list);
2599 char * invert_seq ( char *seq);
2600 int get_best_match ( char *seq1, char *seq2);
2601 int** extract_m_diag_streches ( int ** m, int l1, int l2,char *seq1, char *seq2, int *n_mdiag);
2602 int is_strech ( char *AA, char *seq1, char *seq2, int len, int x, int y);
2603
2604 int search_for_cluster ( int seq, int cluster_number, int *cluster_list, int T, int nseq, int **S);     
2605 int * SHC ( int nseq, int **NST, int **ST);
2606 int mutate_sol (int *sol, int nseq);
2607 int evaluate_sol ( int*sol, int nseq, int **ST, int **NST);     
2608
2609
2610
2611 char **make_symbols ( char *name, int *n);
2612 Alignment *code_dna_aln (Alignment *A);
2613 char* back_translate_dna_codon ( char aa, int deterministic);
2614 int translate_dna_codon ( char *seq, char stop);
2615 char* mutate_amino_acid ( char aa, char *mode);
2616 Alignment * mutate_aln ( Alignment *A, char *r);
2617
2618
2619 Sequence * transform_sequence ( Sequence *S, char *mode);
2620 Alignment *translate_splice_dna_aln (Alignment *A,Alignment *ST );
2621 Alignment * mutate_cdna_aln ( Alignment *A);
2622
2623 char * translate_dna_seq_on3frame (  char *dna_seq, char stop, char *prot);
2624 char * translate_dna_seq ( char *dna_seq, int frame, char stop, char *prot);
2625
2626 char * back_translate_dna_seq ( char *in_seq,char *out_seq, int mode);     
2627 Alignment *back_translate_dna_aln (Alignment *A);
2628 Alignment *translate_dna_aln (Alignment *A, int frame);
2629 Alignment *clean_gdna_aln (Alignment *A);
2630 Alignment *clean_cdna_aln (Alignment *A);
2631 Alignment *clean_est      (Alignment *A);
2632 /**************************************************************************************************/
2633 /********************************                      ********************************************/
2634 /********************************    PROCESSING        ********************************************/
2635 /*************** ****************                      ********************************************/
2636 void modify_data  (Sequence_data_struc *D1, Sequence_data_struc *D2, Sequence_data_struc *DST, char **action_list,int n_actions, Action_data_struc *RAD);
2637    
2638 //
2639 // Name MAnipulation
2640 //
2641
2642 Alignment *clean_aln (Alignment *A);
2643 Sequence *clean_sequence ( Sequence *S);
2644 char ** translate_names (int n, char **name);
2645 char * translate_name ( char *name);
2646 char *decode_name (char *name, int mode);
2647 FILE * display_sequences_names (Sequence *S, FILE *fp, int check_pdb_status, int print_templates);
2648 Sequence *add_file2file_list (char *name, Sequence *S);
2649 /*********************************COPYRIGHT NOTICE**********************************/
2650 /*© Centro de Regulacio Genomica */
2651 /*and */
2652 /*Cedric Notredame */
2653 /*Tue Oct 27 10:12:26 WEST 2009. */
2654 /*All rights reserved.*/
2655 /*This file is part of T-COFFEE.*/
2656 /**/
2657 /*    T-COFFEE is free software; you can redistribute it and/or modify*/
2658 /*    it under the terms of the GNU General Public License as published by*/
2659 /*    the Free Software Foundation; either version 2 of the License, or*/
2660 /*    (at your option) any later version.*/
2661 /**/
2662 /*    T-COFFEE is distributed in the hope that it will be useful,*/
2663 /*    but WITHOUT ANY WARRANTY; without even the implied warranty of*/
2664 /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*/
2665 /*    GNU General Public License for more details.*/
2666 /**/
2667 /*    You should have received a copy of the GNU General Public License*/
2668 /*    along with Foobar; if not, write to the Free Software*/
2669 /*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
2670 /*...............................................                                                                                      |*/
2671 /*  If you need some more information*/
2672 /*  cedric.notredame@europe.com*/
2673 /*...............................................                                                                                                                                     |*/
2674 /**/
2675 /**/
2676 /*      */
2677 /*********************************COPYRIGHT NOTICE**********************************/