ab60176ef469e20f6baf41b0974b1d3134401862
[jabaws.git] / binaries / src / tcoffee / t_coffee_source / fastal_lib_header.h
1
2
3 #define ENLARGEMENT_PER_STEP 50
4 #define PROFILE_ENLARGEMENT 550
5
6 // static char pos2aa[] = {'A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'};
7
8
9 /**
10  * \brief Struct to save all informations of a profile.
11  * 
12  */
13 typedef struct
14 {
15         /// Number of sequences in this profile
16         int num_sequences;
17         /// number of the profile
18         int prf_number;
19         ///0 = combination of two profiles, 1 = profile of a single sequence -> name1 = seq_name
20         int is_leaf;
21         ///length of the profile
22         int length;
23         ///weight of the sequence
24         int weight;
25         ///saves the amount of allocated memory
26         int allocated_memory;   
27         ///the profile itself [alphabet_size][profile_length]
28         int **prf;
29 }
30 Fastal_profile;
31
32 /**
33  * \brief Struct to save all parameters for fastal.
34  * 
35  */
36 typedef struct
37 {
38         /// size of alphabet_size
39         int alphabet_size;
40         /// converting char2position (for profile)
41         int char2pos[26];
42         /// converting pos2char (for profile)
43         char pos2char[26];
44         /// gap opening costs
45         int gop;
46         /// gap extension costs
47         int gep;
48         /// nomatch???
49         int nomatch;
50         ///method to align profile
51         char method[20];
52         ///scoring Matrix;
53         int **M;
54 }
55 Fastal_param;
56
57
58
59 //tree
60 void generate_random_tree(int number);
61
62
63 Fastal_profile* make_profile_of_sequence(char *seq_name, char *sequence, int number);
64
65
66
67 //Definite use
68
69 //*********************    input/output    **********************************
70 void file2profile(FILE* profile_f, Fastal_profile *profile, int prf_number, Fastal_param *param_set);
71 void file_pos2profile(FILE *seq_file, long off_set, Fastal_profile *profile, int prf_number, Fastal_param *param_set);
72 void profile2file(Fastal_profile *profile, FILE* prf_f, Fastal_param *param_set);
73
74 //index
75 int make_index_of_file(char *file_name, long **result);
76
77
78 //*********************    pairwise alignment methods     ************************
79
80         //Needleman-Wunsch
81         int prf_nw(Fastal_profile *profile1, Fastal_profile *profile2, double **prog_matrix, FILE *edit_file_name, int **sumup_prf, int *sumup_length, Fastal_param *param_set);
82         int nw_matrix2edit_file(double **prog_matrix, Fastal_profile *profile1, Fastal_profile *profile2, FILE *edit_f, int **prf_field, int *field_length, Fastal_param *param_set);
83         int** sumup_profile(Fastal_profile *profile, int **sumup_prf, Fastal_param *param_set);
84         void write2file(int **sumup_prf, int length, FILE *file, int number, Fastal_param *param_set);
85
86         
87         //Sparse dynamic programming
88         int seq_pair2blast_diagonal(char *seq_file_name1, char *seq_file_name2, int **diagonals, int *dig_length, int l1, int l2, int is_dna);
89         
90         
91         
92         
93         
94         
95         
96         
97 //edit_files 2 alignment
98         void edit2alignment(FILE *sequence_file, long *seq_positions, FILE *edit_file, long *edit_positions, int node_number, int number_of_sequences, char *aligned_sequence, int alignment_length, FILE *edit_seq_file, int offset, FILE* alignment_file);
99 void edit_seq2aligned_seq(char *aligned_sequence, FILE *sequence_file, long sequence_position, FILE *alignment_file);
100
101
102 //main
103 int fastal(int argc, char **argv);
104
105 //toolbox
106 void initiate_profile_files(FILE **profile_files);
107 void initiate_profiles(Fastal_profile **profiles, Fastal_param *param_set);
108 void free_fastal_profile(Fastal_profile *profile, int alphabet_size);
109 double **resize_dyn_matrix(double **dyn_matrix, int *old_length1, int *old_length2, int length1, int length2);
110 void free_dyn_matrix(int length1, double **dyn_matrix);
111 void fill_parameters(int is_dna, Fastal_param *param_set, char *method);
112
113 struct fastal_arguments
114 {
115 //      char *args[2];
116         char *method;
117         char *sequence_file;
118         char *tree_file;
119         char *output_file;
120         int is_dna;
121         int gop;
122         int gep;
123 };
124
125 // static char fastal_doc[] = "Fastal -- a program to align sequences with little memory";
126 // // static char args_doc[] = "ARG1 ARG2";
127 // static void* fastal_options[]=
128 // {
129 //      {"in",          'i', "FILE", 0, "Sequence file (FASTA format)" },
130 //      {"output",  'o', "FILE", 0, "Output to FILE" },
131 //      {"tree",        't', "FILE", 0, "Tree file" },
132 //      {"method",      'm', "METHOD", 0, "Methods:\n   fast (sparse dynamic),\n   nw (Needleman-Wunsch) "},
133 //      {"is_dna",      'd', 0, 0, "Sequences are DNA"},
134 //      {"is_aa",       'a', 0, 0, "Sequences are AminoAcids"},
135 //      {"gop",         'g', "VALUE", 0, "Gap opening costs"},
136 //      {"gep",         'e', "VALUE", 0, "Gap extension costs"},
137 //      { 0 }
138 // };
139
140
141
142
143
144 /*
145 void
146 fastal_parse_opt (int key, char *arg)
147 {
148 //      struct fastal_arguments *arguments = state->input;
149
150         switch (key)
151         {
152                 case 'o':
153                         arguments->output_file = arg;
154                         break;
155                 case 't':
156                         arguments->tree_file = arg;
157                         break;
158                 case 'i':
159                         arguments->sequence_file = arg;
160                         break;
161                 case 'm':
162                         arguments->method = arg;
163                         break;
164                 case 'g':
165                         arguments->gop = atoi(arg);
166                         break;
167                 case 'e':
168                         arguments->gep = atoi(arg);
169                         break;
170                 case 'd':
171                         arguments->is_dna = 1;
172                         break;
173                 case 'a':
174                         arguments->is_dna = 0;
175                         break;
176                 default:
177                         printf("UNKNOWN OPTION key");
178                         exit(1);
179         }
180         return 0;
181 }*/
182 // 
183 // 
184 // static struct argp argp = { fastal_options, fastal_parse_opt,/* fastal_args_doc,*/ fastal_doc};
185 /*********************************COPYRIGHT NOTICE**********************************/
186 /*© Centro de Regulacio Genomica */
187 /*and */
188 /*Cedric Notredame */
189 /*Tue Oct 27 10:12:26 WEST 2009. */
190 /*All rights reserved.*/
191 /*This file is part of T-COFFEE.*/
192 /**/
193 /*    T-COFFEE is free software; you can redistribute it and/or modify*/
194 /*    it under the terms of the GNU General Public License as published by*/
195 /*    the Free Software Foundation; either version 2 of the License, or*/
196 /*    (at your option) any later version.*/
197 /**/
198 /*    T-COFFEE is distributed in the hope that it will be useful,*/
199 /*    but WITHOUT ANY WARRANTY; without even the implied warranty of*/
200 /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*/
201 /*    GNU General Public License for more details.*/
202 /**/
203 /*    You should have received a copy of the GNU General Public License*/
204 /*    along with Foobar; if not, write to the Free Software*/
205 /*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
206 /*...............................................                                                                                      |*/
207 /*  If you need some more information*/
208 /*  cedric.notredame@europe.com*/
209 /*...............................................                                                                                                                                     |*/
210 /**/
211 /**/
212 /*      */
213 /*********************************COPYRIGHT NOTICE**********************************/