| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#include <p7_config.h> |
| 12 |
|
| 13 |
#include "easel.h" |
| 14 |
#include "esl_random.h" |
| 15 |
#include "esl_sq.h" |
| 16 |
#include "esl_vectorops.h" |
| 17 |
|
| 18 |
#include "hmmer.h" |
| 19 |
|
| 20 |
static int sample_endpoints(ESL_RANDOMNESS *r, const P7_PROFILE *gm, int *ret_kstart, int *ret_kend); |
| 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 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
int |
| 69 |
p7_CoreEmit(ESL_RANDOMNESS *r, const P7_HMM *hmm, ESL_SQ *sq, P7_TRACE *tr) |
| 70 |
{ |
| 71 |
int k = 0; |
| 72 |
int i = 0; |
| 73 |
char st = p7T_B; |
| 74 |
int x; |
| 75 |
int status; |
| 76 |
|
| 77 |
if (sq != NULL) esl_sq_Reuse(sq); |
| 78 |
if (tr != NULL) { |
| 79 |
if ((status = p7_trace_Reuse(tr)) != eslOK) goto ERROR; |
| 80 |
if ((status = p7_trace_Append(tr, st, k, i)) != eslOK) goto ERROR; |
| 81 |
} |
| 82 |
while (st != p7T_E) |
| 83 |
{ |
| 84 |
|
| 85 |
switch (st) { |
| 86 |
case p7T_B: |
| 87 |
case p7T_M: |
| 88 |
switch (esl_rnd_FChoose(r, hmm->t[k], 3)) { |
| 89 |
case 0: st = p7T_M; break; |
| 90 |
case 1: st = p7T_I; break; |
| 91 |
case 2: st = p7T_D; break; |
| 92 |
default: ESL_XEXCEPTION(eslEINCONCEIVABLE, "impossible."); |
| 93 |
} |
| 94 |
break; |
| 95 |
|
| 96 |
case p7T_I: |
| 97 |
switch (esl_rnd_FChoose(r, hmm->t[k]+3, 2)) { |
| 98 |
case 0: st = p7T_M; break; |
| 99 |
case 1: st = p7T_I; break; |
| 100 |
default: ESL_XEXCEPTION(eslEINCONCEIVABLE, "impossible."); |
| 101 |
} |
| 102 |
break; |
| 103 |
|
| 104 |
case p7T_D: |
| 105 |
switch (esl_rnd_FChoose(r, hmm->t[k]+5, 2)) { |
| 106 |
case 0: st = p7T_M; break; |
| 107 |
case 1: st = p7T_D; break; |
| 108 |
default: ESL_XEXCEPTION(eslEINCONCEIVABLE, "impossible."); |
| 109 |
} |
| 110 |
break; |
| 111 |
|
| 112 |
default: ESL_XEXCEPTION(eslECORRUPT, "impossible state reached during emission"); |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
if (st == p7T_M || st == p7T_D) k++; |
| 117 |
if (st == p7T_M || st == p7T_I) i++; |
| 118 |
|
| 119 |
|
| 120 |
if (k == hmm->M+1) { |
| 121 |
if (st == p7T_M) { st = p7T_E; k = 0; } |
| 122 |
else ESL_XEXCEPTION(eslECORRUPT, "failed to reach E state properly"); |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
if (st == p7T_M) x = esl_rnd_FChoose(r, hmm->mat[k], hmm->abc->K); |
| 127 |
else if (st == p7T_I) x = esl_rnd_FChoose(r, hmm->ins[k], hmm->abc->K); |
| 128 |
else x = eslDSQ_SENTINEL; |
| 129 |
|
| 130 |
|
| 131 |
if (tr != NULL) { |
| 132 |
if ((status = p7_trace_Append(tr, st, k, i)) != eslOK) goto ERROR; |
| 133 |
} |
| 134 |
|
| 135 |
if (sq != NULL && x != eslDSQ_SENTINEL) |
| 136 |
if ((status = esl_sq_XAddResidue(sq, x)) != eslOK) goto ERROR; |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
if (tr != NULL) { tr->M = hmm->M; tr->L = i; } |
| 141 |
if (sq != NULL && (status = esl_sq_XAddResidue(sq, eslDSQ_SENTINEL)) != eslOK) goto ERROR; |
| 142 |
return eslOK; |
| 143 |
|
| 144 |
ERROR: |
| 145 |
return status; |
| 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_ProfileEmit(ESL_RANDOMNESS *r, const P7_HMM *hmm, const P7_PROFILE *gm, const P7_BG *bg, ESL_SQ *sq, P7_TRACE *tr) |
| 185 |
{ |
| 186 |
char prv, st; |
| 187 |
int k = 0; |
| 188 |
int i = 0; |
| 189 |
int x; |
| 190 |
int kend = hmm->M; |
| 191 |
int status; |
| 192 |
float xt[p7P_NXSTATES][p7P_NXTRANS]; |
| 193 |
|
| 194 |
|
| 195 |
for (i = 0; i < p7P_NXSTATES; i++) |
| 196 |
for (x = 0; x < p7P_NXTRANS; x++) |
| 197 |
xt[i][x] = exp(gm->xsc[i][x]); |
| 198 |
|
| 199 |
if (sq != NULL) esl_sq_Reuse(sq); |
| 200 |
if (tr != NULL) { |
| 201 |
if ((status = p7_trace_Reuse(tr)) != eslOK) goto ERROR; |
| 202 |
if ((status = p7_trace_Append(tr, p7T_S, k, i)) != eslOK) goto ERROR; |
| 203 |
if ((status = p7_trace_Append(tr, p7T_N, k, i)) != eslOK) goto ERROR; |
| 204 |
} |
| 205 |
st = p7T_N; |
| 206 |
i = 0; |
| 207 |
while (st != p7T_T) |
| 208 |
{ |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
prv = st; |
| 213 |
switch (st) { |
| 214 |
case p7T_B: |
| 215 |
if (p7_profile_IsLocal(gm)) |
| 216 |
{ |
| 217 |
if ((status = sample_endpoints(r, gm, &k, &kend)) != eslOK) goto ERROR; |
| 218 |
st = p7T_M; |
| 219 |
} |
| 220 |
else |
| 221 |
{ |
| 222 |
|
| 223 |
switch (esl_rnd_FChoose(r, P7H_TMAT(hmm, 0), p7H_NTMAT)) { |
| 224 |
case 0: st = p7T_M; k = 1; break; |
| 225 |
case 1: st = p7T_I; k = 0; break; |
| 226 |
case 2: st = p7T_D; k = 1; break; |
| 227 |
default: ESL_XEXCEPTION(eslEINCONCEIVABLE, "impossible."); |
| 228 |
} |
| 229 |
} |
| 230 |
break; |
| 231 |
|
| 232 |
case p7T_M: |
| 233 |
if (k == kend) st = p7T_E; |
| 234 |
else { |
| 235 |
switch (esl_rnd_FChoose(r, P7H_TMAT(hmm, k), p7H_NTMAT)) { |
| 236 |
case 0: st = p7T_M; break; |
| 237 |
case 1: st = p7T_I; break; |
| 238 |
case 2: st = p7T_D; break; |
| 239 |
default: ESL_XEXCEPTION(eslEINCONCEIVABLE, "impossible."); |
| 240 |
} |
| 241 |
} |
| 242 |
break; |
| 243 |
|
| 244 |
case p7T_D: |
| 245 |
if (k == kend) st = p7T_E; |
| 246 |
else st = (esl_rnd_FChoose(r, P7H_TDEL(hmm, k), p7H_NTDEL) == 0) ? p7T_M : p7T_D; |
| 247 |
break; |
| 248 |
|
| 249 |
case p7T_I: st = (esl_rnd_FChoose(r, P7H_TINS(hmm, k), p7H_NTINS) == 0) ? p7T_M : p7T_I; break; |
| 250 |
case p7T_N: st = (esl_rnd_FChoose(r, xt[p7P_N], p7P_NXTRANS) == p7P_MOVE) ? p7T_B : p7T_N; break; |
| 251 |
case p7T_E: st = (esl_rnd_FChoose(r, xt[p7P_E], p7P_NXTRANS) == p7P_MOVE) ? p7T_C : p7T_J; break; |
| 252 |
case p7T_C: st = (esl_rnd_FChoose(r, xt[p7P_C], p7P_NXTRANS) == p7P_MOVE) ? p7T_T : p7T_C; break; |
| 253 |
case p7T_J: st = (esl_rnd_FChoose(r, xt[p7P_J], p7P_NXTRANS) == p7P_MOVE) ? p7T_B : p7T_J; break; |
| 254 |
default: ESL_XEXCEPTION(eslECORRUPT, "impossible state reached during emission"); |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
if (st == p7T_E) k = 0; |
| 259 |
else if (st == p7T_M && prv != p7T_B) k++; |
| 260 |
else if (st == p7T_D) k++; |
| 261 |
|
| 262 |
|
| 263 |
if (st == p7T_M) x = esl_rnd_FChoose(r, hmm->mat[k], hmm->abc->K); |
| 264 |
else if (st == p7T_I) x = esl_rnd_FChoose(r, hmm->ins[k], hmm->abc->K); |
| 265 |
else if ((st == p7T_N || st == p7T_C || st == p7T_J) && prv==st) x = esl_rnd_FChoose(r, bg->f, hmm->abc->K); |
| 266 |
else x = eslDSQ_SENTINEL; |
| 267 |
|
| 268 |
if (x != eslDSQ_SENTINEL) i++; |
| 269 |
|
| 270 |
|
| 271 |
if (sq != NULL && x != eslDSQ_SENTINEL && (status = esl_sq_XAddResidue(sq, x)) != eslOK) goto ERROR; |
| 272 |
|
| 273 |
|
| 274 |
if (tr != NULL) { |
| 275 |
if ((status = p7_trace_Append(tr, st, k, i)) != eslOK) goto ERROR; |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
if (tr != NULL) { tr->M = hmm->M; tr->L = i; } |
| 280 |
if (sq != NULL && (status = esl_sq_XAddResidue(sq, eslDSQ_SENTINEL)) != eslOK) goto ERROR; |
| 281 |
return eslOK; |
| 282 |
|
| 283 |
ERROR: |
| 284 |
return status; |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
int |
| 300 |
p7_emit_SimpleConsensus(const P7_HMM *hmm, ESL_SQ *sq) |
| 301 |
{ |
| 302 |
int k; |
| 303 |
int x; |
| 304 |
int status; |
| 305 |
|
| 306 |
if (! esl_sq_IsDigital(sq)) ESL_EXCEPTION(eslEINVAL, "p7_emit_SimpleConsensus() expects a digital-mode <sq>"); |
| 307 |
if ((status = esl_sq_GrowTo(sq, hmm->M)) != eslOK) return status; |
| 308 |
|
| 309 |
for (k = 1; k <= hmm->M; k++) |
| 310 |
{ |
| 311 |
if (hmm->mm && hmm->mm[k] == 'm') { |
| 312 |
if ((status = esl_sq_XAddResidue(sq, hmm->abc->Kp-3)) != eslOK) return status; |
| 313 |
} else { |
| 314 |
x = esl_vec_FArgMax(hmm->mat[k], hmm->abc->K); |
| 315 |
if ((status = esl_sq_XAddResidue(sq, x)) != eslOK) return status; |
| 316 |
} |
| 317 |
} |
| 318 |
if ((status = esl_sq_XAddResidue(sq, eslDSQ_SENTINEL)) != eslOK) return status; |
| 319 |
return eslOK; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
int |
| 345 |
p7_emit_FancyConsensus(const P7_HMM *hmm, float min_lower, float min_upper, ESL_SQ *sq) |
| 346 |
{ |
| 347 |
int k, x; |
| 348 |
float p; |
| 349 |
char c; |
| 350 |
int status; |
| 351 |
|
| 352 |
if (! esl_sq_IsText(sq)) ESL_EXCEPTION(eslEINVAL, "p7_emit_FancyConsensus() expects a text-mode <sq>"); |
| 353 |
|
| 354 |
if ((status = esl_sq_GrowTo(sq, hmm->M)) != eslOK) return status; |
| 355 |
|
| 356 |
for (k = 1; k <= hmm->M; k++) |
| 357 |
{ |
| 358 |
|
| 359 |
if (hmm->mm && hmm->mm[k] == 'm') { |
| 360 |
if ((status = esl_sq_CAddResidue(sq, tolower(esl_abc_CGetUnknown(hmm->abc))) ) != eslOK) return status; |
| 361 |
} else { |
| 362 |
p = esl_vec_FMax( hmm->mat[k], hmm->abc->K); |
| 363 |
x = esl_vec_FArgMax(hmm->mat[k], hmm->abc->K); |
| 364 |
|
| 365 |
if (p < min_lower) c = tolower(esl_abc_CGetUnknown(hmm->abc)); |
| 366 |
else if (p >= min_upper) c = toupper(hmm->abc->sym[x]); |
| 367 |
else c = tolower(hmm->abc->sym[x]); |
| 368 |
|
| 369 |
if ((status = esl_sq_CAddResidue(sq, c)) != eslOK) return status; |
| 370 |
} |
| 371 |
} |
| 372 |
if ((status = esl_sq_CAddResidue(sq, '\0')) != eslOK) return status; |
| 373 |
return eslOK; |
| 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 |
static int |
| 405 |
sample_endpoints(ESL_RANDOMNESS *r, const P7_PROFILE *gm, int *ret_kstart, int *ret_kend) |
| 406 |
{ |
| 407 |
float *pstart = NULL; |
| 408 |
int k; |
| 409 |
int kstart, kend; |
| 410 |
int status; |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
ESL_ALLOC(pstart, sizeof(float) * (gm->M+1)); |
| 417 |
pstart[0] = 0.0f; |
| 418 |
for (k = 1; k <= gm->M; k++) |
| 419 |
pstart[k] = exp(p7P_TSC(gm, k-1, p7P_BM)) * (gm->M - k + 1); |
| 420 |
kstart = esl_rnd_FChoose(r, pstart, gm->M+1); |
| 421 |
kend = kstart + esl_rnd_Roll(r, gm->M-kstart+1); |
| 422 |
|
| 423 |
free(pstart); |
| 424 |
*ret_kstart = kstart; |
| 425 |
*ret_kend = kend; |
| 426 |
return eslOK; |
| 427 |
|
| 428 |
ERROR: |
| 429 |
if (pstart != NULL) free(pstart); |
| 430 |
*ret_kstart = 0; |
| 431 |
*ret_kend = 0; |
| 432 |
return status; |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
#ifdef p7EMIT_STATS |
| 445 |
#include <p7_config.h> |
| 446 |
|
| 447 |
#include <stdio.h> |
| 448 |
|
| 449 |
#include "easel.h" |
| 450 |
#include "esl_alphabet.h" |
| 451 |
#include "esl_random.h" |
| 452 |
#include "esl_sq.h" |
| 453 |
#include "hmmer.h" |
| 454 |
|
| 455 |
int |
| 456 |
main(int argc, char **argv) |
| 457 |
{ |
| 458 |
char *hmmfile = argv[1]; |
| 459 |
ESL_ALPHABET *abc = NULL; |
| 460 |
ESL_RANDOMNESS *r = NULL; |
| 461 |
P7_HMMFILE *hfp = NULL; |
| 462 |
P7_HMM *hmm = NULL; |
| 463 |
P7_PROFILE *gm = NULL; |
| 464 |
P7_BG *bg = NULL; |
| 465 |
P7_TRACE *tr = NULL; |
| 466 |
ESL_SQ *sq = NULL; |
| 467 |
int n = 1000; |
| 468 |
int counts[p7T_NSTATETYPES]; |
| 469 |
int i; |
| 470 |
float sc; |
| 471 |
float nullsc; |
| 472 |
double bitscore; |
| 473 |
|
| 474 |
r = esl_randomness_CreateFast(0); |
| 475 |
tr = p7_trace_Create(); |
| 476 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("failed to open %s", hmmfile); |
| 477 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("failed to read HMM"); |
| 478 |
sq = esl_sq_CreateDigital(abc); |
| 479 |
bg = p7_bg_Create(abc); |
| 480 |
gm = p7_profile_Create(hmm->M, abc); |
| 481 |
|
| 482 |
p7_ProfileConfig(hmm, bg, gm, sq->n, p7_LOCAL); |
| 483 |
|
| 484 |
for (i = 0; i < n; i++) |
| 485 |
{ |
| 486 |
p7_ProfileEmit(r, hmm, gm, bg, sq, tr); |
| 487 |
p7_trace_GetStateUseCounts(tr, counts); |
| 488 |
|
| 489 |
p7_ReconfigLength(gm, sq->n); |
| 490 |
p7_bg_SetLength(bg, sq->n); |
| 491 |
p7_trace_Score(tr, sq->dsq, gm, &sc); |
| 492 |
p7_bg_NullOne (bg, sq->dsq, sq->n, &nullsc); |
| 493 |
bitscore = (sc - nullsc)/ eslCONST_LOG2; |
| 494 |
|
| 495 |
printf("%d %8.4f\n", |
| 496 |
counts[p7T_M] + (counts[p7T_I] + counts[p7T_D])/2, |
| 497 |
bitscore); |
| 498 |
} |
| 499 |
|
| 500 |
p7_profile_Destroy(gm); |
| 501 |
esl_sq_Destroy(sq); |
| 502 |
p7_trace_Destroy(tr); |
| 503 |
esl_randomness_Destroy(r); |
| 504 |
esl_alphabet_Destroy(abc); |
| 505 |
p7_hmmfile_Close(hfp); |
| 506 |
p7_hmm_Destroy(hmm); |
| 507 |
return eslOK; |
| 508 |
} |
| 509 |
#endif |
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
#ifdef p7EMIT_EXAMPLE |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
#include <p7_config.h> |
| 521 |
|
| 522 |
#include "easel.h" |
| 523 |
#include "esl_alphabet.h" |
| 524 |
#include "esl_getopts.h" |
| 525 |
#include "esl_sq.h" |
| 526 |
#include "esl_sqio.h" |
| 527 |
|
| 528 |
#include "hmmer.h" |
| 529 |
|
| 530 |
static ESL_OPTIONS options[] = { |
| 531 |
|
| 532 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 533 |
{ "-s", eslARG_INT, "42", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 }, |
| 534 |
{ "-L", eslARG_INT, "100", NULL, NULL, NULL, NULL, NULL, "configured mean seq length for profile", 0 }, |
| 535 |
{ "-N", eslARG_INT, "10", NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 536 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 537 |
}; |
| 538 |
static char usage[] = "[-options] <hmmfile>"; |
| 539 |
static char banner[] = "example of emitting sequences from profile"; |
| 540 |
|
| 541 |
int |
| 542 |
main(int argc, char **argv) |
| 543 |
{ |
| 544 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 545 |
ESL_RANDOMNESS *rng = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); |
| 546 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 547 |
int L = esl_opt_GetInteger(go, "-L"); |
| 548 |
int N = esl_opt_GetInteger(go, "-N"); |
| 549 |
ESL_ALPHABET *abc = NULL; |
| 550 |
P7_HMMFILE *hfp = NULL; |
| 551 |
P7_HMM *hmm = NULL; |
| 552 |
P7_BG *bg = NULL; |
| 553 |
P7_PROFILE *gm = NULL; |
| 554 |
P7_TRACE *tr = p7_trace_Create(); |
| 555 |
ESL_SQ *sq = NULL; |
| 556 |
char errbuf[eslERRBUFSIZE]; |
| 557 |
int i; |
| 558 |
int status; |
| 559 |
|
| 560 |
status = p7_hmmfile_Open(hmmfile, NULL, &hfp, errbuf); |
| 561 |
if (status == eslENOTFOUND) p7_Fail("File existence/permissions problem in trying to open HMM file %s.\n%s\n", hmmfile, errbuf); |
| 562 |
else if (status == eslEFORMAT) p7_Fail("File format problem in trying to open HMM file %s.\n%s\n", hmmfile, errbuf); |
| 563 |
else if (status != eslOK) p7_Fail("Unexpected error %d in opening HMM file %s.\n%s\n", status, hmmfile, errbuf); |
| 564 |
|
| 565 |
status = p7_hmmfile_Read(hfp, &abc, &hmm); |
| 566 |
if (status == eslEFORMAT) p7_Fail("Bad file format in HMM file %s:\n%s\n", hfp->fname, hfp->errbuf); |
| 567 |
else if (status == eslEINCOMPAT) p7_Fail("HMM in %s is not in the expected %s alphabet\n", hfp->fname, esl_abc_DecodeType(abc->type)); |
| 568 |
else if (status == eslEOF) p7_Fail("Empty HMM file %s? No HMM data found.\n", hfp->fname); |
| 569 |
else if (status != eslOK) p7_Fail("Unexpected error in reading HMMs from %s\n", hfp->fname); |
| 570 |
|
| 571 |
p7_hmmfile_Close(hfp); |
| 572 |
|
| 573 |
bg = p7_bg_Create(abc); p7_bg_SetLength(bg, L); |
| 574 |
gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL); |
| 575 |
sq = esl_sq_CreateDigital(abc); |
| 576 |
|
| 577 |
for (i = 0; i < N; i++) |
| 578 |
{ |
| 579 |
p7_ProfileEmit(rng, hmm, gm, bg, sq, tr); |
| 580 |
esl_sq_FormatName(sq, "%s-sample%d", hmm->name, i); |
| 581 |
esl_sqio_Write(stdout, sq, eslSQFILE_FASTA, FALSE); |
| 582 |
|
| 583 |
if (p7_trace_Validate(tr, abc, sq->dsq, errbuf) != eslOK) esl_fatal(errbuf); |
| 584 |
|
| 585 |
esl_sq_Reuse(sq); |
| 586 |
p7_trace_Reuse(tr); |
| 587 |
} |
| 588 |
|
| 589 |
esl_sq_Destroy(sq); |
| 590 |
p7_trace_Destroy(tr); |
| 591 |
p7_profile_Destroy(gm); |
| 592 |
p7_bg_Destroy(bg); |
| 593 |
p7_hmm_Destroy(hmm); |
| 594 |
esl_alphabet_Destroy(abc); |
| 595 |
esl_randomness_Destroy(rng); |
| 596 |
esl_getopts_Destroy(go); |
| 597 |
return 0; |
| 598 |
} |
| 599 |
#endif |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|