| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#include <p7_config.h> |
| 14 |
|
| 15 |
#include "easel.h" |
| 16 |
#include "esl_alphabet.h" |
| 17 |
#include "esl_gumbel.h" |
| 18 |
|
| 19 |
|
| 20 |
#include "hmmer.h" |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
int |
| 56 |
p7_GMSV(const ESL_DSQ *dsq, int L, const P7_PROFILE *gm, P7_GMX *gx, float nu, float *opt_sc) |
| 57 |
{ |
| 58 |
float **dp = gx->dp; |
| 59 |
float *xmx = gx->xmx; |
| 60 |
float tloop = logf((float) L / (float) (L+3)); |
| 61 |
float tmove = logf( 3.0f / (float) (L+3)); |
| 62 |
float tbmk = logf( 2.0f / ((float) gm->M * (float) (gm->M+1))); |
| 63 |
float tej = logf((nu - 1.0f) / nu); |
| 64 |
float tec = logf(1.0f / nu); |
| 65 |
int i,k; |
| 66 |
|
| 67 |
|
| 68 |
XMX(0,p7G_N) = 0; |
| 69 |
XMX(0,p7G_B) = tmove; |
| 70 |
XMX(0,p7G_E) = XMX(0,p7G_C) = XMX(0,p7G_J) =-eslINFINITY; |
| 71 |
for (k = 0; k <= gm->M; k++) |
| 72 |
MMX(0,k) = -eslINFINITY; |
| 73 |
|
| 74 |
|
| 75 |
for (i = 1; i <= L; i++) |
| 76 |
{ |
| 77 |
|
| 78 |
float const *rsc = gm->rsc[dsq[i]]; |
| 79 |
MMX(i,0) = -eslINFINITY; |
| 80 |
XMX(i,p7G_E) = -eslINFINITY; |
| 81 |
for (k = 1; k <= gm->M; k++) |
| 82 |
{ |
| 83 |
MMX(i,k) = MSC(k) + ESL_MAX(MMX(i-1,k-1), XMX(i-1,p7G_B) + tbmk); |
| 84 |
XMX(i,p7G_E) = ESL_MAX(XMX(i,p7G_E), MMX(i,k)); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
XMX(i,p7G_J) = ESL_MAX( XMX(i-1,p7G_J) + tloop, XMX(i, p7G_E) + tej); |
| 89 |
XMX(i,p7G_C) = ESL_MAX( XMX(i-1,p7G_C) + tloop, XMX(i, p7G_E) + tec); |
| 90 |
XMX(i,p7G_N) = XMX(i-1,p7G_N) + tloop; |
| 91 |
XMX(i,p7G_B) = ESL_MAX( XMX(i, p7G_N) + tmove, XMX(i, p7G_J) + tmove); |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
gx->M = gm->M; |
| 97 |
gx->L = L; |
| 98 |
if (opt_sc != NULL) *opt_sc = XMX(L,p7G_C) + tmove; |
| 99 |
return eslOK; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
int |
| 141 |
p7_GMSV_longtarget(const ESL_DSQ *dsq, int L, P7_PROFILE *gm, P7_GMX *gx, float nu, P7_BG *bg, double P, P7_HMM_WINDOWLIST *windowlist) |
| 142 |
{ |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
float **dp = gx->dp; |
| 156 |
float *xmx = gx->xmx; |
| 157 |
float tloop = logf((float) gm->max_length / (float) (gm->max_length+3)); |
| 158 |
float tmove = logf( 3.0f / (float) (gm->max_length+3)); |
| 159 |
float tbmk = logf( 2.0f / ((float) gm->M * (float) (gm->M+1))); |
| 160 |
float tej = logf((nu - 1.0f) / nu); |
| 161 |
float tec = logf(1.0f / nu); |
| 162 |
int i,k; |
| 163 |
|
| 164 |
float tloop_total = tloop * gm->max_length; |
| 165 |
|
| 166 |
|
| 167 |
int target_start; |
| 168 |
|
| 169 |
|
| 170 |
float sc_thresh; |
| 171 |
float nullsc; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
float invP = esl_gumbel_invsurv(P, gm->evparam[p7_MMU], gm->evparam[p7_MLAMBDA]); |
| 192 |
p7_bg_SetLength(bg, gm->max_length); |
| 193 |
p7_ReconfigLength(gm, gm->max_length); |
| 194 |
p7_bg_NullOne (bg, dsq, gm->max_length, &nullsc); |
| 195 |
|
| 196 |
sc_thresh = nullsc + (invP * eslCONST_LOG2) - tmove - tloop_total; |
| 197 |
|
| 198 |
|
| 199 |
XMX(0,p7G_N) = 0; |
| 200 |
XMX(0,p7G_B) = tmove; |
| 201 |
XMX(0,p7G_E) = XMX(0,p7G_C) = XMX(0,p7G_J) =-eslINFINITY; |
| 202 |
for (k = 0; k <= gm->M; k++) |
| 203 |
MMX(0,k) = -eslINFINITY; |
| 204 |
|
| 205 |
for (i = 1; i <= L; i++) |
| 206 |
{ |
| 207 |
float const *rsc = gm->rsc[dsq[i]]; |
| 208 |
|
| 209 |
MMX(i,0) = -eslINFINITY; |
| 210 |
XMX(i,p7G_E) = -eslINFINITY; |
| 211 |
|
| 212 |
for (k = 1; k <= gm->M; k++) |
| 213 |
{ |
| 214 |
MMX(i,k) = MSC(k) + ESL_MAX(MMX(i-1,k-1), XMX(i-1,p7G_B) + tbmk); |
| 215 |
XMX(i,p7G_E) = ESL_MAX(XMX(i,p7G_E), MMX(i,k)); |
| 216 |
} |
| 217 |
|
| 218 |
XMX(i,p7G_J) = ESL_MAX( XMX(i-1,p7G_J) , XMX(i, p7G_E) + tej); |
| 219 |
XMX(i,p7G_C) = ESL_MAX( XMX(i-1,p7G_C) , XMX(i, p7G_E) + tec); |
| 220 |
XMX(i,p7G_N) = XMX(i-1,p7G_N) ; |
| 221 |
XMX(i,p7G_B) = ESL_MAX( XMX(i, p7G_N) + tmove, XMX(i, p7G_J) + tmove); |
| 222 |
|
| 223 |
|
| 224 |
if (XMX(i,p7G_C) > sc_thresh) |
| 225 |
{ |
| 226 |
target_start = ESL_MAX(1, i - gm->max_length + 1); |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
p7_hmmwindow_new(windowlist, 0, target_start, 0, gm->M/2, 1, XMX(i,p7G_C), p7_NOCOMPLEMENT, L); |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
XMX(i,p7G_N) = 0; |
| 237 |
XMX(i,p7G_B) = tmove; |
| 238 |
XMX(i,p7G_E) = XMX(i,p7G_C) = XMX(i,p7G_J) =-eslINFINITY; |
| 239 |
for (k = 0; k <= gm->M; k++) |
| 240 |
MMX(i,k) = -eslINFINITY; |
| 241 |
|
| 242 |
} |
| 243 |
|
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
return eslOK; |
| 248 |
|
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
#ifdef p7GENERIC_MSV_BENCHMARK |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
#include <p7_config.h> |
| 270 |
|
| 271 |
#include "easel.h" |
| 272 |
#include "esl_alphabet.h" |
| 273 |
#include "esl_getopts.h" |
| 274 |
#include "esl_random.h" |
| 275 |
#include "esl_randomseq.h" |
| 276 |
#include "esl_stopwatch.h" |
| 277 |
|
| 278 |
#include "hmmer.h" |
| 279 |
|
| 280 |
static ESL_OPTIONS options[] = { |
| 281 |
|
| 282 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 283 |
{ "-s", eslARG_INT, "42", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 }, |
| 284 |
{ "-L", eslARG_INT, "400", NULL, "n>0", NULL, NULL, NULL, "length of random target seqs", 0 }, |
| 285 |
{ "-N", eslARG_INT, "20000", NULL, "n>0", NULL, NULL, NULL, "number of random target seqs", 0 }, |
| 286 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 287 |
}; |
| 288 |
static char usage[] = "[-options] <hmmfile>"; |
| 289 |
static char banner[] = "benchmark driver for generic MSV"; |
| 290 |
|
| 291 |
int |
| 292 |
main(int argc, char **argv) |
| 293 |
{ |
| 294 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 295 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 296 |
ESL_STOPWATCH *w = esl_stopwatch_Create(); |
| 297 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); |
| 298 |
ESL_ALPHABET *abc = NULL; |
| 299 |
P7_HMMFILE *hfp = NULL; |
| 300 |
P7_HMM *hmm = NULL; |
| 301 |
P7_BG *bg = NULL; |
| 302 |
P7_PROFILE *gm = NULL; |
| 303 |
P7_GMX *gx = NULL; |
| 304 |
int L = esl_opt_GetInteger(go, "-L"); |
| 305 |
int N = esl_opt_GetInteger(go, "-N"); |
| 306 |
ESL_DSQ *dsq = malloc(sizeof(ESL_DSQ) * (L+2)); |
| 307 |
int i; |
| 308 |
float sc; |
| 309 |
double base_time, bench_time, Mcs; |
| 310 |
|
| 311 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 312 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 313 |
|
| 314 |
bg = p7_bg_Create(abc); |
| 315 |
p7_bg_SetLength(bg, L); |
| 316 |
gm = p7_profile_Create(hmm->M, abc); |
| 317 |
p7_ProfileConfig(hmm, bg, gm, L, p7_UNILOCAL); |
| 318 |
gx = p7_gmx_Create(gm->M, L); |
| 319 |
|
| 320 |
|
| 321 |
esl_stopwatch_Start(w); |
| 322 |
for (i = 0; i < N; i++) esl_rsq_xfIID(r, bg->f, abc->K, L, dsq); |
| 323 |
esl_stopwatch_Stop(w); |
| 324 |
base_time = w->user; |
| 325 |
|
| 326 |
|
| 327 |
esl_stopwatch_Start(w); |
| 328 |
for (i = 0; i < N; i++) |
| 329 |
{ |
| 330 |
esl_rsq_xfIID(r, bg->f, abc->K, L, dsq); |
| 331 |
p7_GMSV (dsq, L, gm, gx, 2.0, &sc); |
| 332 |
} |
| 333 |
esl_stopwatch_Stop(w); |
| 334 |
bench_time = w->user - base_time; |
| 335 |
Mcs = (double) N * (double) L * (double) gm->M * 1e-6 / (double) bench_time; |
| 336 |
esl_stopwatch_Display(stdout, w, "# CPU time: "); |
| 337 |
printf("# M = %d\n", gm->M); |
| 338 |
printf("# %.1f Mc/s\n", Mcs); |
| 339 |
|
| 340 |
free(dsq); |
| 341 |
p7_gmx_Destroy(gx); |
| 342 |
p7_profile_Destroy(gm); |
| 343 |
p7_bg_Destroy(bg); |
| 344 |
p7_hmm_Destroy(hmm); |
| 345 |
p7_hmmfile_Close(hfp); |
| 346 |
esl_alphabet_Destroy(abc); |
| 347 |
esl_stopwatch_Destroy(w); |
| 348 |
esl_randomness_Destroy(r); |
| 349 |
esl_getopts_Destroy(go); |
| 350 |
return 0; |
| 351 |
} |
| 352 |
#endif |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
#ifdef p7GENERIC_MSV_TESTDRIVE |
| 359 |
#include "esl_getopts.h" |
| 360 |
#include "esl_random.h" |
| 361 |
#include "esl_randomseq.h" |
| 362 |
#include "esl_vectorops.h" |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
static void |
| 370 |
utest_msv(ESL_GETOPTS *go, ESL_RANDOMNESS *r, ESL_ALPHABET *abc, P7_BG *bg, P7_PROFILE *gm, int nseq, int L) |
| 371 |
{ |
| 372 |
P7_PROFILE *g2 = NULL; |
| 373 |
ESL_DSQ *dsq = NULL; |
| 374 |
P7_GMX *gx = NULL; |
| 375 |
float sc1, sc2; |
| 376 |
int k, idx; |
| 377 |
|
| 378 |
if ((dsq = malloc(sizeof(ESL_DSQ) *(L+2))) == NULL) esl_fatal("malloc failed"); |
| 379 |
if ((gx = p7_gmx_Create(gm->M, L)) == NULL) esl_fatal("matrix creation failed"); |
| 380 |
if ((g2 = p7_profile_Clone(gm)) == NULL) esl_fatal("profile clone failed"); |
| 381 |
|
| 382 |
|
| 383 |
esl_vec_FSet(g2->tsc, p7P_NTRANS * g2->M, -eslINFINITY); |
| 384 |
for (k = 1; k < g2->M; k++) p7P_TSC(g2, k, p7P_MM) = 0.0f; |
| 385 |
for (k = 0; k < g2->M; k++) p7P_TSC(g2, k, p7P_BM) = log(2.0f / ((float) g2->M * (float) (g2->M+1))); |
| 386 |
|
| 387 |
for (idx = 0; idx < nseq; idx++) |
| 388 |
{ |
| 389 |
if (esl_rsq_xfIID(r, bg->f, abc->K, L, dsq) != eslOK) esl_fatal("seq generation failed"); |
| 390 |
|
| 391 |
if (p7_GMSV (dsq, L, gm, gx, 2.0, &sc1) != eslOK) esl_fatal("MSV failed"); |
| 392 |
if (p7_GViterbi(dsq, L, g2, gx, &sc2) != eslOK) esl_fatal("viterbi failed"); |
| 393 |
if (fabs(sc1-sc2) > 0.0001) esl_fatal("MSV score not equal to Viterbi score"); |
| 394 |
} |
| 395 |
|
| 396 |
p7_gmx_Destroy(gx); |
| 397 |
p7_profile_Destroy(g2); |
| 398 |
free(dsq); |
| 399 |
return; |
| 400 |
} |
| 401 |
#endif |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
#ifdef p7GENERIC_MSV_TESTDRIVE |
| 411 |
#include "easel.h" |
| 412 |
#include "esl_getopts.h" |
| 413 |
#include "esl_msa.h" |
| 414 |
|
| 415 |
#include <p7_config.h> |
| 416 |
#include "hmmer.h" |
| 417 |
|
| 418 |
static ESL_OPTIONS options[] = { |
| 419 |
|
| 420 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 421 |
{ "-s", eslARG_INT, "42", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 }, |
| 422 |
{ "-v", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "be verbose", 0 }, |
| 423 |
{ "--vv", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "be very verbose", 0 }, |
| 424 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 425 |
}; |
| 426 |
static char usage[] = "[-options]"; |
| 427 |
static char banner[] = "unit test driver for the generic Msv implementation"; |
| 428 |
|
| 429 |
int |
| 430 |
main(int argc, char **argv) |
| 431 |
{ |
| 432 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 0, argc, argv, banner, usage); |
| 433 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); |
| 434 |
ESL_ALPHABET *abc = NULL; |
| 435 |
P7_HMM *hmm = NULL; |
| 436 |
P7_PROFILE *gm = NULL; |
| 437 |
P7_BG *bg = NULL; |
| 438 |
int M = 100; |
| 439 |
int L = 200; |
| 440 |
int nseq = 20; |
| 441 |
char errbuf[eslERRBUFSIZE]; |
| 442 |
|
| 443 |
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet"); |
| 444 |
if (p7_hmm_Sample(r, M, abc, &hmm) != eslOK) esl_fatal("failed to sample an HMM"); |
| 445 |
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model"); |
| 446 |
if ((gm = p7_profile_Create(hmm->M, abc)) == NULL) esl_fatal("failed to create profile"); |
| 447 |
if (p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL) != eslOK) esl_fatal("failed to config profile"); |
| 448 |
if (p7_hmm_Validate (hmm, errbuf, 0.0001) != eslOK) esl_fatal("whoops, HMM is bad!: %s", errbuf); |
| 449 |
if (p7_profile_Validate(gm, errbuf, 0.0001) != eslOK) esl_fatal("whoops, profile is bad!: %s", errbuf); |
| 450 |
|
| 451 |
utest_msv(go, r, abc, bg, gm, nseq, L); |
| 452 |
|
| 453 |
p7_profile_Destroy(gm); |
| 454 |
p7_bg_Destroy(bg); |
| 455 |
p7_hmm_Destroy(hmm); |
| 456 |
esl_alphabet_Destroy(abc); |
| 457 |
esl_randomness_Destroy(r); |
| 458 |
esl_getopts_Destroy(go); |
| 459 |
return 0; |
| 460 |
} |
| 461 |
#endif |
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
#ifdef p7GENERIC_MSV_EXAMPLE |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
#include <p7_config.h> |
| 473 |
|
| 474 |
#include "easel.h" |
| 475 |
#include "esl_alphabet.h" |
| 476 |
#include "esl_getopts.h" |
| 477 |
#include "esl_gumbel.h" |
| 478 |
#include "esl_sq.h" |
| 479 |
#include "esl_sqio.h" |
| 480 |
|
| 481 |
#include "hmmer.h" |
| 482 |
|
| 483 |
static ESL_OPTIONS options[] = { |
| 484 |
|
| 485 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 486 |
{ "--nu", eslARG_REAL, "2.0", NULL, NULL, NULL, NULL, NULL, "set nu param to <x>: expected # MSV diagonals", 0 }, |
| 487 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 488 |
}; |
| 489 |
static char usage[] = "[-options] <hmmfile> <seqfile>"; |
| 490 |
static char banner[] = "example of generic MSV algorithm"; |
| 491 |
|
| 492 |
|
| 493 |
int |
| 494 |
main(int argc, char **argv) |
| 495 |
{ |
| 496 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 2, argc, argv, banner, usage); |
| 497 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 498 |
char *seqfile = esl_opt_GetArg(go, 2); |
| 499 |
float nu = esl_opt_GetReal(go, "--nu"); |
| 500 |
ESL_ALPHABET *abc = NULL; |
| 501 |
P7_HMMFILE *hfp = NULL; |
| 502 |
P7_HMM *hmm = NULL; |
| 503 |
P7_BG *bg = NULL; |
| 504 |
P7_PROFILE *gm = NULL; |
| 505 |
P7_GMX *fwd = NULL; |
| 506 |
ESL_SQ *sq = NULL; |
| 507 |
ESL_SQFILE *sqfp = NULL; |
| 508 |
P7_TRACE *tr = NULL; |
| 509 |
int format = eslSQFILE_UNKNOWN; |
| 510 |
float sc, nullsc, seqscore, lnP; |
| 511 |
int status; |
| 512 |
|
| 513 |
|
| 514 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 515 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 516 |
p7_hmmfile_Close(hfp); |
| 517 |
|
| 518 |
|
| 519 |
sq = esl_sq_CreateDigital(abc); |
| 520 |
status = esl_sqfile_Open(seqfile, format, NULL, &sqfp); |
| 521 |
if (status == eslENOTFOUND) p7_Fail("No such file."); |
| 522 |
else if (status == eslEFORMAT) p7_Fail("Format unrecognized."); |
| 523 |
else if (status == eslEINVAL) p7_Fail("Can't autodetect stdin or .gz."); |
| 524 |
else if (status != eslOK) p7_Fail("Open failed, code %d.", status); |
| 525 |
|
| 526 |
|
| 527 |
bg = p7_bg_Create(abc); |
| 528 |
gm = p7_profile_Create(hmm->M, abc); |
| 529 |
p7_ProfileConfig(hmm, bg, gm, sq->n, p7_LOCAL); |
| 530 |
|
| 531 |
|
| 532 |
fwd = p7_gmx_Create(gm->M, sq->n); |
| 533 |
|
| 534 |
while ((status = esl_sqio_Read(sqfp, sq)) == eslOK) |
| 535 |
{ |
| 536 |
p7_ReconfigLength(gm, sq->n); |
| 537 |
p7_bg_SetLength(bg, sq->n); |
| 538 |
p7_gmx_GrowTo(fwd, gm->M, sq->n); |
| 539 |
|
| 540 |
|
| 541 |
p7_GMSV(sq->dsq, sq->n, gm, fwd, nu, &sc); |
| 542 |
|
| 543 |
|
| 544 |
p7_bg_NullOne (bg, sq->dsq, sq->n, &nullsc); |
| 545 |
seqscore = (sc - nullsc) / eslCONST_LOG2; |
| 546 |
lnP = esl_gumbel_logsurv(seqscore, gm->evparam[p7_MMU], gm->evparam[p7_MLAMBDA]); |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
printf("%g\t%.2f\t%s\t%s\n", exp(lnP), seqscore, sq->name, hmm->name); |
| 552 |
|
| 553 |
esl_sq_Reuse(sq); |
| 554 |
} |
| 555 |
if (status == eslEFORMAT) esl_fatal("Parse failed (sequence file %s):\n%s\n", sqfp->filename, esl_sqfile_GetErrorBuf(sqfp)); |
| 556 |
else if (status != eslEOF) esl_fatal("Unexpected error %d reading sequence file %s", status, sqfp->filename); |
| 557 |
|
| 558 |
|
| 559 |
esl_sqfile_Close(sqfp); |
| 560 |
esl_sq_Destroy(sq); |
| 561 |
p7_trace_Destroy(tr); |
| 562 |
p7_gmx_Destroy(fwd); |
| 563 |
p7_profile_Destroy(gm); |
| 564 |
p7_bg_Destroy(bg); |
| 565 |
p7_hmm_Destroy(hmm); |
| 566 |
esl_alphabet_Destroy(abc); |
| 567 |
esl_getopts_Destroy(go); |
| 568 |
return 0; |
| 569 |
} |
| 570 |
#endif |
| 571 |
|
| 572 |
|
| 573 |
|