Debian Codegraph @

hmmer/src/impl_sse/optacc.c

raw symbols SCIP
1 /* Optimal accuracy alignment; SSE version.
2 *
3 * Contents:
4 * 1. Optimal accuracy alignment, DP fill
5 * 2. OA traceback
6 * 3. Benchmark driver
7 * 4. Unit tests
8 * 5. Test driver
9 * 6. Example
10 *
11 * SRE, Mon Aug 18 20:01:01 2008 [Casa de Gatos]
12 */
13 #include <p7_config.h>
14
15 #include <float.h>
16
17 #include <xmmintrin.h>
18 #include <emmintrin.h>
19
20 #include "easel.h"
21 #include "esl_sse.h"
22 #include "esl_vectorops.h"
23
24 #include "hmmer.h"
25
26
27 /*****************************************************************
28 * 1. Optimal accuracy alignment, DP fill
29 *****************************************************************/
30
31 /* Function: p7_OptimalAccuracy()
32 * Synopsis: DP fill of an optimal accuracy alignment calculation.
33 * Incept: SRE, Mon Aug 18 11:04:48 2008 [Janelia]
34 *
35 * Purpose: Calculates the fill step of the optimal accuracy decoding
36 * algorithm \citep{Kall05}.
37 *
38 * Caller provides the posterior decoding matrix <pp>,
39 * which was calculated by Forward/Backward on a target sequence
40 * of length <pp->L> using the query model <om>.
41 *
42 * Caller also provides a DP matrix <ox>, allocated for a full
43 * <om->M> by <L> comparison. The routine fills this in
44 * with OA scores.
45 *
46 * Args: om - query profile
47 * pp - posterior decoding matrix created by <p7_GPosteriorDecoding()>
48 * gx - RESULT: caller provided DP matrix for <gm->M> by <L>
49 * ret_e - RETURN: expected number of correctly decoded positions
50 *
51 * Returns: <eslOK> on success, and <*ret_e> contains the final OA
52 * score, which is the expected number of correctly decoded
53 * positions in the target sequence (up to <L>).
54 *
55 * Throws: (no abnormal error conditions)
56 */
57 int
58 p7_OptimalAccuracy(const P7_OPROFILE *om, const P7_OMX *pp, P7_OMX *ox, float *ret_e)
59 {
60 register __m128 mpv, dpv, ipv; /* previous row values */
61 register __m128 sv; /* temp storage of 1 curr row value in progress */
62 register __m128 xEv; /* E state: keeps max for Mk->E as we go */
63 register __m128 xBv; /* B state: splatted vector of B[i-1] for B->Mk calculations */
64 register __m128 dcv;
65 float *xmx = ox->xmx;
66 __m128 *dpc = ox->dpf[0]; /* current row, for use in {MDI}MO(dpp,q) access macro */
67 __m128 *dpp; /* previous row, for use in {MDI}MO(dpp,q) access macro */
68 __m128 *ppp; /* quads in the <pp> posterior probability matrix */
69 __m128 *tp; /* quads in the <om->tfv> transition scores */
70 __m128 zerov = _mm_setzero_ps();
71 __m128 infv = _mm_set1_ps(-eslINFINITY);
72 int M = om->M;
73 int Q = p7O_NQF(M);
74 int q;
75 int j;
76 int i;
77 float t1, t2;
78
79 ox->M = om->M;
80 ox->L = pp->L;
81 for (q = 0; q < Q; q++) MMO(dpc, q) = IMO(dpc,q) = DMO(dpc,q) = infv;
82 XMXo(0, p7X_E) = -eslINFINITY;
83 XMXo(0, p7X_N) = 0.;
84 XMXo(0, p7X_J) = -eslINFINITY;
85 XMXo(0, p7X_B) = 0.;
86 XMXo(0, p7X_C) = -eslINFINITY;
87
88 for (i = 1; i <= pp->L; i++)
89 {
90 dpp = dpc; /* previous DP row in OA matrix */
91 dpc = ox->dpf[i]; /* current DP row in OA matrix */
92 ppp = pp->dpf[i]; /* current row in the posterior probabilities per position */
93 tp = om->tfv; /* transition probabilities */
94 dcv = infv;
95 xEv = infv;
96 xBv = _mm_set1_ps(XMXo(i-1, p7X_B));
97
98 mpv = esl_sse_rightshift_ps(MMO(dpp,Q-1), infv); /* Right shifts by 4 bytes. 4,8,12,x becomes x,4,8,12. */
99 dpv = esl_sse_rightshift_ps(DMO(dpp,Q-1), infv);
100 ipv = esl_sse_rightshift_ps(IMO(dpp,Q-1), infv);
101 for (q = 0; q < Q; q++)
102 {
103 sv = _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), xBv); tp++;
104 sv = _mm_max_ps(sv, _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), mpv)); tp++;
105 sv = _mm_max_ps(sv, _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), ipv)); tp++;
106 sv = _mm_max_ps(sv, _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), dpv)); tp++;
107 sv = _mm_add_ps(sv, *ppp); ppp += 2;
108 xEv = _mm_max_ps(xEv, sv);
109
110 mpv = MMO(dpp,q);
111 dpv = DMO(dpp,q);
112 ipv = IMO(dpp,q);
113
114 MMO(dpc,q) = sv;
115 DMO(dpc,q) = dcv;
116
117 dcv = _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), sv); tp++;
118
119 sv = _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), mpv); tp++;
120 sv = _mm_max_ps(sv, _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), ipv)); tp++;
121 IMO(dpc,q) = _mm_add_ps(sv, *ppp); ppp++;
122 }
123
124 /* dcv has carried through from end of q loop above; store it
125 * in first pass, we add M->D and D->D path into DMX
126 */
127 dcv = esl_sse_rightshift_ps(dcv, infv);
128 tp = om->tfv + 7*Q; /* set tp to start of the DD's */
129 for (q = 0; q < Q; q++)
130 {
131 DMO(dpc, q) = _mm_max_ps(dcv, DMO(dpc, q));
132 dcv = _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), DMO(dpc,q)); tp++;
133 }
134
135 /* fully serialized D->D; can optimize later */
136 for (j = 1; j < 4; j++)
137 {
138 dcv = esl_sse_rightshift_ps(dcv, infv);
139 tp = om->tfv + 7*Q;
140 for (q = 0; q < Q; q++)
141 {
142 DMO(dpc, q) = _mm_max_ps(dcv, DMO(dpc, q));
143 dcv = _mm_and_ps(_mm_cmpgt_ps(*tp, zerov), dcv); tp++;
144 }
145 }
146
147 /* D->E paths */
148 for (q = 0; q < Q; q++) xEv = _mm_max_ps(xEv, DMO(dpc,q));
149
150 /* Specials */
151 esl_sse_hmax_ps(xEv, &(XMXo(i,p7X_E)));
152
153 t1 = ( (om->xf[p7O_J][p7O_LOOP] == 0.0) ? 0.0 : ox->xmx[(i-1)*p7X_NXCELLS+p7X_J] + pp->xmx[i*p7X_NXCELLS+p7X_J]);
154 t2 = ( (om->xf[p7O_E][p7O_LOOP] == 0.0) ? 0.0 : ox->xmx[ i *p7X_NXCELLS+p7X_E]);
155 ox->xmx[i*p7X_NXCELLS+p7X_J] = ESL_MAX(t1, t2);
156
157 t1 = ( (om->xf[p7O_C][p7O_LOOP] == 0.0) ? 0.0 : ox->xmx[(i-1)*p7X_NXCELLS+p7X_C] + pp->xmx[i*p7X_NXCELLS+p7X_C]);
158 t2 = ( (om->xf[p7O_E][p7O_MOVE] == 0.0) ? 0.0 : ox->xmx[ i *p7X_NXCELLS+p7X_E]);
159 ox->xmx[i*p7X_NXCELLS+p7X_C] = ESL_MAX(t1, t2);
160
161 ox->xmx[i*p7X_NXCELLS+p7X_N] = ((om->xf[p7O_N][p7O_LOOP] == 0.0) ? 0.0 : ox->xmx[(i-1)*p7X_NXCELLS+p7X_N] + pp->xmx[i*p7X_NXCELLS+p7X_N]);
162
163 t1 = ( (om->xf[p7O_N][p7O_MOVE] == 0.0) ? 0.0 : ox->xmx[i*p7X_NXCELLS+p7X_N]);
164 t2 = ( (om->xf[p7O_J][p7O_MOVE] == 0.0) ? 0.0 : ox->xmx[i*p7X_NXCELLS+p7X_J]);
165 ox->xmx[i*p7X_NXCELLS+p7X_B] = ESL_MAX(t1, t2);
166 }
167
168 *ret_e = ox->xmx[pp->L*p7X_NXCELLS+p7X_C];
169 return eslOK;
170 }
171 /*------------------- end, OA DP fill ---------------------------*/
172
173
174
175
176
177 /*****************************************************************
178 * 2. OA traceback
179 *****************************************************************/
180
181 static inline float get_postprob(const P7_OMX *pp, int scur, int sprv, int k, int i);
182
183 static inline int select_m(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k);
184 static inline int select_d(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k);
185 static inline int select_i(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k);
186 static inline int select_n(int i);
187 static inline int select_c(const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, int i);
188 static inline int select_j(const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, int i);
189 static inline int select_e(const P7_OPROFILE *om, const P7_OMX *ox, int i, int *ret_k);
190 static inline int select_b(const P7_OPROFILE *om, const P7_OMX *ox, int i);
191
192
193 /* Function: p7_OATrace()
194 * Synopsis: Optimal accuracy decoding: traceback.
195 * Incept: SRE, Mon Aug 18 13:53:33 2008 [Janelia]
196 *
197 * Purpose: The traceback stage of the optimal accuracy decoding algorithm
198 * \citep{Kall05}.
199 *
200 * Caller provides the OA DP matrix <ox> that was just
201 * calculated by <p7_OptimalAccuracyDP()>, as well as the
202 * posterior decoding matrix <pp>, which was calculated by
203 * Forward/Backward on a target sequence using the query
204 * model <gm>. Because the calculation depends only on
205 * <pp>, the target sequence itself need not be provided.
206 *
207 * The resulting optimal accuracy decoding traceback is put
208 * in a caller-provided traceback structure <tr>, which the
209 * caller has allocated for optional posterior probability
210 * annotation on residues (with <p7_trace_CreateWithPP()>,
211 * generally). This structure will be reallocated
212 * internally if necessary.
213 *
214 * Args: om - profile
215 * pp - posterior probability matrix
216 * ox - OA matrix to trace, LxM
217 * tr - storage for the recovered traceback
218 *
219 * Returns: <eslOK> on success.
220 *
221 * Throws: <eslEMEM> on allocation error.
222 * <eslEINVAL> if the trace <tr> isn't empty (needs to be Reuse()'d).
223 */
224 int
225 p7_OATrace(const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, P7_TRACE *tr)
226 {
227 int i = ox->L; /* position in sequence 1..L */
228 int k = 0; /* position in model 1..M */
229 int s0, s1; /* choice of a state */
230 float postprob;
231 int status;
232
233 if (tr->N != 0) ESL_EXCEPTION(eslEINVAL, "trace not empty; needs to be Reuse()'d?");
234
235 if ((status = p7_trace_AppendWithPP(tr, p7T_T, k, i, 0.0)) != eslOK) return status;
236 if ((status = p7_trace_AppendWithPP(tr, p7T_C, k, i, 0.0)) != eslOK) return status;
237
238 s0 = tr->st[tr->N-1];
239 while (s0 != p7T_S)
240 {
241 switch (s0) {
242 case p7T_M: s1 = select_m(om, ox, i, k); k--; i--; break;
243 case p7T_D: s1 = select_d(om, ox, i, k); k--; break;
244 case p7T_I: s1 = select_i(om, ox, i, k); i--; break;
245 case p7T_N: s1 = select_n(i); break;
246 case p7T_C: s1 = select_c(om, pp, ox, i); break;
247 case p7T_J: s1 = select_j(om, pp, ox, i); break;
248 case p7T_E: s1 = select_e(om, ox, i, &k); break;
249 case p7T_B: s1 = select_b(om, ox, i); break;
250 default: ESL_EXCEPTION(eslEINVAL, "bogus state in traceback");
251 }
252 if (s1 == -1) ESL_EXCEPTION(eslEINVAL, "OA traceback choice failed");
253
254 postprob = get_postprob(pp, s1, s0, k, i);
255 if ((status = p7_trace_AppendWithPP(tr, s1, k, i, postprob)) != eslOK) return status;
256
257 if ( (s1 == p7T_N || s1 == p7T_J || s1 == p7T_C) && s1 == s0) i--;
258 s0 = s1;
259 } /* end traceback, at S state */
260 tr->M = om->M;
261 tr->L = ox->L;
262 return p7_trace_Reverse(tr);
263 }
264
265 static inline float
266 get_postprob(const P7_OMX *pp, int scur, int sprv, int k, int i)
267 {
268 int Q = p7O_NQF(pp->M);
269 int q = (k-1) % Q; /* (q,r) is position of the current DP cell M(i,k) */
270 int r = (k-1) / Q;
271 union { __m128 v; float p[4]; } u;
272
273 switch (scur) {
274 case p7T_M: u.v = MMO(pp->dpf[i], q); return u.p[r];
275 case p7T_I: u.v = IMO(pp->dpf[i], q); return u.p[r];
276 case p7T_N: if (sprv == scur) return pp->xmx[i*p7X_NXCELLS+p7X_N];
277 case p7T_C: if (sprv == scur) return pp->xmx[i*p7X_NXCELLS+p7X_C];
278 case p7T_J: if (sprv == scur) return pp->xmx[i*p7X_NXCELLS+p7X_J];
279 default: return 0.0;
280 }
281 }
282
283 /* M(i,k) is reached from B(i-1), M(i-1,k-1), D(i-1,k-1), or I(i-1,k-1). */
284 static inline int
285 select_m(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k)
286 {
287 int Q = p7O_NQF(ox->M);
288 int q = (k-1) % Q; /* (q,r) is position of the current DP cell M(i,k) */
289 int r = (k-1) / Q;
290 __m128 *tp = om->tfv + 7*q; /* *tp now at start of transitions to cur cell M(i,k) */
291 __m128 xBv = _mm_set1_ps(ox->xmx[(i-1)*p7X_NXCELLS+p7X_B]);
292 __m128 mpv, dpv, ipv;
293 union { __m128 v; float p[4]; } u, tv;
294 float path[4];
295 int state[4] = { p7T_M, p7T_I, p7T_D, p7T_B };
296
297 if (q > 0) {
298 mpv = ox->dpf[i-1][(q-1)*3 + p7X_M];
299 dpv = ox->dpf[i-1][(q-1)*3 + p7X_D];
300 ipv = ox->dpf[i-1][(q-1)*3 + p7X_I];
301 } else {
302 mpv = esl_sse_rightshiftz_float(ox->dpf[i-1][(Q-1)*3 + p7X_M]);
303 dpv = esl_sse_rightshiftz_float(ox->dpf[i-1][(Q-1)*3 + p7X_D]);
304 ipv = esl_sse_rightshiftz_float(ox->dpf[i-1][(Q-1)*3 + p7X_I]);
305 }
306
307 /* paths are numbered so that most desirable choice in case of tie is first. */
308 u.v = xBv; tv.v = *tp; path[3] = ((tv.p[r] == 0.0) ? -eslINFINITY : u.p[r]); tp++;
309 u.v = mpv; tv.v = *tp; path[0] = ((tv.p[r] == 0.0) ? -eslINFINITY : u.p[r]); tp++;
310 u.v = ipv; tv.v = *tp; path[1] = ((tv.p[r] == 0.0) ? -eslINFINITY : u.p[r]); tp++;
311 u.v = dpv; tv.v = *tp; path[2] = ((tv.p[r] == 0.0) ? -eslINFINITY : u.p[r]);
312 return state[esl_vec_FArgMax(path, 4)];
313 }
314
315
316 /* D(i,k) is reached from M(i, k-1) or D(i,k-1). */
317 static inline int
318 select_d(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k)
319 {
320 int Q = p7O_NQF(ox->M);
321 int q = (k-1) % Q; /* (q,r) is position of the current DP cell D(i,k) */
322 int r = (k-1) / Q;
323 union { __m128 v; float p[4]; } mpv, dpv, tmdv, tddv;
324 float path[2];
325
326 if (q > 0) {
327 mpv.v = ox->dpf[i][(q-1)*3 + p7X_M];
328 dpv.v = ox->dpf[i][(q-1)*3 + p7X_D];
329 tmdv.v = om->tfv[7*(q-1) + p7O_MD];
330 tddv.v = om->tfv[7*Q + (q-1)];
331 } else {
332 mpv.v = esl_sse_rightshiftz_float(ox->dpf[i][(Q-1)*3 + p7X_M]);
333 dpv.v = esl_sse_rightshiftz_float(ox->dpf[i][(Q-1)*3 + p7X_D]);
334 tmdv.v = esl_sse_rightshiftz_float(om->tfv[7*(Q-1) + p7O_MD]);
335 tddv.v = esl_sse_rightshiftz_float(om->tfv[8*Q-1]);
336 }
337
338 path[0] = ((tmdv.p[r] == 0.0) ? -eslINFINITY : mpv.p[r]);
339 path[1] = ((tddv.p[r] == 0.0) ? -eslINFINITY : dpv.p[r]);
340 return ((path[0] >= path[1]) ? p7T_M : p7T_D);
341 }
342
343 /* I(i,k) is reached from M(i-1, k) or I(i-1,k). */
344 static inline int
345 select_i(const P7_OPROFILE *om, const P7_OMX *ox, int i, int k)
346 {
347 int Q = p7O_NQF(ox->M);
348 int q = (k-1) % Q; /* (q,r) is position of the current DP cell D(i,k) */
349 int r = (k-1) / Q;
350 __m128 *tp = om->tfv + 7*q + p7O_MI;
351 union { __m128 v; float p[4]; } tv, mpv, ipv;
352 float path[2];
353
354 mpv.v = ox->dpf[i-1][q*3 + p7X_M]; tv.v = *tp; path[0] = ((tv.p[r] == 0.0) ? -eslINFINITY : mpv.p[r]); tp++;
355 ipv.v = ox->dpf[i-1][q*3 + p7X_I]; tv.v = *tp; path[1] = ((tv.p[r] == 0.0) ? -eslINFINITY : ipv.p[r]);
356 return ((path[0] >= path[1]) ? p7T_M : p7T_I);
357 }
358
359 /* N(i) must come from N(i-1) for i>0; else it comes from S */
360 static inline int
361 select_n(int i)
362 {
363 return ((i==0) ? p7T_S : p7T_N);
364 }
365
366 /* C(i) is reached from E(i) or C(i-1). */
367 static inline int
368 select_c(const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, int i)
369 {
370 float path[2];
371 path[0] = ( (om->xf[p7O_C][p7O_LOOP] == 0.0) ? -eslINFINITY : ox->xmx[(i-1)*p7X_NXCELLS+p7X_C] + pp->xmx[i*p7X_NXCELLS+p7X_C]);
372 path[1] = ( (om->xf[p7O_E][p7O_MOVE] == 0.0) ? -eslINFINITY : ox->xmx[ i *p7X_NXCELLS+p7X_E]);
373 return ((path[0] > path[1]) ? p7T_C : p7T_E);
374 }
375
376 /* J(i) is reached from E(i) or J(i-1). */
377 static inline int
378 select_j(const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, int i)
379 {
380 float path[2];
381
382 path[0] = ( (om->xf[p7O_J][p7O_LOOP] == 0.0) ? -eslINFINITY : ox->xmx[(i-1)*p7X_NXCELLS+p7X_J] + pp->xmx[i*p7X_NXCELLS+p7X_J]);
383 path[1] = ( (om->xf[p7O_E][p7O_LOOP] == 0.0) ? -eslINFINITY : ox->xmx[ i *p7X_NXCELLS+p7X_E]);
384 return ((path[0] > path[1]) ? p7T_J : p7T_E);
385 }
386
387 /* E(i) is reached from any M(i, k=1..M) or D(i, k=2..M). */
388 /* This assumes all M_k->E, D_k->E are 1.0 */
389 static inline int
390 select_e(const P7_OPROFILE *om, const P7_OMX *ox, int i, int *ret_k)
391 {
392 int Q = p7O_NQF(ox->M);
393 __m128 *dp = ox->dpf[i];
394 union { __m128 v; float p[4]; } u;
395 float max = -eslINFINITY;
396 int smax, kmax;
397 int q,r;
398
399 /* precedence rules in case of ties here are a little tricky: M beats D: note the >= max! */
400 for (q = 0; q < Q; q++)
401 {
402 u.v = *dp; dp++; for (r = 0; r < 4; r++) if (u.p[r] >= max) { max = u.p[r]; smax = p7T_M; kmax = r*Q + q + 1; }
403 u.v = *dp; dp+=2; for (r = 0; r < 4; r++) if (u.p[r] > max) { max = u.p[r]; smax = p7T_D; kmax = r*Q + q + 1; }
404 }
405 *ret_k = kmax;
406 return smax;
407 }
408
409
410 /* B(i) is reached from N(i) or J(i). */
411 static inline int
412 select_b(const P7_OPROFILE *om, const P7_OMX *ox, int i)
413 {
414 float path[2];
415
416 path[0] = ( (om->xf[p7O_N][p7O_MOVE] == 0.0) ? -eslINFINITY : ox->xmx[i*p7X_NXCELLS+p7X_N]);
417 path[1] = ( (om->xf[p7O_J][p7O_MOVE] == 0.0) ? -eslINFINITY : ox->xmx[i*p7X_NXCELLS+p7X_J]);
418 return ((path[0] > path[1]) ? p7T_N : p7T_J);
419 }
420 /*---------------------- end, OA traceback ----------------------*/
421
422
423
424
425 /*****************************************************************
426 * 3. Benchmark driver
427 *****************************************************************/
428 #ifdef p7OPTACC_BENCHMARK
429 /*
430 icc -O3 -static -o optacc_benchmark -I.. -L.. -I../../easel -L../../easel -Dp7OPTACC_BENCHMARK optacc.c -lhmmer -leasel -lm
431
432 ./optacc_benchmark <hmmfile> runs benchmark on optimal accuracy fill and trace
433 ./optacc_benchmark -c -N1 <hmmfile> compare scores of SSE version to generic impl
434 ./optacc_benchmark -x -N1 <hmmfile> test that scores match trusted implementation.
435
436 RRM_1 (M=72) Caudal_act (M=136) SMC_N (M=1151)
437 ----------------- ------------------ ---------------
438 20 Aug 08: 13.11u (110 Mc/s) 23.39u (116 Mc/s) 332.62u (69 Mc/s)
439
440 */
441 #include <p7_config.h>
442
443 #include "easel.h"
444 #include "esl_alphabet.h"
445 #include "esl_getopts.h"
446 #include "esl_random.h"
447 #include "esl_randomseq.h"
448 #include "esl_stopwatch.h"
449
450 #include "hmmer.h"
451 #include "impl_sse.h"
452
453 static ESL_OPTIONS options[] = {
454 /* name type default env range toggles reqs incomp help docgroup*/
455 { "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 },
456 { "-c", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "-x", "compare scores to generic implementation (debug)", 0 },
457 { "-s", eslARG_INT, "42", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 },
458 { "-x", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "-c", "equate scores to trusted implementation (debug)", 0 },
459 { "-L", eslARG_INT, "400", NULL, "n>0", NULL, NULL, NULL, "length of random target seqs", 0 },
460 { "-N", eslARG_INT, "50000", NULL, "n>0", NULL, NULL, NULL, "number of random target seqs", 0 },
461 { "--notrace", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "only benchmark the DP fill stage", 0 },
462 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
463 };
464 static char usage[] = "[-options] <hmmfile>";
465 static char banner[] = "benchmark driver for optimal accuracy alignment, SSE version";
466
467 int
468 main(int argc, char **argv)
469 {
470 ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
471 char *hmmfile = esl_opt_GetArg(go, 1);
472 ESL_STOPWATCH *w = esl_stopwatch_Create();
473 ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
474 ESL_ALPHABET *abc = NULL;
475 P7_HMMFILE *hfp = NULL;
476 P7_HMM *hmm = NULL;
477 P7_BG *bg = NULL;
478 P7_PROFILE *gm = NULL;
479 P7_OPROFILE *om = NULL;
480 P7_GMX *gx1 = NULL;
481 P7_GMX *gx2 = NULL;
482 P7_OMX *ox1 = NULL;
483 P7_OMX *ox2 = NULL;
484 P7_TRACE *tr = NULL;
485 int L = esl_opt_GetInteger(go, "-L");
486 int N = esl_opt_GetInteger(go, "-N");
487 ESL_DSQ *dsq = malloc(sizeof(ESL_DSQ) * (L+2));
488 int i;
489 float fsc, bsc, accscore;
490 float fsc_g, bsc_g, accscore_g;
491 double Mcs;
492
493 p7_FLogsumInit();
494
495 if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile);
496 if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM");
497
498 bg = p7_bg_Create(abc); p7_bg_SetLength(bg, L);
499 gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL);
500 om = p7_oprofile_Create(gm->M, abc); p7_oprofile_Convert(gm, om);
501 p7_oprofile_ReconfigLength(om, L);
502
503 if (esl_opt_GetBoolean(go, "-x") && p7_FLogsumError(-0.4, -0.5) > 0.0001)
504 p7_Fail("-x here requires p7_Logsum() recompiled in slow exact mode");
505
506 ox1 = p7_omx_Create(gm->M, L, L);
507 ox2 = p7_omx_Create(gm->M, L, L);
508 tr = p7_trace_CreateWithPP();
509
510 esl_rsq_xfIID(r, bg->f, abc->K, L, dsq);
511 p7_Forward (dsq, L, om, ox1, &fsc);
512 p7_Backward(dsq, L, om, ox1, ox2, &bsc);
513 p7_Decoding(om, ox1, ox2, ox2);
514
515 esl_stopwatch_Start(w);
516 for (i = 0; i < N; i++)
517 {
518 p7_OptimalAccuracy(om, ox2, ox1, &accscore);
519
520 if (! esl_opt_GetBoolean(go, "--notrace"))
521 {
522 p7_OATrace(om, ox2, ox1, tr);
523 p7_trace_Reuse(tr);
524 }
525 }
526 esl_stopwatch_Stop(w);
527
528 Mcs = (double) N * (double) L * (double) gm->M * 1e-6 / (double) w->user;
529 esl_stopwatch_Display(stdout, w, "# CPU time: ");
530 printf("# M = %d\n", gm->M);
531 printf("# %.1f Mc/s\n", Mcs);
532
533 if (esl_opt_GetBoolean(go, "-c") || esl_opt_GetBoolean(go, "-x") )
534 {
535 gx1 = p7_gmx_Create(gm->M, L);
536 gx2 = p7_gmx_Create(gm->M, L);
537
538 p7_GForward (dsq, L, gm, gx1, &fsc_g);
539 p7_GBackward(dsq, L, gm, gx2, &bsc_g);
540 p7_GDecoding(gm, gx1, gx2, gx2);
541 p7_GOptimalAccuracy(gm, gx2, gx1, &accscore_g);
542
543 printf("generic: fwd=%8.4f bck=%8.4f acc=%8.4f\n", fsc_g, bsc_g, accscore_g);
544 printf("SSE: fwd=%8.4f bck=%8.4f acc=%8.4f\n", fsc, bsc, accscore);
545
546 p7_gmx_Destroy(gx1);
547 p7_gmx_Destroy(gx2);
548 }
549
550 free(dsq);
551 p7_omx_Destroy(ox1);
552 p7_omx_Destroy(ox2);
553 p7_trace_Destroy(tr);
554 p7_oprofile_Destroy(om);
555 p7_profile_Destroy(gm);
556 p7_bg_Destroy(bg);
557 p7_hmm_Destroy(hmm);
558 p7_hmmfile_Close(hfp);
559 esl_alphabet_Destroy(abc);
560 esl_stopwatch_Destroy(w);
561 esl_randomness_Destroy(r);
562 esl_getopts_Destroy(go);
563 return 0;
564 }
565 #endif /*p7OPTACC_BENCHMARK*/
566 /*---------------- end, benchmark driver ------------------------*/
567
568
569
570
571 /*****************************************************************
572 * 4. Unit tests
573 *****************************************************************/
574 #ifdef p7OPTACC_TESTDRIVE
575 #include "esl_alphabet.h"
576 #include "esl_getopts.h"
577 #include "esl_random.h"
578 /*
579 * 1. Compare accscore to GOptimalAccuracy().
580 * 2. Compare trace to GOATrace().
581 *
582 * Note: This test is subject to some expected noise and can fail
583 * for entirely innocent reasons. Generic Forward/Backward calculations with
584 * p7_GForward(), p7_GBackward() use coarse-grain table lookups to sum
585 * log probabilities, and sufficient roundoff error can accumulate to
586 * change the optimal accuracy traceback, causing this test to fail.
587 * So, if optacc_utest fails, before you go looking for bugs, first
588 * go to ../logsum.c, change the #ifdef to activate the slow/accurate
589 * version, recompile and rerun optacc_utest. If the failure goes away,
590 * you can ignore it. - SRE, Wed Dec 17 09:45:31 2008
591 */
592 static void
593 utest_optacc(ESL_GETOPTS *go, ESL_RANDOMNESS *r, ESL_ALPHABET *abc, P7_BG *bg, int M, int L, int N)
594 {
595 char *msg = "optimal accuracy unit test failed";
596 P7_HMM *hmm = NULL;
597 P7_PROFILE *gm = NULL;
598 P7_OPROFILE *om = NULL;
599 ESL_SQ *sq = esl_sq_CreateDigital(abc);
600 P7_OMX *ox1 = p7_omx_Create(M, L, L);
601 P7_OMX *ox2 = p7_omx_Create(M, L, L);
602 P7_GMX *gx1 = p7_gmx_Create(M, L);
603 P7_GMX *gx2 = p7_gmx_Create(M, L);
604 P7_TRACE *tr = p7_trace_CreateWithPP();
605 P7_TRACE *trg = p7_trace_CreateWithPP();
606 P7_TRACE *tro = p7_trace_CreateWithPP();
607 float accscore_o;
608 float fsc, bsc, accscore;
609 float fsc_g, bsc_g, accscore_g, accscore_g2;
610 float pptol = 0.01;
611 float sctol = 0.001;
612 float gtol;
613
614 p7_FLogsumInit();
615 gtol = ( (p7_FLogsumError(-0.4, -0.5) > 0.0001) ? 0.1 : 0.001);
616
617 if (p7_oprofile_Sample(r, abc, bg, M, L, &hmm, &gm, &om)!= eslOK) esl_fatal(msg);
618 while (N--)
619 {
620 if (p7_ProfileEmit(r, hmm, gm, bg, sq, tro) != eslOK) esl_fatal(msg);
621
622 if (p7_omx_GrowTo(ox1, M, sq->n, sq->n) != eslOK) esl_fatal(msg);
623 if (p7_omx_GrowTo(ox2, M, sq->n, sq->n) != eslOK) esl_fatal(msg);
624 if (p7_gmx_GrowTo(gx1, M, sq->n) != eslOK) esl_fatal(msg);
625 if (p7_gmx_GrowTo(gx2, M, sq->n) != eslOK) esl_fatal(msg);
626
627 if (p7_Forward (sq->dsq, sq->n, om, ox1, &fsc) != eslOK) esl_fatal(msg);
628 if (p7_Backward(sq->dsq, sq->n, om, ox1, ox2, &bsc) != eslOK) esl_fatal(msg);
629 if (p7_Decoding(om, ox1, ox2, ox2) != eslOK) esl_fatal(msg);
630 if (p7_OptimalAccuracy(om, ox2, ox1, &accscore) != eslOK) esl_fatal(msg);
631
632 #if 0
633 p7_omx_FDeconvert(ox1, gx1);
634 p7_gmx_Dump(stdout, gx1, p7_DEFAULT);
635 p7_omx_FDeconvert(ox2, gx1);
636 p7_gmx_Dump(stdout, gx1, p7_DEFAULT);
637 #endif
638 if (p7_OATrace(om, ox2, ox1, tr) != eslOK) esl_fatal(msg);
639
640 if (p7_GForward (sq->dsq, sq->n, gm, gx1, &fsc_g) != eslOK) esl_fatal(msg);
641 if (p7_GBackward(sq->dsq, sq->n, gm, gx2, &bsc_g) != eslOK) esl_fatal(msg);
642
643 #if 0
644 p7_gmx_Dump(stdout, gx1, p7_DEFAULT); /* fwd */
645 p7_gmx_Dump(stdout, gx2, p7_DEFAULT); /* bck */
646 #endif
647
648 if (p7_GDecoding(gm, gx1, gx2, gx2) != eslOK) esl_fatal(msg);
649 if (p7_GOptimalAccuracy(gm, gx2, gx1, &accscore_g) != eslOK) esl_fatal(msg);
650
651 #if 0
652 p7_gmx_Dump(stdout, gx1, p7_DEFAULT); /* oa */
653 p7_gmx_Dump(stdout, gx2, p7_DEFAULT); /* pp */
654 #endif
655 if (p7_GOATrace(gm, gx2, gx1, trg) != eslOK) esl_fatal(msg);
656
657 if (p7_trace_SetPP(tro, gx2) != eslOK) esl_fatal(msg);
658
659 if (esl_opt_GetBoolean(go, "--traces"))
660 {
661 p7_trace_Dump(stdout, tro, gm, sq->dsq);
662 p7_trace_Dump(stdout, tr, gm, sq->dsq);
663 p7_trace_Dump(stdout, trg, gm, sq->dsq);
664 }
665
666 if (p7_trace_Validate(tr, abc, sq->dsq, NULL) != eslOK) esl_fatal(msg);
667 if (p7_trace_Validate(trg, abc, sq->dsq, NULL) != eslOK) esl_fatal(msg);
668 if (p7_trace_Compare(tr, trg, pptol) != eslOK) esl_fatal(msg);
669
670 accscore_o = p7_trace_GetExpectedAccuracy(tro); /* according to gx2; see p7_trace_SetPP() call above */
671 accscore_g2 = p7_trace_GetExpectedAccuracy(trg);
672
673 #if 0
674 printf("%f %f %f %f\n", accscore, accscore_g, accscore_g2, accscore_o);
675 #endif
676
677 if (esl_FCompare_old(fsc, bsc, sctol) != eslOK) esl_fatal(msg);
678 if (esl_FCompare_old(fsc_g, bsc_g, gtol) != eslOK) esl_fatal(msg);
679 if (esl_FCompare_old(fsc, fsc_g, gtol) != eslOK) esl_fatal(msg);
680 if (esl_FCompare_old(accscore, accscore_g, gtol) != eslOK) esl_fatal(msg);
681 if (esl_FCompare_old(accscore_g, accscore_g2, gtol) != eslOK) esl_fatal(msg);
682 if (accscore_g2 < accscore_o) esl_fatal(msg);
683 /* the above deserves explanation:
684 * - accscore_o is the accuracy of the originally emitted trace, according
685 * to the generic posterior decoding matrix <gx2>. This is a lower bound
686 * on the expected # of accurately aligned residues found by a DP
687 * optimization.
688 * - accscore is the accuracy found by the fast (vector) code DP implementation.
689 * - accscore_g is the accuracy found by the generic DP implementation.
690 * accscore and accscore_g should be nearly identical,
691 * within tolerance of roundoff error accumulation and
692 * the imprecision of Logsum() tables.
693 * - accscore_g2 is the accuracy of the traceback identified by the generic
694 * DP implementation. It should be identical (within order-of-evaluation
695 * roundoff error) to accscore_g.
696 *
697 * the "accscore_g2 < accscore_o" test is carefully contrived.
698 * accscore_o is a theoretical lower bound but because of fp error,
699 * accscore and (much more rarely) even accscore_g can exceed accscore_o.
700 * accscore_g2, however, is calculated with identical order of evaluation
701 * as accscore_o if the optimal trace does turn out to be identical to
702 * the originally emitted trace. It should be extremely unlikely (though
703 * not impossible) for accscore_o to exceed accscore_g2. (The DP algorithm
704 * would have to identify a trace that was different than the original trace,
705 * which the DP algorithm, by order-of-evaluation, assigned higher accuracy,
706 * but order-of-evaluation in traceback dependent code assigned lower accuracy.
707 * [xref J5/29]
708 */
709
710 esl_sq_Reuse(sq);
711 p7_trace_Reuse(tr);
712 p7_trace_Reuse(trg);
713 p7_trace_Reuse(tro);
714 }
715
716 p7_trace_Destroy(tro);
717 p7_trace_Destroy(trg);
718 p7_trace_Destroy(tr);
719 p7_gmx_Destroy(gx2);
720 p7_gmx_Destroy(gx1);
721 p7_omx_Destroy(ox2);
722 p7_omx_Destroy(ox1);
723 esl_sq_Destroy(sq);
724 p7_oprofile_Destroy(om);
725 p7_profile_Destroy(gm);
726 p7_hmm_Destroy(hmm);
727 }
728
729 #endif /*p7OPTACC_TESTDRIVE*/
730 /*------------------- end, unit tests ---------------------------*/
731
732
733
734
735 /*****************************************************************
736 * 5. Test driver
737 *****************************************************************/
738 #ifdef p7OPTACC_TESTDRIVE
739
740 /* Failures in this test are to be expected, if you change the defaults.
741 * The default RNG seed of 41 is very carefully chosen! Most seeds will
742 * cause this test to fail. (Only 13 and 41 work for seeds 1..50.)
743 *
744 * The generic fwd/bck algorithms work in log space and suffer from a
745 * small amount of imprecision, not only from the use of FLogsum()'s
746 * table-driven approximation, but even (apparently) inherent in log()
747 * and exp(). To minimize this, the generic decoding algorithm burns
748 * time renormalizing each row. Still, it's a problem. See notes at
749 * the header of utest_optacc() for more info.
750 *
751 * Another expected failure mode is when a fwd, bck nat score are close to
752 * 0.0; FCompare() can evaluate two close-to-zero numbers as "different"
753 * even if their absolute diff is negligible. (I suppose I could fix this.)
754 */
755
756 /*
757 gcc -g -Wall -msse2 -std=gnu99 -o optacc_utest -I.. -L.. -I../../easel -L../../easel -Dp7OPTACC_TESTDRIVE optacc.c -lhmmer -leasel -lm
758 ./optacc_utest
759 */
760 #include <p7_config.h>
761
762 #include "easel.h"
763 #include "esl_alphabet.h"
764 #include "esl_getopts.h"
765
766 #include "hmmer.h"
767 #include "impl_sse.h"
768
769 static ESL_OPTIONS options[] = {
770 /* name type default env range toggles reqs incomp help docgroup*/
771 { "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 },
772 { "-s", eslARG_INT, "41", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 },
773 { "-L", eslARG_INT, "50", NULL, NULL, NULL, NULL, NULL, "size of random sequences to sample", 0 },
774 { "-M", eslARG_INT, "45", NULL, NULL, NULL, NULL, NULL, "size of random models to sample", 0 },
775 { "-N", eslARG_INT, "20", NULL, NULL, NULL, NULL, NULL, "number of random sequences to sample", 0 },
776 { "--traces", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "dump all tracebacks", 0 },
777 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
778 };
779 static char usage[] = "[-options]";
780 static char banner[] = "test driver for SSE Forward, Backward implementations";
781
782 int
783 main(int argc, char **argv)
784 {
785 ESL_GETOPTS *go = p7_CreateDefaultApp(options, 0, argc, argv, banner, usage);
786 ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
787 ESL_ALPHABET *abc = NULL;
788 P7_BG *bg = NULL;
789 int M = esl_opt_GetInteger(go, "-M");
790 int L = esl_opt_GetInteger(go, "-L");
791 int N = esl_opt_GetInteger(go, "-N");
792
793 /* first round of tests for DNA alphabets. */
794 if ((abc = esl_alphabet_Create(eslDNA)) == NULL) esl_fatal("failed to create alphabet");
795 if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
796
797 utest_optacc(go, r, abc, bg, M, L, N); /* normal sized models */
798 utest_optacc(go, r, abc, bg, 1, L, 10); /* size 1 models */
799 utest_optacc(go, r, abc, bg, M, 1, 10); /* size 1 sequences */
800
801 esl_alphabet_Destroy(abc);
802 p7_bg_Destroy(bg);
803
804 /* Second round of tests for amino alphabets. */
805 if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet");
806 if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
807
808 utest_optacc(go, r, abc, bg, M, L, N);
809 utest_optacc(go, r, abc, bg, 1, L, 10);
810 utest_optacc(go, r, abc, bg, M, 1, 10);
811
812 esl_alphabet_Destroy(abc);
813 p7_bg_Destroy(bg);
814
815 esl_getopts_Destroy(go);
816 esl_randomness_Destroy(r);
817 return eslOK;
818 }
819 #endif /*p7OPTACC_TESTDRIVE*/
820 /*------------------ end, test driver ---------------------------*/
821
822
823
824
825 /*****************************************************************
826 * 6. Example
827 *****************************************************************/
828 #ifdef p7OPTACC_EXAMPLE
829 /*
830 gcc -g -Wall -o optacc_example -Dp7OPTACC_EXAMPLE -I.. -I../../easel -L.. -L../../easel optacc.c -lhmmer -leasel -lm
831 ./optacc_example <hmmfile> <seqfile>
832 */
833 #include <p7_config.h>
834
835 #include "easel.h"
836 #include "esl_alphabet.h"
837 #include "esl_getopts.h"
838 #include "esl_sq.h"
839 #include "esl_sqio.h"
840
841 #include "hmmer.h"
842 #include "impl_sse.h"
843
844 static ESL_OPTIONS options[] = {
845 /* name type default env range toggles reqs incomp help docgroup*/
846 { "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 },
847 { "-d", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "dump posterior residue decoding matrix", 0 },
848 { "-m", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "dump OA matrix", 0 },
849 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
850 };
851 static char usage[] = "[-options] <hmmfile> <seqfile>";
852 static char banner[] = "example of optimal accuracy alignment, SSE implementation";
853
854 int
855 main(int argc, char **argv)
856 {
857 ESL_GETOPTS *go = p7_CreateDefaultApp(options, 2, argc, argv, banner, usage);
858 char *hmmfile = esl_opt_GetArg(go, 1);
859 char *seqfile = esl_opt_GetArg(go, 2);
860 ESL_ALPHABET *abc = NULL;
861 P7_HMMFILE *hfp = NULL;
862 P7_HMM *hmm = NULL;
863 P7_BG *bg = NULL;
864 P7_PROFILE *gm = NULL;
865 P7_OPROFILE *om = NULL;
866 P7_OMX *ox1 = NULL;
867 P7_OMX *ox2 = NULL;
868 P7_GMX *gx = NULL;
869 ESL_SQ *sq = NULL;
870 ESL_SQFILE *sqfp = NULL;
871 P7_TRACE *tr = NULL;
872 int format = eslSQFILE_UNKNOWN;
873 char errbuf[eslERRBUFSIZE];
874 float fsc, bsc;
875 float accscore;
876 int status;
877
878 /* Read in one HMM */
879 if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile);
880 if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM");
881 p7_hmmfile_Close(hfp);
882
883 /* Read in one sequence */
884 sq = esl_sq_CreateDigital(abc);
885 status = esl_sqfile_OpenDigital(abc, seqfile, format, NULL, &sqfp);
886 if (status == eslENOTFOUND) p7_Fail("No such file.");
887 else if (status == eslEFORMAT) p7_Fail("Format unrecognized.");
888 else if (status == eslEINVAL) p7_Fail("Can't autodetect stdin or .gz.");
889 else if (status != eslOK) p7_Fail("Open failed, code %d.", status);
890 if (esl_sqio_Read(sqfp, sq) != eslOK) p7_Fail("Failed to read sequence");
891 esl_sqfile_Close(sqfp);
892
893 /* Configure a profile from the HMM */
894 bg = p7_bg_Create(abc); p7_bg_SetLength(bg, sq->n);
895 gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, sq->n, p7_LOCAL); /* multihit local: H3 default */
896 om = p7_oprofile_Create(gm->M, abc); p7_oprofile_Convert(gm, om);
897
898 /* Allocations */
899 ox1 = p7_omx_Create(gm->M, sq->n, sq->n);
900 ox2 = p7_omx_Create(gm->M, sq->n, sq->n);
901 gx = p7_gmx_Create(gm->M, sq->n);
902 tr = p7_trace_CreateWithPP();
903 p7_FLogsumInit();
904
905 /* Run Forward, Backward; do OA fill and trace */
906 p7_Forward (sq->dsq, sq->n, om, ox1, &fsc);
907 p7_Backward(sq->dsq, sq->n, om, ox1, ox2, &bsc);
908 p7_Decoding(om, ox1, ox2, ox2); /* <gx2> is now the posterior decoding matrix */
909 p7_OptimalAccuracy(om, ox2, ox1, &accscore); /* <gx1> is now the OA matrix */
910 p7_OATrace(om, ox2, ox1, tr);
911
912 if (esl_opt_GetBoolean(go, "-d")) { p7_omx_FDeconvert(ox2, gx); p7_gmx_Dump(stdout, gx, p7_DEFAULT); }
913 if (esl_opt_GetBoolean(go, "-m")) { p7_omx_FDeconvert(ox1, gx); p7_gmx_Dump(stdout, gx, p7_DEFAULT); }
914
915 p7_trace_Dump(stdout, tr, gm, sq->dsq);
916
917 if (p7_trace_Validate(tr, abc, sq->dsq, errbuf) != eslOK) p7_Die("trace fails validation:\n%s\n", errbuf);
918
919 printf("fwd = %.4f nats\n", fsc);
920 printf("bck = %.4f nats\n", bsc);
921 printf("acc = %.4f (%.2f%%)\n", accscore, accscore * 100. / (float) sq->n);
922
923 /* Cleanup */
924 esl_sq_Destroy(sq);
925 p7_trace_Destroy(tr);
926 p7_omx_Destroy(ox1);
927 p7_omx_Destroy(ox2);
928 p7_gmx_Destroy(gx);
929 p7_oprofile_Destroy(om);
930 p7_profile_Destroy(gm);
931 p7_bg_Destroy(bg);
932 p7_hmm_Destroy(hmm);
933 esl_alphabet_Destroy(abc);
934 esl_getopts_Destroy(go);
935 return 0;
936 }
937 #endif /*p7OPTACC_EXAMPLE*/
938 /*-------------------- end, example -----------------------------*/
939
940
941
942