Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / fasta34 / tatstats.h
1 #ifndef MAXSQ
2 #include "param.h"
3 #endif
4
5 #ifndef MAXSAV
6 #ifdef FASTS
7 #define MAXSAV 25
8 #else
9 #define MAXSAV 10
10 #endif
11 #endif
12
13 #if defined(IBM_AIX) && defined(MAXSEG)
14 #undef MAXSEG
15 #endif
16 #define MAXSEG 30
17
18 struct savestr {
19   int     score;                /* pam score with segment optimization */
20   int     score0;               /* pam score of best single segment */
21   int     start0;               /* score from global match */
22   int     dp;                   /* diagonal of match */
23   int     start;                /* start of match in lib seq */
24   int     stop;                 /* end of match in lib seq */
25   int     exact;                /* exact match */
26 #if defined(FASTF)
27   int     *used;                /* array of positions in aa0 that were used */
28 #endif
29 };
30
31 struct dstruct  {       /* diagonal structure for saving current run */
32    int     score;       /* hash score of current match */
33    int     start;       /* start of current match */
34    int     stop;        /* end of current match */
35    struct savestr *dmax;   /* location in vmax[] where best score data saved */
36 };
37
38 struct tat_str {
39   double *probs;
40   int lowscore;
41   int highscore;
42 };
43
44 struct f_struct {
45   struct dstruct *diag;
46   struct savestr *vmax; /* best matches saved for one sequence */
47   struct savestr **vptr;
48   struct slink *sarr;
49   struct savestr *lowmax;
50   int maxsav;   /* max number of peptide alignments saved in search */
51   int maxsav_w; /* max number of peptide alignments saved in alignment */
52   int shuff_cnt;
53   int nsave;
54   int ndo;
55   int noff;
56   int nm0;              /* number of fragments */
57 #if defined(FASTS) || defined(FASTM)
58   int *nmoff;           /* offset number, start */
59   int *nm_u;
60   int *aa0b;            /* beginning of each segment */
61   int *aa0e;            /* end of each segment */
62   int *aa0i;            /* index of each segment */
63   int *aa0s;            /* max score of each segment */
64   int *aa0l;            /* longest possible peptide match */
65 #else
66   int nmoff;            /* offset number, start */
67   unsigned char *aa0;
68   int aa0ix;
69 #endif
70   unsigned char *aa0t;  /* temp location for peptides */
71   int *aa0ti;           /* temp index for peptides */
72   int hmask;                    /* hash constants */
73   int *pamh1;                   /* pam based array */
74   int *pamh2;                   /* pam based kfact array */
75 #if defined(FASTS) || defined(FASTM)
76   int *link, *harr, *l_end;             /* hash arrays */
77 #else
78   struct hlstr *link, *harr;            /* hash arrays */
79 #endif
80   int kshft;                    /* shift width */
81   int nsav, lowscor;            /* number of saved runs, worst saved run */
82   unsigned char *aa1x;          /* contains translated codons 111222333 */
83   unsigned char *aa1y;          /* contains translated codons 123123123 */
84   int n10;
85   int *waa;
86   int *res;
87   int max_res;
88   double *priors;
89 #if defined(FASTS) || defined(FASTM)
90   struct tat_str **tatprobs;          /* array of pointers to tat structs */
91   double **intprobs;                  /* array of integrated tatprobs */
92 #endif
93   int dotat;
94   double spacefactor;
95 };
96
97 struct slink {
98   int     score;
99   double  tatprob;
100   struct tat_str *tat;
101   struct tat_str *newtat;
102   struct savestr *vp;
103   struct slink *next;
104   struct slink *prev;
105 };
106
107 struct segstr {
108   double tatprob;
109   int length;
110 };
111
112 void generate_tatprobs(const unsigned char *query,
113                        int begin,
114                        int end,
115                        double *priors,
116                        int **pam2,
117                        int nsq,
118                        struct tat_str **tatarg, struct tat_str *oldtat);
119
120 double
121 calc_tatusov ( struct slink *last,
122                struct slink *this,
123                const unsigned char *aa0, int n0,
124                const unsigned char *aa1, int n1,
125                int **pam2, int nsq,
126                struct f_struct *f_str,
127                int pseudocts,
128                int do_opt,
129                int zsflag
130                );
131
132 double seg_tatprob(struct slink *start,
133                    const unsigned char *aa0,
134                    int n0,
135                    const unsigned char *aa1,
136                    int n1,
137                    struct f_struct *f_str,
138                    struct pstruct *ppst,
139                    int do_opt);
140
141 void calc_priors(double *priors,
142                  struct pstruct *ppst,
143                  struct f_struct *f_str,
144                  const unsigned char *aa1,
145                  int n1, int pseudocts);
146
147 double factorial (int a, int b);
148
149 int max_score(int *scores, int nsq);
150
151 int min_score(int *scores, int nsq);
152
153 double calc_spacefactor(struct f_struct *f_str);
154
155 void linreg(double *lnx, double *x, double *lny,
156             int n,
157             double *a, double *b, double *c, int start);