1 | #define USE_XCED 0 |
---|
2 | |
---|
3 | #if USE_XCED |
---|
4 | #include "config.h" |
---|
5 | #include "share.h" |
---|
6 | #else |
---|
7 | #endif |
---|
8 | |
---|
9 | #include <stdio.h> |
---|
10 | #include <stdlib.h> |
---|
11 | #include <stddef.h> |
---|
12 | #include <sys/types.h> |
---|
13 | #include <string.h> |
---|
14 | #include <unistd.h> |
---|
15 | #include <math.h> |
---|
16 | #include <ctype.h> |
---|
17 | #include "mtxutl.h" |
---|
18 | #include <float.h> |
---|
19 | #ifdef enablemultithread |
---|
20 | #include <pthread.h> |
---|
21 | #endif |
---|
22 | |
---|
23 | #define VERSION "7.055b" |
---|
24 | #define SHOWVERSION fprintf( stderr, "%s (%s) Version " VERSION " alg=%c, model=%s\n%d thread(s)\n", progName( argv[0] ), (dorp=='d')?"nuc":"aa", alg, modelname, nthread ) |
---|
25 | |
---|
26 | #define FFT_THRESHOLD 80 |
---|
27 | #define FFT_WINSIZE_P 20 |
---|
28 | #define FFT_WINSIZE_D 100 |
---|
29 | #define DISPSEQF 60 |
---|
30 | #define DISPSITEI 0 |
---|
31 | #define MAXITERATION 500 |
---|
32 | #define M 500000 /* njob no saidaiti */ |
---|
33 | #define N 5000000 /* nlen no saidaiti */ |
---|
34 | #define MAXSEG 100000 |
---|
35 | #define B 256 |
---|
36 | #define C 60 /* 1 gyou no mojisuu */ |
---|
37 | #define D 6 |
---|
38 | #define rnd() ( ( 1.0 / ( RAND_MAX + 1.0 ) ) * rand() ) |
---|
39 | #define MAX(X,Y) ( ((X)>(Y))?(X):(Y) ) |
---|
40 | #define MIN(X,Y) ( ((X)<(Y))?(X):(Y) ) |
---|
41 | #define G(X) ( ((X)>(0))?(X):(0) ) |
---|
42 | #define BEFF 1.0 /* 0.6 ni suruto zureru */ |
---|
43 | #define WIN 3 |
---|
44 | #define SGAPP -1000 |
---|
45 | #define GETA2 0.001 |
---|
46 | #define GETA3 0.001 |
---|
47 | #define NOTSPECIFIED 100009 |
---|
48 | #define SUEFF 0.1 /* upg/(spg+upg) -> sueff.sed */ |
---|
49 | #define DIVLOCAL 0 |
---|
50 | #define INTMTXSCALE 1000000.0 |
---|
51 | #define JTT 201 |
---|
52 | #define TM 202 |
---|
53 | |
---|
54 | extern char modelname[100]; |
---|
55 | extern int njob, nlenmax; |
---|
56 | extern int amino_n[0x80]; |
---|
57 | extern char amino_grp[0x80]; |
---|
58 | extern int amino_dis[0x80][0x80]; |
---|
59 | extern int amino_disLN[0x80][0x80]; |
---|
60 | extern double amino_dis_consweight_multi[0x80][0x80]; |
---|
61 | extern int n_dis[26][26]; |
---|
62 | extern int n_disFFT[26][26]; |
---|
63 | extern float n_dis_consweight_multi[26][26]; |
---|
64 | extern char amino[26]; |
---|
65 | extern double polarity[20]; |
---|
66 | extern double volume[20]; |
---|
67 | extern int ribosumdis[37][37]; |
---|
68 | |
---|
69 | extern int ppid; |
---|
70 | extern double thrinter; |
---|
71 | extern double fastathreshold; |
---|
72 | extern int pslocal, ppslocal; |
---|
73 | extern int constraint; |
---|
74 | extern int divpairscore; |
---|
75 | extern int fmodel; // 1-> fmodel 0->default -1->raw |
---|
76 | extern int nblosum; // 45, 50, 62, 80 |
---|
77 | extern int kobetsubunkatsu; |
---|
78 | extern int bunkatsu; |
---|
79 | extern int dorp; |
---|
80 | extern int niter; |
---|
81 | extern int contin; |
---|
82 | extern int calledByXced; |
---|
83 | extern int devide; |
---|
84 | extern int scmtd; |
---|
85 | extern int weight; |
---|
86 | extern int utree; |
---|
87 | extern int tbutree; |
---|
88 | extern int refine; |
---|
89 | extern int check; |
---|
90 | extern double cut; |
---|
91 | extern int cooling; |
---|
92 | extern int penalty, ppenalty, penaltyLN; |
---|
93 | extern int RNApenalty, RNAppenalty; |
---|
94 | extern int RNApenalty_ex, RNAppenalty_ex; |
---|
95 | extern int penalty_ex, ppenalty_ex, penalty_exLN; |
---|
96 | extern int penalty_EX, ppenalty_EX; |
---|
97 | extern int penalty_OP, ppenalty_OP; |
---|
98 | extern int offset, poffset, offsetLN, offsetFFT; |
---|
99 | extern int RNAthr, RNApthr; |
---|
100 | extern int scoremtx; |
---|
101 | extern int TMorJTT; |
---|
102 | extern char use_fft; |
---|
103 | extern char force_fft; |
---|
104 | extern int nevermemsave; |
---|
105 | extern int fftscore; |
---|
106 | extern int fftWinSize; |
---|
107 | extern int fftThreshold; |
---|
108 | extern int fftRepeatStop; |
---|
109 | extern int fftNoAnchStop; |
---|
110 | extern int divWinSize; |
---|
111 | extern int divThreshold; |
---|
112 | extern int disp; |
---|
113 | extern int outgap; |
---|
114 | extern char alg; |
---|
115 | extern int cnst; |
---|
116 | extern int mix; |
---|
117 | extern int tbitr; |
---|
118 | extern int tbweight; |
---|
119 | extern int tbrweight; |
---|
120 | extern int disopt; |
---|
121 | extern int pamN; |
---|
122 | extern int checkC; |
---|
123 | extern float geta2; |
---|
124 | extern int treemethod; |
---|
125 | extern int kimuraR; |
---|
126 | extern char *swopt; |
---|
127 | extern int fftkeika; |
---|
128 | extern int score_check; |
---|
129 | extern char *inputfile; |
---|
130 | extern char *addfile; |
---|
131 | extern int addprofile; |
---|
132 | extern float consweight_multi; |
---|
133 | extern float consweight_rna; |
---|
134 | extern char RNAscoremtx; |
---|
135 | |
---|
136 | extern char *signalSM; |
---|
137 | extern FILE *prep_g; |
---|
138 | extern FILE *trap_g; |
---|
139 | extern char **seq_g; |
---|
140 | extern char **res_g; |
---|
141 | extern int rnakozo; |
---|
142 | extern char rnaprediction; |
---|
143 | |
---|
144 | /* sengen no ichi ha koko dake de ha nai */ |
---|
145 | extern void constants(); |
---|
146 | extern char **Calignm1(); |
---|
147 | extern char **Dalignm1(); |
---|
148 | extern char **align0(); |
---|
149 | extern double Cscore_m_1( char **, int, int, double ** ); |
---|
150 | extern double score_m_1( char **, int, int, double ** ); |
---|
151 | extern double score_calc0( char **, int, double **, int ); |
---|
152 | extern char seqcheck( char ** ); |
---|
153 | extern float substitution( char *, char * ); |
---|
154 | extern float substitution_score( char *, char * ); |
---|
155 | extern float substitution_nid( char *, char * ); |
---|
156 | extern float substitution_hosei( char *, char * ); |
---|
157 | extern double ipower( double, int ); |
---|
158 | extern float translate_and_Calign(); |
---|
159 | extern float A__align(); |
---|
160 | extern float A__align11(); |
---|
161 | extern float A__align_gapmap(); |
---|
162 | extern float partA__align(); |
---|
163 | extern float L__align11(); |
---|
164 | extern float G__align11(); |
---|
165 | extern float Falign(); |
---|
166 | extern float Falign_localhom(); |
---|
167 | extern float Conalign(); |
---|
168 | extern float Aalign(); |
---|
169 | extern float imp_match_out_sc( int, int ); |
---|
170 | extern float part_imp_match_out_sc( int, int ); |
---|
171 | extern void ErrorExit(); |
---|
172 | extern void cpmx_calc(); |
---|
173 | extern void intergroup_score( char **, char **, double *, double *, int, int, int, double * ); |
---|
174 | extern int conjuctionfortbfast(); |
---|
175 | extern int fastconjuction(); |
---|
176 | extern char seqcheck( char ** ); |
---|
177 | |
---|
178 | typedef struct _LocalHom |
---|
179 | { |
---|
180 | int nokori; |
---|
181 | struct _LocalHom *next; |
---|
182 | struct _LocalHom *last; |
---|
183 | int start1; |
---|
184 | int end1; |
---|
185 | int start2; |
---|
186 | int end2; |
---|
187 | double opt; |
---|
188 | int overlapaa; |
---|
189 | int extended; |
---|
190 | double importance; |
---|
191 | float fimportance; |
---|
192 | double wimportance; |
---|
193 | char korh; |
---|
194 | } LocalHom; |
---|
195 | |
---|
196 | typedef struct _NodeInCub |
---|
197 | { |
---|
198 | int step; |
---|
199 | int LorR; |
---|
200 | } NodeInCub; |
---|
201 | |
---|
202 | typedef struct _Node |
---|
203 | { |
---|
204 | struct _Node *children[3]; |
---|
205 | int tmpChildren[3]; |
---|
206 | double length[3]; |
---|
207 | double *weightptr[3]; |
---|
208 | int top[3]; |
---|
209 | int *members[3]; |
---|
210 | } Node; |
---|
211 | |
---|
212 | typedef struct _Segment |
---|
213 | { |
---|
214 | int start; |
---|
215 | int end; |
---|
216 | int center; |
---|
217 | double score; |
---|
218 | int skipForeward; |
---|
219 | int skipBackward; |
---|
220 | struct _Segment *pair; |
---|
221 | int number; |
---|
222 | } Segment; |
---|
223 | |
---|
224 | typedef struct _Segments |
---|
225 | { |
---|
226 | Segment group1; |
---|
227 | Segment group2; |
---|
228 | int number1; |
---|
229 | int number2; |
---|
230 | } Segments; |
---|
231 | |
---|
232 | typedef struct _Bchain |
---|
233 | { |
---|
234 | struct _Bchain *next; |
---|
235 | struct _Bchain *prev; |
---|
236 | int pos; |
---|
237 | } Bchain; |
---|
238 | |
---|
239 | typedef struct _Achain |
---|
240 | { |
---|
241 | int next; |
---|
242 | int prev; |
---|
243 | // int curr; |
---|
244 | } Achain; |
---|
245 | |
---|
246 | |
---|
247 | typedef struct _Fukusosuu |
---|
248 | { |
---|
249 | double R; |
---|
250 | double I; |
---|
251 | } Fukusosuu; |
---|
252 | |
---|
253 | typedef struct _Gappattern |
---|
254 | { |
---|
255 | int len; |
---|
256 | float freq; |
---|
257 | } Gappat; |
---|
258 | |
---|
259 | typedef struct _RNApair |
---|
260 | { |
---|
261 | int uppos; |
---|
262 | float upscore; |
---|
263 | int downpos; |
---|
264 | float downscore; |
---|
265 | int bestpos; |
---|
266 | float bestscore; |
---|
267 | } RNApair; |
---|
268 | |
---|
269 | typedef struct _Treedep |
---|
270 | { |
---|
271 | int child0; |
---|
272 | int child1; |
---|
273 | int done; |
---|
274 | float distfromtip; |
---|
275 | } Treedep; |
---|
276 | |
---|
277 | typedef struct _Addtree |
---|
278 | { |
---|
279 | int nearest; |
---|
280 | float dist1; |
---|
281 | char *neighbors; |
---|
282 | float dist2; |
---|
283 | } Addtree; |
---|
284 | |
---|
285 | |
---|
286 | #include "fft.h" |
---|
287 | #include "dp.h" |
---|
288 | #include "functions.h" |
---|
289 | |
---|
290 | #ifdef enablemultithread |
---|
291 | #define TLS __thread |
---|
292 | #else |
---|
293 | #define TLS |
---|
294 | #endif |
---|
295 | |
---|
296 | extern TLS int commonAlloc1; |
---|
297 | extern TLS int commonAlloc2; |
---|
298 | extern TLS int **commonIP; |
---|
299 | extern TLS int **commonJP; |
---|
300 | extern int nthread; |
---|
301 | extern int randomseed; |
---|
302 | extern int parallelizationstrategy; |
---|
303 | #define BESTFIRST 0 |
---|
304 | #define BAATARI0 1 |
---|
305 | #define BAATARI1 2 |
---|
306 | #define BAATARI2 3 |
---|
307 | |
---|
308 | extern int scoreout; |
---|
309 | extern int outnumber; |
---|
310 | |
---|
311 | extern TLS char *newgapstr; |
---|