1 /******************************COPYRIGHT NOTICE*******************************/
2 /* (c) Centro de Regulacio Genomica */
5 /* 12 Aug 2014 - 22:07. */
6 /*All rights reserved. */
7 /*This file is part of T-COFFEE. */
9 /* T-COFFEE is free software; you can redistribute it and/or modify */
10 /* it under the terms of the GNU General Public License as published by */
11 /* the Free Software Foundation; either version 2 of the License, or */
12 /* (at your option) any later version. */
14 /* T-COFFEE is distributed in the hope that it will be useful, */
15 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
16 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17 /* GNU General Public License for more details. */
19 /* You should have received a copy of the GNU General Public License */
20 /* along with Foobar; if not, write to the Free Software */
21 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
22 /*............................................... */
23 /* If you need some more information */
24 /* cedric.notredame@europe.com */
25 /*............................................... */
26 /******************************COPYRIGHT NOTICE*******************************/
30 /*By convention, 0: START, 1: END*/
35 double freeT; /*Free transition*/
36 double forbiden; /*Forbiden transition*/
37 int start; /*start, by convention: 0*/
38 int end; /*end, by convention: 1*/
40 int nS; /*Number of states*/
42 struct HmmState **S; /*State List*/
45 double **T; /*Transition matrix*/
46 int **fromM; /*For any sate s, fromM[0]->number of states leading to s*/
47 int **toM; /*For any sate s, toM[0]->number of s can go to*/
48 /*End and Start are NOT included in toM and FromM*/
52 typedef struct Hmm Hmm;
59 typedef struct HmmAln HmmAln;
61 typedef double (*Generic_em_func)(struct Hmm*, struct HmmState*, int);
72 Col_cost_func em_func;
76 Generic_em_func em_func2;
78 struct StateTrans **T;
80 typedef struct HmmState HmmState;
87 typedef struct StateTrans StateTrans;
98 struct MatState *m; /*memory*/
99 struct MatState *s; /*memory of the start point*/
100 /*Heap Mamagement: Never copy*/
101 struct MatState *Hn;/*Heap Next*/
102 struct MatState *Hp;/*Heap Previous*/
104 struct MatState *Mn;/*Marked Heap section*/
105 struct MatState *Mp;/*Marked Heap Section*/
108 typedef struct MatState MatState;
111 /*********************************************************************************/
114 /* simple HMM: Viterbi */
117 /*********************************************************************************/
118 int seq_viterbi_pair_wise (Alignment *A,int*ns, int **ls,Constraint_list *CL);
120 /*********************************************************************************/
126 /*********************************************************************************/
128 int viterbi_pair_wise_OLD (Alignment *A,int*ns, int **ls,Constraint_list *CL);
129 Alignment * viterbipath2aln (Alignment *A, int *ns,int **ls,int *tb, Hmm *H);
130 double*** viterbi_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL);
131 int * viterbi2path (int l1,int l2, Hmm *H, double ***M);
132 /*********************************************************************************/
138 /*********************************************************************************/
139 int viterbiL_pair_wise (Alignment *A,int*ns, int **ls,Constraint_list *CL);
140 MatState* RviterbiL_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E);
141 MatState* viterbiL_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL, MatState *S, MatState *E);
143 int viterbiD_pair_wise (Alignment *A,int*ns, int **ls,Constraint_list *CL);
144 double lu_RviterbiD_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
145 MatState* RviterbiD_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
146 MatState* viterbiD_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL, MatState *S, MatState *E, int **seg_list);
147 int **seglist2table ( int **seglist,int l1, int l2);
148 int *seglist2line ( int **seglist, int line, int start, int end);
149 int * traceback (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
151 int viterbiDGL_pair_wise (Alignment *A,int*ns, int **ls,Constraint_list *CL);
152 double lu_RviterbiDGL_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
153 MatState* RviterbiDGL_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
154 MatState* viterbiDGL_hmm (Alignment *A,int *ns, int **ls, Hmm *H, Constraint_list *CL,MatState *S, MatState *E, int **seg_list);
157 /*********************************************************************************/
163 /*********************************************************************************/
164 int MatStateAreIdentical (MatState*I, MatState*O);
165 int MaxDeltaMatState (MatState*I, MatState*O);
166 int MinDeltaMatState (MatState*I, MatState*O);
168 MatState * ManageMatState(int Mode, MatState *C);
169 MatState* CopyMatState ( MatState*I, MatState*O);
171 Hmm* read_hmm(char *file);
172 Hmm* declare_hmm(int n);
173 Hmm* free_Hmm(Hmm*H);
174 void DisplayHmm ( Hmm *H);
176 /*********************************************************************************/
182 /*********************************************************************************/
183 Hmm* define_two_mat_model(Constraint_list *CL);
184 Hmm* define_probcons_model(Constraint_list *CL);
185 Hmm* define_simple_model(Constraint_list *CL);
187 Hmm * bound_hmm ( Hmm *H);