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