#ifndef __INDEL_DEF_H
#define __INDEL_DEF_H
#include "indel_std.h"
#define CodonSize 3
#define NASize 4
#define AASize 20
/*Options and parameters*/
typedef struct _options_block {
long int max_iter; /* [burn-in period + data collection period] */
int num_throw; /*length of burn-in period*/
long int max_idnum; /*maximum number which can hold chain_ids*/
short lmax, nmax, lmax0; /*maximun length, maximum number of insertions or deletions*/
short select_num; /*the number of (c,t,p) to display in the output file*/
int seqtype; /*1:base, 2:aa*/
Uint1Ptr orig_seq; /*sequence of ancestor(origin) translated in "BASE"*/
Uint1Ptr target_seq; /*sequence and extant(target) translated in "BASE"*/
int orig_len, target_len; /*length of sequence*/
int model; /*model number(HKY85:4, TN93:5)*/
int num_t; /*the number of time periods.
Tmax is divided into num_t periods,
during each of which simulation is performed*/
double branch_length; /*mean substitution number per site per one time period */
double *pi; /*nucleotide composition*/
double kappa;
double *PMat; /*substitution matrix P(t)ij, that is,
the probability that i becomes j after t
based on the continuous time Markov model*/
double lambda; /* [insertion+deletion] vs substitution ratio*/
double *pID; /* length distribution of insertions and deletions */
double x, y, z;
/* x=zeta1:probability that insertion occurring at a non-MRC position becomes duplication.
y=zeta2:extra-probability of duplication(insertion) at modulo rep center (MRC).
z=zeta3:extra-probability of deletion at modulo rep center*/
int **MRC;
int filter;
} OptionsBlk, *OptionsBlkPtr;
/* Once accepted by MCMC, the information of each (c,t,p) is tranformed to the chain_id format
and stored in stock_id. Therefore one chain_id corresponds to one (c,t,p).
stock_id holds the information
regarding the types and number of accepted (c,t,p)s and can be used for referring to the (c,t,p)s.
*/
typedef struct _chain_id {
int nind_index; /* specifies (ni, nd) = (number of insertion, number of deletion)*/
int i_order, d_order; /* This number defines an array indicating the number of
insertion/deletion of differnt lengths.
For example, (1,1,2,4) means two 1nt insertions,
one 2nt insertion and one 4nt insertion occurring in this order.
This 'ins_array'is transformed
into a number using the function ArrayToID in handle_cand.c */
int order_index;
int t_index;
short *pos_vector;
double lnL;
int num_visit; /* indicates how many times the (c,t,p) was accepted by MCMC */
double lnProbAS;
} ChainID, *ChainIDPtr;
typedef struct _stock_id {
long int max_idnum;
long int current_id;
long int total_accepted;
short select_num;
short select_id0;
double Ave_lnAS;
ChainIDPtr PNTR chain_id_array;
} StockID, *StockIDPtr;
/* The following struct is a look-up table for (c,t,p) candidates. This table enables
quick choosing of a candidate (i.e, MCMC propose) by random number.
However, due to the limitation of memomry, if the number of candidates exceed the 'max_stored',
the preparation of the table is given up
and the candidate is nominated in an 'ab initio' manner. */
typedef struct _pool {
short lmax, nmax;
int target_d;
int num_t;
int orig_seqlen;
short max_setnum; /*(nmax+1)*(nmax+1)*/
double **rij; /*realtive possibily of set i->set j*/
double *num_cand; /*log10(number of candidate of the set(ni, nd))*/
double *limit_nind; /*probability of each (ni,nd) set selected*/
short max_stored;
int **i_pool, **d_pool;
double *num_order; /*log10(number of candidates of order)*/
double *num_t_cand; /*log10(number of candidates of t_vector)*/
} PoolStruct, *PoolStructPtr;
typedef struct _candidate {
short ni, nd;
short *ins_array, *del_array;
short *order;
short *id_array;
short *t_vector;
short *pos_vector;
double lnL;
short chain_no; /*which element has been changed*/
double num_pos_cand;
} CandStruct, *CandStructPtr;
/* score_block is a struct that stores the estimated probability
that the simulation results in a sequence identical to S (target sequence) */
typedef struct _score_block {
int target_seqlen;
double *lkl;
int *anc_no;
int count_per_cycle;
double *P; /*P=sum(ln(lkl[i]))*/
int current_cycle;
int max_cycle;
double MP, VP;/*mean and variance of P*/
} ScoreBlk, *ScoreBlkPtr;
/*align struct Dec 22,2000 Several (c,t,p)s may correspond to an alignment model.
This struct organize the 'alignment' space.
*/
typedef struct _align_id {
int num_gap;
short *gap_length;
short *pos_vector;
double lnL;
int num_visit;
double lnProbAS;
} AlignID, *AlignIDPtr;
typedef struct _stock_align {
long int max_idnum;
long int current_id;
long int total_accepted;
short select_num;
short select_id0;
double Ave_lnAS;
AlignIDPtr PNTR align_id_array;
} StockAlign, *StockAlignPtr;
/* When (ni, nd) is going to be changed upon MCMC proposal, completely random drawing
from a new (ni, nd) group may cause too high a rate of MCMC rejection. Hence, some
elements of (c,t,p) may well be conserved upon jumping from one (ni,nd) group to another.
Struct pool_cons provides a look-up table of
the candidates (which have the conserved elements) of the new (ni, nd) group. */
typedef struct _pool_cons {
int *num_cons; /*number of candidate of the set(ni, nd)*/
int max_stored;
int *i_pool_cons, *d_pool_cons; /*only store the indel for new(ni,nd)*/
}PoolCons, *PoolConsPtr;
#endif