| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#include <p7_config.h> |
| 12 |
|
| 13 |
#include "easel.h" |
| 14 |
#include "esl_gumbel.h" |
| 15 |
#include "esl_random.h" |
| 16 |
#include "esl_randomseq.h" |
| 17 |
#include "esl_vectorops.h" |
| 18 |
|
| 19 |
#include "hmmer.h" |
| 20 |
|
| 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 |
|
| 56 |
|
| 57 |
int |
| 58 |
p7_Calibrate(P7_HMM *hmm, P7_BUILDER *cfg_b, ESL_RANDOMNESS **byp_rng, P7_BG **byp_bg, P7_PROFILE **byp_gm, P7_OPROFILE **byp_om) |
| 59 |
{ |
| 60 |
P7_BG *bg = (esl_byp_IsProvided(byp_bg) ? *byp_bg : NULL); |
| 61 |
P7_PROFILE *gm = (esl_byp_IsProvided(byp_gm) ? *byp_gm : NULL); |
| 62 |
P7_OPROFILE *om = (esl_byp_IsProvided(byp_om) ? *byp_om : NULL); |
| 63 |
ESL_RANDOMNESS *r = (esl_byp_IsProvided(byp_rng) ? *byp_rng : NULL); |
| 64 |
char *errbuf = ((cfg_b != NULL) ? cfg_b->errbuf : NULL); |
| 65 |
int EmL = ((cfg_b != NULL) ? cfg_b->EmL : 200); |
| 66 |
int EmN = ((cfg_b != NULL) ? cfg_b->EmN : 200); |
| 67 |
int EvL = ((cfg_b != NULL) ? cfg_b->EvL : 200); |
| 68 |
int EvN = ((cfg_b != NULL) ? cfg_b->EvN : 200); |
| 69 |
int EfL = ((cfg_b != NULL) ? cfg_b->EfL : 100); |
| 70 |
int EfN = ((cfg_b != NULL) ? cfg_b->EfN : 200); |
| 71 |
double Eft = ((cfg_b != NULL) ? cfg_b->Eft : 0.04); |
| 72 |
double lambda, mmu, vmu, tau; |
| 73 |
int status; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
if (r == NULL) { |
| 79 |
if ((r = esl_randomness_CreateFast(42)) == NULL) ESL_XFAIL(eslEMEM, errbuf, "failed to create RNG"); |
| 80 |
} else if (cfg_b != NULL && cfg_b->do_reseeding) { |
| 81 |
esl_randomness_Init(r, esl_randomness_GetSeed(r)); |
| 82 |
} |
| 83 |
|
| 84 |
if (bg == NULL) { |
| 85 |
if ((bg = p7_bg_Create(hmm->abc)) == NULL) ESL_XFAIL(eslEMEM, errbuf, "failed to allocate background"); |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
if ((esl_byp_IsInternal(byp_gm) && ! esl_byp_IsProvided(byp_om)) || esl_byp_IsReturned(byp_gm)) { |
| 94 |
if ( (gm = p7_profile_Create(hmm->M, hmm->abc)) == NULL) ESL_XFAIL(eslEMEM, errbuf, "failed to allocate profile"); |
| 95 |
if ( (status = p7_ProfileConfig(hmm, bg, gm, EvL, p7_LOCAL)) != eslOK) ESL_XFAIL(status, errbuf, "failed to configure profile"); |
| 96 |
} |
| 97 |
|
| 98 |
if (om == NULL) { |
| 99 |
if ((om = p7_oprofile_Create(hmm->M, hmm->abc)) == NULL) ESL_XFAIL(eslEMEM, errbuf, "failed to create optimized profile"); |
| 100 |
if ((status = p7_oprofile_Convert(gm, om)) != eslOK) ESL_XFAIL(status, errbuf, "failed to convert to optimized profile"); |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
if ((status = p7_Lambda(hmm, bg, &lambda)) != eslOK) ESL_XFAIL(status, errbuf, "failed to determine lambda"); |
| 105 |
if ((status = p7_MSVMu (r, om, bg, EmL, EmN, lambda, &mmu)) != eslOK) ESL_XFAIL(status, errbuf, "failed to determine msv mu"); |
| 106 |
if ((status = p7_ViterbiMu(r, om, bg, EvL, EvN, lambda, &vmu)) != eslOK) ESL_XFAIL(status, errbuf, "failed to determine vit mu"); |
| 107 |
if ((status = p7_Tau (r, om, bg, EfL, EfN, lambda, Eft, &tau)) != eslOK) ESL_XFAIL(status, errbuf, "failed to determine fwd tau"); |
| 108 |
|
| 109 |
|
| 110 |
hmm->evparam[p7_MLAMBDA] = om->evparam[p7_MLAMBDA] = lambda; |
| 111 |
hmm->evparam[p7_VLAMBDA] = om->evparam[p7_VLAMBDA] = lambda; |
| 112 |
hmm->evparam[p7_FLAMBDA] = om->evparam[p7_FLAMBDA] = lambda; |
| 113 |
hmm->evparam[p7_MMU] = om->evparam[p7_MMU] = mmu; |
| 114 |
hmm->evparam[p7_VMU] = om->evparam[p7_VMU] = vmu; |
| 115 |
hmm->evparam[p7_FTAU] = om->evparam[p7_FTAU] = tau; |
| 116 |
hmm->flags |= p7H_STATS; |
| 117 |
|
| 118 |
if (gm != NULL) { |
| 119 |
gm->evparam[p7_MLAMBDA] = lambda; |
| 120 |
gm->evparam[p7_VLAMBDA] = lambda; |
| 121 |
gm->evparam[p7_FLAMBDA] = lambda; |
| 122 |
gm->evparam[p7_MMU] = mmu; |
| 123 |
gm->evparam[p7_VMU] = vmu; |
| 124 |
gm->evparam[p7_FTAU] = tau; |
| 125 |
} |
| 126 |
|
| 127 |
if (byp_rng != NULL) *byp_rng = r; else esl_randomness_Destroy(r); |
| 128 |
if (byp_bg != NULL) *byp_bg = bg; else p7_bg_Destroy(bg); |
| 129 |
if (byp_gm != NULL) *byp_gm = gm; else p7_profile_Destroy(gm); |
| 130 |
if (byp_om != NULL) *byp_om = om; else p7_oprofile_Destroy(om); |
| 131 |
return eslOK; |
| 132 |
|
| 133 |
ERROR: |
| 134 |
if (! esl_byp_IsProvided(byp_rng)) esl_randomness_Destroy(r); |
| 135 |
if (! esl_byp_IsProvided(byp_bg)) p7_bg_Destroy(bg); |
| 136 |
if (! esl_byp_IsProvided(byp_gm)) p7_profile_Destroy(gm); |
| 137 |
if (! esl_byp_IsProvided(byp_om)) p7_oprofile_Destroy(om); |
| 138 |
return status; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
int |
| 184 |
p7_Lambda(P7_HMM *hmm, P7_BG *bg, double *ret_lambda) |
| 185 |
{ |
| 186 |
double H = p7_MeanMatchRelativeEntropy(hmm, bg); |
| 187 |
|
| 188 |
*ret_lambda = eslCONST_LOG2 + 1.44 / ((double) hmm->M * H); |
| 189 |
return eslOK; |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
int |
| 238 |
p7_MSVMu(ESL_RANDOMNESS *r, P7_OPROFILE *om, P7_BG *bg, int L, int N, double lambda, double *ret_mmu) |
| 239 |
{ |
| 240 |
P7_OMX *ox = p7_omx_Create(om->M, 0, 0); |
| 241 |
ESL_DSQ *dsq = NULL; |
| 242 |
double *xv = NULL; |
| 243 |
int i; |
| 244 |
float sc, nullsc; |
| 245 |
float maxsc = (255 - om->base_b) / om->scale_b; |
| 246 |
int status; |
| 247 |
|
| 248 |
if (ox == NULL) { status = eslEMEM; goto ERROR; } |
| 249 |
ESL_ALLOC(xv, sizeof(double) * N); |
| 250 |
ESL_ALLOC(dsq, sizeof(ESL_DSQ) * (L+2)); |
| 251 |
|
| 252 |
p7_oprofile_ReconfigLength(om, L); |
| 253 |
p7_bg_SetLength(bg, L); |
| 254 |
|
| 255 |
for (i = 0; i < N; i++) |
| 256 |
{ |
| 257 |
if ((status = esl_rsq_xfIID(r, bg->f, om->abc->K, L, dsq)) != eslOK) goto ERROR; |
| 258 |
if ((status = p7_bg_NullOne(bg, dsq, L, &nullsc)) != eslOK) goto ERROR; |
| 259 |
|
| 260 |
status = p7_MSVFilter(dsq, L, om, ox, &sc); |
| 261 |
if (status == eslERANGE) { sc = maxsc; status = eslOK; } |
| 262 |
if (status != eslOK) goto ERROR; |
| 263 |
|
| 264 |
xv[i] = (sc - nullsc) / eslCONST_LOG2; |
| 265 |
} |
| 266 |
|
| 267 |
if ((status = esl_gumbel_FitCompleteLoc(xv, N, lambda, ret_mmu)) != eslOK) goto ERROR; |
| 268 |
p7_omx_Destroy(ox); |
| 269 |
free(xv); |
| 270 |
free(dsq); |
| 271 |
return eslOK; |
| 272 |
|
| 273 |
ERROR: |
| 274 |
*ret_mmu = 0.0; |
| 275 |
if (ox != NULL) p7_omx_Destroy(ox); |
| 276 |
if (xv != NULL) free(xv); |
| 277 |
if (dsq != NULL) free(dsq); |
| 278 |
return status; |
| 279 |
|
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
int |
| 307 |
p7_ViterbiMu(ESL_RANDOMNESS *r, P7_OPROFILE *om, P7_BG *bg, int L, int N, double lambda, double *ret_vmu) |
| 308 |
{ |
| 309 |
P7_OMX *ox = p7_omx_Create(om->M, 0, 0); |
| 310 |
ESL_DSQ *dsq = NULL; |
| 311 |
double *xv = NULL; |
| 312 |
int i; |
| 313 |
float sc, nullsc; |
| 314 |
float maxsc = (32767.0 - om->base_w) / om->scale_w; |
| 315 |
int status; |
| 316 |
|
| 317 |
if (ox == NULL) { status = eslEMEM; goto ERROR; } |
| 318 |
ESL_ALLOC(xv, sizeof(double) * N); |
| 319 |
ESL_ALLOC(dsq, sizeof(ESL_DSQ) * (L+2)); |
| 320 |
|
| 321 |
p7_oprofile_ReconfigLength(om, L); |
| 322 |
p7_bg_SetLength(bg, L); |
| 323 |
|
| 324 |
for (i = 0; i < N; i++) |
| 325 |
{ |
| 326 |
if ((status = esl_rsq_xfIID(r, bg->f, om->abc->K, L, dsq)) != eslOK) goto ERROR; |
| 327 |
if ((status = p7_bg_NullOne(bg, dsq, L, &nullsc)) != eslOK) goto ERROR; |
| 328 |
|
| 329 |
status = p7_ViterbiFilter(dsq, L, om, ox, &sc); |
| 330 |
if (status == eslERANGE) { sc = maxsc; status = eslOK; } |
| 331 |
if (status != eslOK) goto ERROR; |
| 332 |
|
| 333 |
xv[i] = (sc - nullsc) / eslCONST_LOG2; |
| 334 |
} |
| 335 |
|
| 336 |
if ((status = esl_gumbel_FitCompleteLoc(xv, N, lambda, ret_vmu)) != eslOK) goto ERROR; |
| 337 |
p7_omx_Destroy(ox); |
| 338 |
free(xv); |
| 339 |
free(dsq); |
| 340 |
return eslOK; |
| 341 |
|
| 342 |
ERROR: |
| 343 |
*ret_vmu = 0.0; |
| 344 |
if (ox != NULL) p7_omx_Destroy(ox); |
| 345 |
if (xv != NULL) free(xv); |
| 346 |
if (dsq != NULL) free(dsq); |
| 347 |
return status; |
| 348 |
|
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
int |
| 412 |
p7_Tau(ESL_RANDOMNESS *r, P7_OPROFILE *om, P7_BG *bg, int L, int N, double lambda, double tailp, double *ret_tau) |
| 413 |
{ |
| 414 |
P7_OMX *ox = p7_omx_Create(om->M, 0, L); |
| 415 |
ESL_DSQ *dsq = NULL; |
| 416 |
double *xv = NULL; |
| 417 |
float fsc, nullsc; |
| 418 |
double gmu, glam; |
| 419 |
int status; |
| 420 |
int i; |
| 421 |
|
| 422 |
ESL_ALLOC(xv, sizeof(double) * N); |
| 423 |
ESL_ALLOC(dsq, sizeof(ESL_DSQ) * (L+2)); |
| 424 |
if (ox == NULL) { status = eslEMEM; goto ERROR; } |
| 425 |
|
| 426 |
p7_oprofile_ReconfigLength(om, L); |
| 427 |
p7_bg_SetLength(bg, L); |
| 428 |
|
| 429 |
for (i = 0; i < N; i++) |
| 430 |
{ |
| 431 |
if ((status = esl_rsq_xfIID(r, bg->f, om->abc->K, L, dsq)) != eslOK) goto ERROR; |
| 432 |
if ((status = p7_ForwardParser(dsq, L, om, ox, &fsc)) != eslOK) goto ERROR; |
| 433 |
if ((status = p7_bg_NullOne(bg, dsq, L, &nullsc)) != eslOK) goto ERROR; |
| 434 |
xv[i] = (fsc - nullsc) / eslCONST_LOG2; |
| 435 |
} |
| 436 |
if ((status = esl_gumbel_FitComplete(xv, N, &gmu, &glam)) != eslOK) goto ERROR; |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
*ret_tau = esl_gumbel_invcdf(1.0-tailp, gmu, glam) + (log(tailp) / lambda); |
| 444 |
|
| 445 |
free(xv); |
| 446 |
free(dsq); |
| 447 |
p7_omx_Destroy(ox); |
| 448 |
return eslOK; |
| 449 |
|
| 450 |
ERROR: |
| 451 |
*ret_tau = 0.; |
| 452 |
if (xv != NULL) free(xv); |
| 453 |
if (dsq != NULL) free(dsq); |
| 454 |
if (ox != NULL) p7_omx_Destroy(ox); |
| 455 |
return status; |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
#ifdef p7EVALUES_STATS |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
#include <p7_config.h> |
| 473 |
|
| 474 |
#include "easel.h" |
| 475 |
#include "esl_getopts.h" |
| 476 |
#include "esl_random.h" |
| 477 |
#include "esl_alphabet.h" |
| 478 |
|
| 479 |
#include "hmmer.h" |
| 480 |
|
| 481 |
#define BMARKS "--msvonly,--vitonly,--fwdonly" |
| 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 |
{ "-s", eslARG_INT, "0", NULL, NULL, NULL, NULL, NULL, "set random number generator seed to <n>", 0 }, |
| 487 |
{ "--EmL", eslARG_INT, "200", NULL,"n>0", NULL, NULL, NULL, "length of sequences for MSV Gumbel mu fit", 0 }, |
| 488 |
{ "--EmN", eslARG_INT, "200", NULL,"n>0", NULL, NULL, NULL, "number of sequences for MSV Gumbel mu fit", 0 }, |
| 489 |
{ "--EvL", eslARG_INT, "200", NULL,"n>0", NULL, NULL, NULL, "length of sequences for Viterbi Gumbel mu fit", 0 }, |
| 490 |
{ "--EvN", eslARG_INT, "200", NULL,"n>0", NULL, NULL, NULL, "number of sequences for Viterbi Gumbel mu fit", 0 }, |
| 491 |
{ "--EfL", eslARG_INT, "100", NULL,"n>0", NULL, NULL, NULL, "length of sequences for Forward exp tail tau fit",0 }, |
| 492 |
{ "--EfN", eslARG_INT, "200", NULL,"n>0", NULL, NULL, NULL, "number of sequences for Forward exp tail tau fit",0 }, |
| 493 |
{ "--Eft", eslARG_REAL, "0.04", NULL,"0<x<1",NULL, NULL, NULL, "tail mass for Forward exponential tail tau fit", 0 }, |
| 494 |
{ "-Z", eslARG_INT, "1", NULL, NULL, NULL, NULL, NULL, "set number of iterations per model to <n>", 0 }, |
| 495 |
{ "--lambda", eslARG_REAL, NULL, NULL, NULL, NULL, NULL, NULL, "set lambda param to <x>", 0 }, |
| 496 |
{ "--msvonly", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL,BMARKS, "only run MSV mu calibration (for benchmarking)", 0 }, |
| 497 |
{ "--vitonly", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL,BMARKS, "only run Vit mu calibration (for benchmarking)", 0 }, |
| 498 |
{ "--fwdonly", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL,BMARKS, "only run Fwd tau calibration (for benchmarking)", 0 }, |
| 499 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 500 |
}; |
| 501 |
static char usage[] = "[-options] <hmmfile>"; |
| 502 |
static char banner[] = "collect test statistics for E-value calculations"; |
| 503 |
|
| 504 |
int |
| 505 |
main(int argc, char **argv) |
| 506 |
{ |
| 507 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 508 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 509 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); |
| 510 |
ESL_ALPHABET *abc = NULL; |
| 511 |
P7_HMMFILE *hfp = NULL; |
| 512 |
P7_HMM *hmm = NULL; |
| 513 |
P7_BG *bg = NULL; |
| 514 |
P7_PROFILE *gm = NULL; |
| 515 |
P7_OPROFILE *om = NULL; |
| 516 |
double lambda = 0.0; |
| 517 |
double mmu = 0.0; |
| 518 |
double vmu = 0.0; |
| 519 |
double ftau = 0.0; |
| 520 |
int Z = esl_opt_GetInteger(go, "-Z"); |
| 521 |
int EmL = esl_opt_GetInteger(go, "--EmL"); |
| 522 |
int EmN = esl_opt_GetInteger(go, "--EmN"); |
| 523 |
int EvL = esl_opt_GetInteger(go, "--EvL"); |
| 524 |
int EvN = esl_opt_GetInteger(go, "--EvN"); |
| 525 |
int EfL = esl_opt_GetInteger(go, "--EfL"); |
| 526 |
int EfN = esl_opt_GetInteger(go, "--EfN"); |
| 527 |
int Eft = esl_opt_GetReal (go, "--Eft"); |
| 528 |
int iteration; |
| 529 |
int do_msv, do_vit, do_fwd; |
| 530 |
int status; |
| 531 |
|
| 532 |
if (esl_opt_GetBoolean(go, "--msvonly") == TRUE) { do_msv = TRUE; do_vit = FALSE; do_fwd = FALSE; } |
| 533 |
else if (esl_opt_GetBoolean(go, "--vitonly") == TRUE) { do_msv = FALSE; do_vit = TRUE; do_fwd = FALSE; } |
| 534 |
else if (esl_opt_GetBoolean(go, "--fwdonly") == TRUE) { do_msv = FALSE; do_vit = FALSE; do_fwd = TRUE; } |
| 535 |
else { do_msv = TRUE; do_vit = TRUE; do_fwd = TRUE; } |
| 536 |
|
| 537 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 538 |
while ((status = p7_hmmfile_Read(hfp, &abc, &hmm)) != eslEOF) |
| 539 |
{ |
| 540 |
if (bg == NULL) bg = p7_bg_Create(abc); |
| 541 |
gm = p7_profile_Create(hmm->M, abc); |
| 542 |
p7_ProfileConfig(hmm, bg, gm, EvL, p7_LOCAL); |
| 543 |
om = p7_oprofile_Create(hmm->M, abc); |
| 544 |
p7_oprofile_Convert(gm, om); |
| 545 |
|
| 546 |
if (esl_opt_IsOn(go, "--lambda")) lambda = esl_opt_GetReal(go, "--lambda"); |
| 547 |
else p7_Lambda(hmm, bg, &lambda); |
| 548 |
|
| 549 |
for (iteration = 0; iteration < Z; iteration++) |
| 550 |
{ |
| 551 |
if (do_msv) p7_MSVMu (r, om, bg, EmL, EmN, lambda, &mmu); |
| 552 |
if (do_vit) p7_ViterbiMu (r, om, bg, EvL, EvN, lambda, &vmu); |
| 553 |
if (do_fwd) p7_Tau (r, om, bg, EfL, EfN, lambda, Eft, &ftau); |
| 554 |
|
| 555 |
printf("%s %.4f %.4f %.4f %.4f\n", hmm->name, lambda, mmu, vmu, ftau); |
| 556 |
} |
| 557 |
|
| 558 |
p7_hmm_Destroy(hmm); |
| 559 |
p7_profile_Destroy(gm); |
| 560 |
p7_oprofile_Destroy(om); |
| 561 |
} |
| 562 |
|
| 563 |
p7_hmmfile_Close(hfp); |
| 564 |
p7_bg_Destroy(bg); |
| 565 |
esl_alphabet_Destroy(abc); |
| 566 |
esl_randomness_Destroy(r); |
| 567 |
esl_getopts_Destroy(go); |
| 568 |
return eslOK; |
| 569 |
} |
| 570 |
#endif |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
#ifdef p7EVALUES_BENCHMARK |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
#include <p7_config.h> |
| 593 |
|
| 594 |
#include "easel.h" |
| 595 |
#include "esl_alphabet.h" |
| 596 |
#include "esl_getopts.h" |
| 597 |
#include "esl_stopwatch.h" |
| 598 |
|
| 599 |
#include "hmmer.h" |
| 600 |
|
| 601 |
static ESL_OPTIONS options[] = { |
| 602 |
|
| 603 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 604 |
{ "-N", eslARG_INT, "100", NULL, "n>0", NULL, NULL, NULL, "number of calibrations to do", 0 }, |
| 605 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 606 |
}; |
| 607 |
static char usage[] = "[-options] <hmmfile>"; |
| 608 |
static char banner[] = "benchmark driver for E-value calibration"; |
| 609 |
|
| 610 |
int |
| 611 |
main(int argc, char **argv) |
| 612 |
{ |
| 613 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 614 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 615 |
int N = esl_opt_GetInteger(go, "-N"); |
| 616 |
ESL_STOPWATCH *w = esl_stopwatch_Create(); |
| 617 |
ESL_ALPHABET *abc = NULL; |
| 618 |
P7_HMMFILE *hfp = NULL; |
| 619 |
P7_HMM *hmm = NULL; |
| 620 |
|
| 621 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 622 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 623 |
p7_hmmfile_Close(hfp); |
| 624 |
|
| 625 |
esl_stopwatch_Start(w); |
| 626 |
while (N--) |
| 627 |
{ |
| 628 |
p7_Calibrate(hmm, NULL, NULL, NULL, NULL, NULL); |
| 629 |
} |
| 630 |
esl_stopwatch_Stop(w); |
| 631 |
esl_stopwatch_Display(stdout, w, "# CPU time: "); |
| 632 |
|
| 633 |
p7_hmm_Destroy(hmm); |
| 634 |
esl_alphabet_Destroy(abc); |
| 635 |
esl_stopwatch_Destroy(w); |
| 636 |
esl_getopts_Destroy(go); |
| 637 |
return 0; |
| 638 |
} |
| 639 |
#endif |
| 640 |
|
| 641 |
|