1 #ifndef DYNAMITEpairbaseHEADERFILE
2 #define DYNAMITEpairbaseHEADERFILE
3 #ifdef _cplusplus
4 extern "C" {
5 #endif
6 #include "codon.h"
7 #include "probability.h"
8 #include "codonmatrix.h"
9 #include <stdio.h>
10 
11 typedef char pairbase_type;
12 typedef int  pairbase_codon_type;
13 
14 #define BASE_GAP  5
15 #define BASE_OPEN 6
16 
17 #define IS_NOT_BASE(a) (a == BASE_GAP ? 1 : a == BASE_OPEN ? 1 : 0)
18 #define MAKE_PAIRBASE(anchor,informant) (anchor*7+informant)
19 
20 #define PAIRBASE_LENGTH (7*7)
21 
22 #define PAIRBASE_CODON_LENGTH (PAIRBASE_LENGTH*PAIRBASE_LENGTH*PAIRBASE_LENGTH)
23 
24 struct Wise2_PairBaseModel {
25     int dynamite_hard_link;
26 #ifdef PTHREAD
27     pthread_mutex_t dynamite_mutex;
28 #endif
29     Probability base[PAIRBASE_LENGTH];
30     } ;
31 /* PairBaseModel defined */
32 #ifndef DYNAMITE_DEFINED_PairBaseModel
33 typedef struct Wise2_PairBaseModel Wise2_PairBaseModel;
34 #define PairBaseModel Wise2_PairBaseModel
35 #define DYNAMITE_DEFINED_PairBaseModel
36 #endif
37 
38 
39 struct Wise2_PairBaseCodonModel {
40     int dynamite_hard_link;
41 #ifdef PTHREAD
42     pthread_mutex_t dynamite_mutex;
43 #endif
44     Probability codon[PAIRBASE_CODON_LENGTH];
45     } ;
46 /* PairBaseCodonModel defined */
47 #ifndef DYNAMITE_DEFINED_PairBaseCodonModel
48 typedef struct Wise2_PairBaseCodonModel Wise2_PairBaseCodonModel;
49 #define PairBaseCodonModel Wise2_PairBaseCodonModel
50 #define DYNAMITE_DEFINED_PairBaseCodonModel
51 #endif
52 
53 
54 struct Wise2_PairBaseModelScore {
55     int dynamite_hard_link;
56 #ifdef PTHREAD
57     pthread_mutex_t dynamite_mutex;
58 #endif
59     Score base[PAIRBASE_LENGTH];
60     } ;
61 /* PairBaseModelScore defined */
62 #ifndef DYNAMITE_DEFINED_PairBaseModelScore
63 typedef struct Wise2_PairBaseModelScore Wise2_PairBaseModelScore;
64 #define PairBaseModelScore Wise2_PairBaseModelScore
65 #define DYNAMITE_DEFINED_PairBaseModelScore
66 #endif
67 
68 
69 struct Wise2_PairBaseCodonModelScore {
70     int dynamite_hard_link;
71 #ifdef PTHREAD
72     pthread_mutex_t dynamite_mutex;
73 #endif
74     Score codon[PAIRBASE_CODON_LENGTH];
75     } ;
76 /* PairBaseCodonModelScore defined */
77 #ifndef DYNAMITE_DEFINED_PairBaseCodonModelScore
78 typedef struct Wise2_PairBaseCodonModelScore Wise2_PairBaseCodonModelScore;
79 #define PairBaseCodonModelScore Wise2_PairBaseCodonModelScore
80 #define DYNAMITE_DEFINED_PairBaseCodonModelScore
81 #endif
82 
83 
84 
85 
86     /***************************************************/
87     /* Callable functions                              */
88     /* These are the functions you are expected to use */
89     /***************************************************/
90 
91 
92 
93 /* Function:  diagonal_tweak_PairBaseCodonModel(m,ratio_on,ratio_off_positive,ratio_off_negative)
94  *
95  * Descrip:    Tweaks a PairBaseCodonModel with on and off diagonal ratios
96  *
97  *
98  * Arg:                         m [UNKN ] Undocumented argument [PairBaseCodonModel *]
99  * Arg:                  ratio_on [UNKN ] Undocumented argument [double]
100  * Arg:        ratio_off_positive [UNKN ] Undocumented argument [double]
101  * Arg:        ratio_off_negative [UNKN ] Undocumented argument [double]
102  *
103  */
104 void Wise2_diagonal_tweak_PairBaseCodonModel(PairBaseCodonModel * m,double ratio_on,double ratio_off_positive,double ratio_off_negative);
105 #define diagonal_tweak_PairBaseCodonModel Wise2_diagonal_tweak_PairBaseCodonModel
106 
107 
108 /* Function:  flatten_diagonal_PairBaseCodonModel(m,ct)
109  *
110  * Descrip:    flattens out the diagonal signal
111  *
112  *
113  * Arg:         m [UNKN ] Undocumented argument [PairBaseCodonModel *]
114  * Arg:        ct [UNKN ] Undocumented argument [CodonTable *]
115  *
116  */
117 void Wise2_flatten_diagonal_PairBaseCodonModel(PairBaseCodonModel * m,CodonTable * ct);
118 #define flatten_diagonal_PairBaseCodonModel Wise2_flatten_diagonal_PairBaseCodonModel
119 
120 
121 /* Function:  flatten_diagonal_PairBaseCodonModelScore(m,ct)
122  *
123  * Descrip:    flattens out the diagonal signal - for scores!
124  *
125  *
126  * Arg:         m [UNKN ] Undocumented argument [PairBaseCodonModelScore *]
127  * Arg:        ct [UNKN ] Undocumented argument [CodonTable *]
128  *
129  */
130 void Wise2_flatten_diagonal_PairBaseCodonModelScore(PairBaseCodonModelScore * m,CodonTable * ct);
131 #define flatten_diagonal_PairBaseCodonModelScore Wise2_flatten_diagonal_PairBaseCodonModelScore
132 
133 
134 /* Function:  zero_PairBaseModelScore(void)
135  *
136  * Descrip:    a 0 pairbasemodel score
137  *
138  *
139  *
140  * Return [UNKN ]  Undocumented return value [PairBaseModelScore *]
141  *
142  */
143 PairBaseModelScore * Wise2_zero_PairBaseModelScore(void);
144 #define zero_PairBaseModelScore Wise2_zero_PairBaseModelScore
145 
146 
147 /* Function:  very_simple_PairBaseCodonModel(id,rnd,nonm,gap,ct)
148  *
149  * Descrip:    Makes a PairBaseCodonModel from just a one parameter! Wow!
150  *
151  *
152  * Arg:          id [UNKN ] Undocumented argument [Probability]
153  * Arg:         rnd [UNKN ] Undocumented argument [Probability]
154  * Arg:        nonm [UNKN ] Undocumented argument [Probability]
155  * Arg:         gap [UNKN ] Undocumented argument [Probability]
156  * Arg:          ct [UNKN ] Undocumented argument [CodonTable *]
157  *
158  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
159  *
160  */
161 PairBaseCodonModel * Wise2_very_simple_PairBaseCodonModel(Probability id,Probability rnd,Probability nonm,Probability gap,CodonTable * ct);
162 #define very_simple_PairBaseCodonModel Wise2_very_simple_PairBaseCodonModel
163 
164 
165 /* Function:  make_flat_PairBaseCodonModel(cp,nonm,gap,ct)
166  *
167  * Descrip:    Makes a PairBaseCodonModel from a protein matrix - assumming a flat
168  *             mapping to CodonMatrix
169  *
170  *
171  * Arg:          cp [UNKN ] Undocumented argument [CompProb *]
172  * Arg:        nonm [UNKN ] Undocumented argument [Probability]
173  * Arg:         gap [UNKN ] Undocumented argument [Probability]
174  * Arg:          ct [UNKN ] Undocumented argument [CodonTable *]
175  *
176  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
177  *
178  */
179 PairBaseCodonModel * Wise2_make_flat_PairBaseCodonModel(CompProb * cp,Probability nonm,Probability gap,CodonTable * ct);
180 #define make_flat_PairBaseCodonModel Wise2_make_flat_PairBaseCodonModel
181 
182 
183 /* Function:  make_start_PairBaseCodonModelScore(ct)
184  *
185  * Descrip:    Makes a PairBaseCodonModel score for start codon
186  *
187  *
188  * Arg:        ct [UNKN ] Undocumented argument [CodonTable *]
189  *
190  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
191  *
192  */
193 PairBaseCodonModelScore * Wise2_make_start_PairBaseCodonModelScore(CodonTable * ct);
194 #define make_start_PairBaseCodonModelScore Wise2_make_start_PairBaseCodonModelScore
195 
196 
197 /* Function:  make_stop_PairBaseCodonModelScore(ct)
198  *
199  * Descrip:    Makes a PairBaseCodonModel score for start codon
200  *
201  *
202  * Arg:        ct [UNKN ] Undocumented argument [CodonTable *]
203  *
204  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
205  *
206  */
207 PairBaseCodonModelScore * Wise2_make_stop_PairBaseCodonModelScore(CodonTable * ct);
208 #define make_stop_PairBaseCodonModelScore Wise2_make_stop_PairBaseCodonModelScore
209 
210 
211 /* Function:  make_conserved_PairBaseCodonModel(cons,non_cons,aa_var,ct)
212  *
213  * Descrip:    Makes a PairBaseCodonModel for a particular character in the CodonTable
214  *
215  *
216  * Arg:            cons [UNKN ] Undocumented argument [Probability]
217  * Arg:        non_cons [UNKN ] Undocumented argument [Probability]
218  * Arg:          aa_var [UNKN ] Undocumented argument [char]
219  * Arg:              ct [UNKN ] Undocumented argument [CodonTable *]
220  *
221  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
222  *
223  */
224 PairBaseCodonModel * Wise2_make_conserved_PairBaseCodonModel(Probability cons,Probability non_cons,char aa_var,CodonTable * ct);
225 #define make_conserved_PairBaseCodonModel Wise2_make_conserved_PairBaseCodonModel
226 
227 
228 /* Function:  make_PairBaseCodonModel(codon_matrix,nonm,gap,ct)
229  *
230  * Descrip:    Makes a PairBaseCodonModel from a CodonMatrix and parameters
231  *
232  *
233  * Arg:        codon_matrix [UNKN ] Undocumented argument [CodonMatrix *]
234  * Arg:                nonm [UNKN ] Undocumented argument [Probability]
235  * Arg:                 gap [UNKN ] Undocumented argument [Probability]
236  * Arg:                  ct [UNKN ] Undocumented argument [CodonTable *]
237  *
238  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
239  *
240  */
241 PairBaseCodonModel * Wise2_make_PairBaseCodonModel(CodonMatrix * codon_matrix,Probability nonm,Probability gap,CodonTable * ct);
242 #define make_PairBaseCodonModel Wise2_make_PairBaseCodonModel
243 
244 
245 /* Function:  simple_PairBaseModel(iden,other,gap)
246  *
247  * Descrip:    Makes a pair base model from simple leading diagonal
248  *
249  *
250  * Arg:         iden [UNKN ] Undocumented argument [Probability]
251  * Arg:        other [UNKN ] Undocumented argument [Probability]
252  * Arg:          gap [UNKN ] Undocumented argument [Probability]
253  *
254  * Return [UNKN ]  Undocumented return value [PairBaseModel *]
255  *
256  */
257 PairBaseModel * Wise2_simple_PairBaseModel(Probability iden,Probability other,Probability gap);
258 #define simple_PairBaseModel Wise2_simple_PairBaseModel
259 
260 
261 /* Function:  new_PairBaseCodonModelScore(pbcm)
262  *
263  * Descrip:    Makes a codon score from a codon model
264  *
265  *
266  * Arg:        pbcm [UNKN ] Undocumented argument [PairBaseCodonModel *]
267  *
268  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
269  *
270  */
271 PairBaseCodonModelScore * Wise2_new_PairBaseCodonModelScore(PairBaseCodonModel * pbcm);
272 #define new_PairBaseCodonModelScore Wise2_new_PairBaseCodonModelScore
273 
274 
275 /* Function:  new_PairBaseModelScore(pbm)
276  *
277  * Descrip:    Makes a base score from a base model
278  *
279  *
280  * Arg:        pbm [UNKN ] Undocumented argument [PairBaseModel *]
281  *
282  * Return [UNKN ]  Undocumented return value [PairBaseModelScore *]
283  *
284  */
285 PairBaseModelScore * Wise2_new_PairBaseModelScore(PairBaseModel * pbm);
286 #define new_PairBaseModelScore Wise2_new_PairBaseModelScore
287 
288 
289 /* Function:  show_PairBaseModelScore(sc,ofp)
290  *
291  * Descrip:    Debugging
292  *
293  *
294  * Arg:         sc [UNKN ] Undocumented argument [PairBaseModelScore *]
295  * Arg:        ofp [UNKN ] Undocumented argument [FILE *]
296  *
297  */
298 void Wise2_show_PairBaseModelScore(PairBaseModelScore * sc,FILE * ofp);
299 #define show_PairBaseModelScore Wise2_show_PairBaseModelScore
300 
301 
302 /* Function:  show_PairBaseCodonModelScore(sc,ct,ofp)
303  *
304  * Descrip:    Debugging
305  *
306  *
307  * Arg:         sc [UNKN ] Undocumented argument [PairBaseCodonModelScore *]
308  * Arg:         ct [UNKN ] Undocumented argument [CodonTable *]
309  * Arg:        ofp [UNKN ] Undocumented argument [FILE *]
310  *
311  */
312 void Wise2_show_PairBaseCodonModelScore(PairBaseCodonModelScore * sc,CodonTable * ct,FILE * ofp);
313 #define show_PairBaseCodonModelScore Wise2_show_PairBaseCodonModelScore
314 
315 
316 /* Function:  reverse_pairbase_codon(codon)
317  *
318  * Descrip:    Inverts pairbase codon
319  *
320  *
321  * Arg:        codon [UNKN ] Undocumented argument [pairbase_codon_type]
322  *
323  * Return [UNKN ]  Undocumented return value [pairbase_codon_type]
324  *
325  */
326 pairbase_codon_type Wise2_reverse_pairbase_codon(pairbase_codon_type codon);
327 #define reverse_pairbase_codon Wise2_reverse_pairbase_codon
328 
329 
330 /* Function:  complement_pairbase(b)
331  *
332  * Descrip:    complements a pairbase
333  *
334  *
335  * Arg:        b [UNKN ] Undocumented argument [pairbase_type]
336  *
337  * Return [UNKN ]  Undocumented return value [pairbase_type]
338  *
339  */
340 pairbase_type Wise2_complement_pairbase(pairbase_type b);
341 #define complement_pairbase Wise2_complement_pairbase
342 
343 
344 /* Function:  pairbase_codon_from_seq(seq)
345  *
346  * Descrip:    Makes a pairbase_codon from a pairbase_sequence
347  *
348  *
349  * Arg:        seq [UNKN ] Undocumented argument [pairbase_type *]
350  *
351  * Return [UNKN ]  Undocumented return value [pairbase_codon_type]
352  *
353  */
354 pairbase_codon_type Wise2_pairbase_codon_from_seq(pairbase_type * seq);
355 #define pairbase_codon_from_seq Wise2_pairbase_codon_from_seq
356 
357 
358 /* Function:  decompose_pairbase_codon(t,a,b,c)
359  *
360  * Descrip:    Decomposes a pairbase codon
361  *
362  *
363  * Arg:        t [UNKN ] Undocumented argument [pairbase_codon_type]
364  * Arg:        a [UNKN ] Undocumented argument [pairbase_type *]
365  * Arg:        b [UNKN ] Undocumented argument [pairbase_type *]
366  * Arg:        c [UNKN ] Undocumented argument [pairbase_type *]
367  *
368  */
369 void Wise2_decompose_pairbase_codon(pairbase_codon_type t,pairbase_type * a,pairbase_type * b,pairbase_type * c);
370 #define decompose_pairbase_codon Wise2_decompose_pairbase_codon
371 
372 
373 /* Function:  anchor_base_from_pairbase(pairbase)
374  *
375  * Descrip:    Finds the anchor base from a pair base
376  *
377  *
378  * Arg:        pairbase [UNKN ] Undocumented argument [pairbase_type]
379  *
380  * Return [UNKN ]  Undocumented return value [base]
381  *
382  */
383 base Wise2_anchor_base_from_pairbase(pairbase_type pairbase);
384 #define anchor_base_from_pairbase Wise2_anchor_base_from_pairbase
385 
386 
387 /* Function:  informant_base_from_pairbase(pairbase)
388  *
389  * Descrip:    Finds the informant base from a pair base
390  *
391  *
392  * Arg:        pairbase [UNKN ] Undocumented argument [pairbase_type]
393  *
394  * Return [UNKN ]  Undocumented return value [base]
395  *
396  */
397 base Wise2_informant_base_from_pairbase(pairbase_type pairbase);
398 #define informant_base_from_pairbase Wise2_informant_base_from_pairbase
399 
400 
401 /* Function:  char_for_base(base)
402  *
403  * Descrip:    gives back the character for the base
404  *
405  *
406  * Arg:        base [UNKN ] Undocumented argument [int]
407  *
408  * Return [UNKN ]  Undocumented return value [char]
409  *
410  */
411 char Wise2_char_for_base(int base);
412 #define char_for_base Wise2_char_for_base
413 
414 
415 /* Function:  hard_link_PairBaseModel(obj)
416  *
417  * Descrip:    Bumps up the reference count of the object
418  *             Meaning that multiple pointers can 'own' it
419  *
420  *
421  * Arg:        obj [UNKN ] Object to be hard linked [PairBaseModel *]
422  *
423  * Return [UNKN ]  Undocumented return value [PairBaseModel *]
424  *
425  */
426 PairBaseModel * Wise2_hard_link_PairBaseModel(PairBaseModel * obj);
427 #define hard_link_PairBaseModel Wise2_hard_link_PairBaseModel
428 
429 
430 /* Function:  PairBaseModel_alloc(void)
431  *
432  * Descrip:    Allocates structure: assigns defaults if given
433  *
434  *
435  *
436  * Return [UNKN ]  Undocumented return value [PairBaseModel *]
437  *
438  */
439 PairBaseModel * Wise2_PairBaseModel_alloc(void);
440 #define PairBaseModel_alloc Wise2_PairBaseModel_alloc
441 
442 
443 /* Function:  free_PairBaseModel(obj)
444  *
445  * Descrip:    Free Function: removes the memory held by obj
446  *             Will chain up to owned members and clear all lists
447  *
448  *
449  * Arg:        obj [UNKN ] Object that is free'd [PairBaseModel *]
450  *
451  * Return [UNKN ]  Undocumented return value [PairBaseModel *]
452  *
453  */
454 PairBaseModel * Wise2_free_PairBaseModel(PairBaseModel * obj);
455 #define free_PairBaseModel Wise2_free_PairBaseModel
456 
457 
458 /* Function:  hard_link_PairBaseCodonModel(obj)
459  *
460  * Descrip:    Bumps up the reference count of the object
461  *             Meaning that multiple pointers can 'own' it
462  *
463  *
464  * Arg:        obj [UNKN ] Object to be hard linked [PairBaseCodonModel *]
465  *
466  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
467  *
468  */
469 PairBaseCodonModel * Wise2_hard_link_PairBaseCodonModel(PairBaseCodonModel * obj);
470 #define hard_link_PairBaseCodonModel Wise2_hard_link_PairBaseCodonModel
471 
472 
473 /* Function:  PairBaseCodonModel_alloc(void)
474  *
475  * Descrip:    Allocates structure: assigns defaults if given
476  *
477  *
478  *
479  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
480  *
481  */
482 PairBaseCodonModel * Wise2_PairBaseCodonModel_alloc(void);
483 #define PairBaseCodonModel_alloc Wise2_PairBaseCodonModel_alloc
484 
485 
486 /* Function:  free_PairBaseCodonModel(obj)
487  *
488  * Descrip:    Free Function: removes the memory held by obj
489  *             Will chain up to owned members and clear all lists
490  *
491  *
492  * Arg:        obj [UNKN ] Object that is free'd [PairBaseCodonModel *]
493  *
494  * Return [UNKN ]  Undocumented return value [PairBaseCodonModel *]
495  *
496  */
497 PairBaseCodonModel * Wise2_free_PairBaseCodonModel(PairBaseCodonModel * obj);
498 #define free_PairBaseCodonModel Wise2_free_PairBaseCodonModel
499 
500 
501 /* Function:  hard_link_PairBaseModelScore(obj)
502  *
503  * Descrip:    Bumps up the reference count of the object
504  *             Meaning that multiple pointers can 'own' it
505  *
506  *
507  * Arg:        obj [UNKN ] Object to be hard linked [PairBaseModelScore *]
508  *
509  * Return [UNKN ]  Undocumented return value [PairBaseModelScore *]
510  *
511  */
512 PairBaseModelScore * Wise2_hard_link_PairBaseModelScore(PairBaseModelScore * obj);
513 #define hard_link_PairBaseModelScore Wise2_hard_link_PairBaseModelScore
514 
515 
516 /* Function:  PairBaseModelScore_alloc(void)
517  *
518  * Descrip:    Allocates structure: assigns defaults if given
519  *
520  *
521  *
522  * Return [UNKN ]  Undocumented return value [PairBaseModelScore *]
523  *
524  */
525 PairBaseModelScore * Wise2_PairBaseModelScore_alloc(void);
526 #define PairBaseModelScore_alloc Wise2_PairBaseModelScore_alloc
527 
528 
529 /* Function:  free_PairBaseModelScore(obj)
530  *
531  * Descrip:    Free Function: removes the memory held by obj
532  *             Will chain up to owned members and clear all lists
533  *
534  *
535  * Arg:        obj [UNKN ] Object that is free'd [PairBaseModelScore *]
536  *
537  * Return [UNKN ]  Undocumented return value [PairBaseModelScore *]
538  *
539  */
540 PairBaseModelScore * Wise2_free_PairBaseModelScore(PairBaseModelScore * obj);
541 #define free_PairBaseModelScore Wise2_free_PairBaseModelScore
542 
543 
544 /* Function:  hard_link_PairBaseCodonModelScore(obj)
545  *
546  * Descrip:    Bumps up the reference count of the object
547  *             Meaning that multiple pointers can 'own' it
548  *
549  *
550  * Arg:        obj [UNKN ] Object to be hard linked [PairBaseCodonModelScore *]
551  *
552  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
553  *
554  */
555 PairBaseCodonModelScore * Wise2_hard_link_PairBaseCodonModelScore(PairBaseCodonModelScore * obj);
556 #define hard_link_PairBaseCodonModelScore Wise2_hard_link_PairBaseCodonModelScore
557 
558 
559 /* Function:  PairBaseCodonModelScore_alloc(void)
560  *
561  * Descrip:    Allocates structure: assigns defaults if given
562  *
563  *
564  *
565  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
566  *
567  */
568 PairBaseCodonModelScore * Wise2_PairBaseCodonModelScore_alloc(void);
569 #define PairBaseCodonModelScore_alloc Wise2_PairBaseCodonModelScore_alloc
570 
571 
572 /* Function:  free_PairBaseCodonModelScore(obj)
573  *
574  * Descrip:    Free Function: removes the memory held by obj
575  *             Will chain up to owned members and clear all lists
576  *
577  *
578  * Arg:        obj [UNKN ] Object that is free'd [PairBaseCodonModelScore *]
579  *
580  * Return [UNKN ]  Undocumented return value [PairBaseCodonModelScore *]
581  *
582  */
583 PairBaseCodonModelScore * Wise2_free_PairBaseCodonModelScore(PairBaseCodonModelScore * obj);
584 #define free_PairBaseCodonModelScore Wise2_free_PairBaseCodonModelScore
585 
586 
587   /* Unplaced functions */
588   /* There has been no indication of the use of these functions */
589 
590 
591     /***************************************************/
592     /* Internal functions                              */
593     /* you are not expected to have to call these      */
594     /***************************************************/
595 
596 #ifdef _cplusplus
597 }
598 #endif
599 
600 #endif
601