1 /****************************************************************\
2 *                                                                *
3 *  GAM: Gapped Alignment Manager                                 *
4 *                                                                *
5 *  Guy St.C. Slater..   mailto:guy@ebi.ac.uk                     *
6 *  Copyright (C) 2000-2009.  All Rights Reserved.                *
7 *                                                                *
8 *  This source code is distributed under the terms of the        *
9 *  GNU General Public License, version 3. See the file COPYING   *
10 *  or http://www.gnu.org/licenses/gpl.txt for details            *
11 *                                                                *
12 *  If you use this code, please keep this notice intact.         *
13 *                                                                *
14 \****************************************************************/
15 
16 #ifndef INCLUDED_GAM_H
17 #define INCLUDED_GAM_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
22 
23 #include <glib.h>
24 
25 #ifdef USE_PTHREADS
26 #include <pthread.h>
27 #endif /* USE_PTHREADS */
28 
29 #include "sequence.h"
30 #include "c4.h"
31 #include "heuristic.h"
32 #include "hpair.h"
33 #include "sequence.h"
34 #include "hspset.h"
35 #include "submat.h"
36 #include "argument.h"
37 #include "translate.h"
38 #include "pqueue.h"
39 #include "modeltype.h"
40 #include "comparison.h"
41 #include "sdp.h"
42 #include "subopt.h"
43 #include "threadref.h"
44 
45 typedef enum {
46     GAM_Refinement_NONE,
47     GAM_Refinement_REGION,
48     GAM_Refinement_FULL,
49     GAM_Refinement_TOTAL /* Just the total */
50 } GAM_Refinement;
51 
52 typedef struct {
53         Model_Type  type;
54           C4_Score  threshold;
55             gfloat  percent_threshold;
56           gboolean  show_alignment;
57           gboolean  show_sugar;
58           gboolean  show_cigar;
59           gboolean  show_vulgar;
60           gboolean  show_query_gff;
61           gboolean  show_target_gff;
62              gchar *ryo;
63               gint  best_n;
64           gboolean  use_subopt;
65           gboolean  use_gapped_extension;
66       /**/
67     GAM_Refinement  refinement;
68               gint  refinement_boundary;
69 } GAM_ArgumentSet;
70 
71 GAM_ArgumentSet *GAM_ArgumentSet_create(Argument *arg);
72 
73 typedef struct {
74        C4_Score score;
75           glong pos;
76           glong len;
77 } GAM_StoredResult;
78 
79 typedef struct {
80      gchar *query_id;
81     PQueue *pq; /* Contains GAM_StoredResult */
82       gint  tie_count; /* For best_n */
83   C4_Score  tie_score; /* For best_n */
84 } GAM_QueryResult;
85 
86 typedef struct {
87        gchar *query_id;
88     C4_Score threshold;
89 } GAM_QueryInfo;
90 
91 typedef struct {
92              ThreadRef *thread_ref;
93          Alphabet_Type  query_type;
94          Alphabet_Type  target_type;
95               C4_Model *model;
96              GPtrArray *match_list;
97                Optimal *optimal;
98              Heuristic *heuristic;
99                    SDP *sdp;
100                 Submat *dna_submat;
101                 Submat *protein_submat;
102              Translate *translate;
103        GAM_ArgumentSet *gas;
104                  GTree *bestn_tree; /* Contains GAM_QueryResult */
105                   FILE *bestn_tmp_file;
106                   gint  verbosity;
107               gboolean  translate_both;
108               gboolean  dual_match;
109                  GTree *percent_threshold_tree;
110                         /* Contains GAM_QueryInfo */
111              PQueueSet *pqueue_set;
112                   gint  max_query_span;
113                   gint  max_target_span;
114 #ifdef USE_PTHREADS
115        pthread_mutex_t  gam_lock;
116 #endif /* USE_PTHREADS */
117 } GAM;
118 
119 GAM *GAM_create(Alphabet_Type query_type, Alphabet_Type target_type,
120                 Submat *dna_submat, Submat *protein_submat,
121                 Translate *translate, gboolean use_exhaustive,
122                 gint verbosity);
123 GAM *GAM_share(GAM *gam);
124 void GAM_destroy(GAM *gam);
125 void GAM_report(GAM *gam);
126 
127 typedef struct {
128          gint  ref_count;
129           GAM *gam;
130      Sequence *query;
131      Sequence *target;
132     GPtrArray *alignment_list;
133      gpointer  user_data;
134      gpointer  self_data;
135        SubOpt *subopt;
136 } GAM_Result;
137 
138 GAM_Result *GAM_Result_ungapped_create(GAM *gam,
139                                        Comparison *comparison);
140 /* Will return NULL when no alignments are produced */
141 
142 GAM_Result *GAM_Result_heuristic_create(GAM *gam,
143                                         Comparison *comparison);
144 /* Will return NULL when no alignments are produced */
145 
146 GAM_Result *GAM_Result_exhaustive_create(GAM *gam,
147                                          Sequence *query,
148                                          Sequence *target);
149 
150 GAM_Result *GAM_Result_share(GAM_Result *gam_result);
151       void  GAM_Result_destroy(GAM_Result *gam_result);
152       void  GAM_Result_submit(GAM_Result *gam_result);
153 
154 void GAM_lock(GAM *gam);
155 void GAM_unlock(GAM *gam);
156 
157 #ifdef __cplusplus
158 }
159 #endif /* __cplusplus */
160 
161 #endif /* INCLUDED_GAM_H */
162 
163