Revert multithreading support for mafft as it does not seem to work
[jabaws.git] / binaries / src / tcoffee / t_coffee_source / util_dp_est.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4 #include <stdarg.h>
5 #include <string.h>
6
7 #include "io_lib_header.h"
8 #include "util_lib_header.h"
9 #include "define_header.h"
10 #include "dp_lib_header.h"
11
12
13
14 int evaluate_est_order (Sequence *S, char *concat, Constraint_list *CL, int ktuple)
15     {
16         int a;
17         static char *alphabet;
18         int  *hasched_seq, *hasched_seq1, *hasched_seq2;
19         int  *lu_seq, *lu_seq1, *lu_seq2;
20         int pos_ktup1, pos_ktup2;
21         double score=0;
22         int n_ktup;
23         int n_dots=0;
24         
25         if ( !alphabet)alphabet=get_alphabet ( concat, alphabet);
26         n_ktup=(int)pow ( (double)alphabet[0]+1, (double)ktuple);
27         
28         hasch_seq (concat,&hasched_seq, &lu_seq,ktuple, alphabet);
29         hasched_seq1=hasched_seq2=hasched_seq;
30         lu_seq1=lu_seq2=lu_seq;
31         
32
33
34         for ( a=1; a< n_ktup; a++)
35             {
36                 pos_ktup1=lu_seq1[a];
37                 
38                 while (TRUE)
39                     {
40                     
41                      if (!pos_ktup1)break;
42                      pos_ktup2=lu_seq2[a];
43                      while (pos_ktup2) 
44                             {
45                             score+=abs ((int)(pos_ktup1-pos_ktup2));
46                             pos_ktup2=hasched_seq2[pos_ktup2];
47                             n_dots++;
48                             }
49                   pos_ktup1=hasched_seq1[pos_ktup1];
50                   }
51             }
52         
53         score=(score/(double)(n_dots*strlen(concat)))*100000;
54         vfree ( hasched_seq);
55         vfree(lu_seq);
56
57
58         return score;
59     }
60         
61 /*********************************COPYRIGHT NOTICE**********************************/
62 /*© Centro de Regulacio Genomica */
63 /*and */
64 /*Cedric Notredame */
65 /*Tue Oct 27 10:12:26 WEST 2009. */
66 /*All rights reserved.*/
67 /*This file is part of T-COFFEE.*/
68 /**/
69 /*    T-COFFEE is free software; you can redistribute it and/or modify*/
70 /*    it under the terms of the GNU General Public License as published by*/
71 /*    the Free Software Foundation; either version 2 of the License, or*/
72 /*    (at your option) any later version.*/
73 /**/
74 /*    T-COFFEE is distributed in the hope that it will be useful,*/
75 /*    but WITHOUT ANY WARRANTY; without even the implied warranty of*/
76 /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*/
77 /*    GNU General Public License for more details.*/
78 /**/
79 /*    You should have received a copy of the GNU General Public License*/
80 /*    along with Foobar; if not, write to the Free Software*/
81 /*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
82 /*...............................................                                                                                      |*/
83 /*  If you need some more information*/
84 /*  cedric.notredame@europe.com*/
85 /*...............................................                                                                                                                                     |*/
86 /**/
87 /**/
88 /*      */
89 /*********************************COPYRIGHT NOTICE**********************************/