| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <p7_config.h> |
| 7 |
#include "easel.h" |
| 8 |
#include "esl_cluster.h" |
| 9 |
#include "esl_vectorops.h" |
| 10 |
#include "hmmer.h" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
P7_SPENSEMBLE * |
| 43 |
p7_spensemble_Create(int init_n, int init_epc, int init_sigc) |
| 44 |
{ |
| 45 |
P7_SPENSEMBLE *sp = NULL; |
| 46 |
int status; |
| 47 |
|
| 48 |
ESL_ALLOC(sp, sizeof(P7_SPENSEMBLE)); |
| 49 |
sp->sp = NULL; |
| 50 |
sp->workspace = NULL; |
| 51 |
sp->assignment = NULL; |
| 52 |
sp->epc = NULL; |
| 53 |
sp->sigc = NULL; |
| 54 |
|
| 55 |
sp->nalloc = init_n; |
| 56 |
sp->epc_alloc = init_epc; |
| 57 |
sp->nsigc_alloc = init_sigc; |
| 58 |
|
| 59 |
ESL_ALLOC(sp->sp, sizeof(struct p7_spcoord_s) * sp->nalloc); |
| 60 |
ESL_ALLOC(sp->workspace, sizeof(int) * sp->nalloc * 2); |
| 61 |
ESL_ALLOC(sp->assignment, sizeof(int) * sp->nalloc); |
| 62 |
ESL_ALLOC(sp->epc, sizeof(int) * sp->epc_alloc); |
| 63 |
ESL_ALLOC(sp->sigc, sizeof(struct p7_spcoord_s) * sp->nsigc_alloc); |
| 64 |
sp->nsamples = 0; |
| 65 |
sp->n = 0; |
| 66 |
sp->nc = 0; |
| 67 |
sp->nsigc = 0; |
| 68 |
return sp; |
| 69 |
|
| 70 |
ERROR: |
| 71 |
p7_spensemble_Destroy(sp); |
| 72 |
return NULL; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
int |
| 86 |
p7_spensemble_Reuse(P7_SPENSEMBLE *sp) |
| 87 |
{ |
| 88 |
sp->nsamples = 0; |
| 89 |
sp->n = 0; |
| 90 |
sp->nc = 0; |
| 91 |
sp->nsigc = 0; |
| 92 |
return eslOK; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 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 |
|
| 141 |
|
| 142 |
int |
| 143 |
p7_spensemble_Add(P7_SPENSEMBLE *sp, int sampleidx, int i, int j, int k, int m) |
| 144 |
{ |
| 145 |
int status; |
| 146 |
|
| 147 |
if (sampleidx > sp->nsamples) ESL_EXCEPTION(eslEINVAL, "seg pair's <sampleidx> is out of order"); |
| 148 |
else if (sampleidx == sp->nsamples) sp->nsamples++; |
| 149 |
|
| 150 |
if (sp->n >= sp->nalloc) { |
| 151 |
void *p; |
| 152 |
ESL_RALLOC(sp->sp, p, sizeof(struct p7_spcoord_s) * sp->nalloc * 2); |
| 153 |
ESL_RALLOC(sp->workspace, p, sizeof(int) * sp->nalloc * 4); |
| 154 |
ESL_RALLOC(sp->assignment, p, sizeof(int) * sp->nalloc * 2); |
| 155 |
sp->nalloc *= 2; |
| 156 |
} |
| 157 |
|
| 158 |
sp->sp[sp->n].idx = sampleidx; |
| 159 |
sp->sp[sp->n].i = i; |
| 160 |
sp->sp[sp->n].j = j; |
| 161 |
sp->sp[sp->n].k = k; |
| 162 |
sp->sp[sp->n].m = m; |
| 163 |
sp->n++; |
| 164 |
return eslOK; |
| 165 |
|
| 166 |
ERROR: |
| 167 |
return status; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
struct p7_linkparam_s { |
| 176 |
float min_overlap; |
| 177 |
int of_smaller; |
| 178 |
int max_diagdiff; |
| 179 |
float min_posterior; |
| 180 |
float min_endpointp; |
| 181 |
}; |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
static int |
| 191 |
link_spsamples(const void *v1, const void *v2, const void *prm, int *ret_link) |
| 192 |
{ |
| 193 |
struct p7_spcoord_s *h1 = (struct p7_spcoord_s *) v1; |
| 194 |
struct p7_spcoord_s *h2 = (struct p7_spcoord_s *) v2; |
| 195 |
struct p7_linkparam_s *param = (struct p7_linkparam_s *) prm; |
| 196 |
int nov, n; |
| 197 |
int d1, d2; |
| 198 |
|
| 199 |
|
| 200 |
nov = ESL_MIN(h1->j, h2->j) - ESL_MAX(h1->i, h2->i) + 1; |
| 201 |
n = (param->of_smaller ? ESL_MIN(h1->j - h1->i + 1, h2->j - h2->i + 1) : |
| 202 |
ESL_MAX(h1->j - h1->i + 1, h2->j - h2->i + 1)); |
| 203 |
if ((float) nov / (float) n < param->min_overlap) { *ret_link = FALSE; return eslOK; } |
| 204 |
|
| 205 |
|
| 206 |
nov = ESL_MIN(h1->m, h2->m) - ESL_MAX(h1->k, h2->k); |
| 207 |
n = (param->of_smaller ? ESL_MIN(h1->m - h1->k + 1, h2->m - h2->k + 1) : |
| 208 |
ESL_MAX(h1->m - h1->k + 1, h2->m - h2->k + 1)); |
| 209 |
if ((float) nov / (float) n < param->min_overlap) { *ret_link = FALSE; return eslOK; } |
| 210 |
|
| 211 |
|
| 212 |
d1 = (h1->i - h1->k); d2 = (h2->i - h2->k); if (abs(d1-d2) <= param->max_diagdiff) { *ret_link = TRUE; return eslOK; } |
| 213 |
d1 = (h1->j - h1->m); d2 = (h2->j - h2->m); if (abs(d1-d2) <= param->max_diagdiff) { *ret_link = TRUE; return eslOK; } |
| 214 |
|
| 215 |
*ret_link = FALSE; |
| 216 |
return eslOK; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
static int |
| 225 |
cluster_orderer(const void *v1, const void *v2) |
| 226 |
{ |
| 227 |
struct p7_spcoord_s *h1 = (struct p7_spcoord_s *) v1; |
| 228 |
struct p7_spcoord_s *h2 = (struct p7_spcoord_s *) v2; |
| 229 |
|
| 230 |
if (h1->i < h2->i) return -1; |
| 231 |
else if (h1->i > h2->i) return 1; |
| 232 |
else return 0; |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
int |
| 281 |
p7_spensemble_Cluster(P7_SPENSEMBLE *sp, |
| 282 |
float min_overlap, int of_smaller, int max_diagdiff, float min_posterior, float min_endpointp, |
| 283 |
int *ret_nclusters) |
| 284 |
{ |
| 285 |
struct p7_linkparam_s param; |
| 286 |
int status; |
| 287 |
int c; |
| 288 |
int h; |
| 289 |
int idx_of_last; |
| 290 |
int *ninc = NULL; |
| 291 |
int cwindow_width; |
| 292 |
int epc_threshold; |
| 293 |
int imin, jmin, kmin, mmin; |
| 294 |
int imax, jmax, kmax, mmax; |
| 295 |
int best_i, best_j, best_k, best_m; |
| 296 |
|
| 297 |
|
| 298 |
param.min_overlap = min_overlap; |
| 299 |
param.of_smaller = of_smaller; |
| 300 |
param.max_diagdiff = max_diagdiff; |
| 301 |
param.min_posterior = min_posterior; |
| 302 |
param.min_endpointp = min_endpointp; |
| 303 |
if ((status = esl_cluster_SingleLinkage(sp->sp, sp->n, sizeof(struct p7_spcoord_s), link_spsamples, (void *) ¶m, |
| 304 |
sp->workspace, sp->assignment, &(sp->nc))) != eslOK) goto ERROR; |
| 305 |
|
| 306 |
ESL_ALLOC(ninc, sizeof(int) * sp->nc); |
| 307 |
|
| 308 |
|
| 309 |
for (c = 0; c < sp->nc; c++) |
| 310 |
{ |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
idx_of_last = -1; |
| 317 |
for (ninc[c] = 0, h = 0; h < sp->n; h++) { |
| 318 |
if (sp->assignment[h] == c) { |
| 319 |
if (sp->sp[h].idx != idx_of_last) ninc[c]++; |
| 320 |
idx_of_last = sp->sp[h].idx; |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
if ((float) ninc[c] / (float) sp->nsamples < min_posterior) continue; |
| 325 |
|
| 326 |
|
| 327 |
for (imin = 0, h = 0; h < sp->n; h++) |
| 328 |
if (sp->assignment[h] == c) |
| 329 |
{ |
| 330 |
if (imin == 0) { |
| 331 |
imin = imax = sp->sp[h].i; |
| 332 |
jmin = jmax = sp->sp[h].j; |
| 333 |
kmin = kmax = sp->sp[h].k; |
| 334 |
mmin = mmax = sp->sp[h].m; |
| 335 |
} else { |
| 336 |
imin = ESL_MIN(imin, sp->sp[h].i); imax = ESL_MAX(imax, sp->sp[h].i); |
| 337 |
jmin = ESL_MIN(jmin, sp->sp[h].j); jmax = ESL_MAX(jmax, sp->sp[h].j); |
| 338 |
kmin = ESL_MIN(kmin, sp->sp[h].k); kmax = ESL_MAX(kmax, sp->sp[h].k); |
| 339 |
mmin = ESL_MIN(mmin, sp->sp[h].m); mmax = ESL_MAX(mmax, sp->sp[h].m); |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
cwindow_width = ESL_MAX(ESL_MAX(imax-imin+1, jmax-jmin+1), |
| 345 |
ESL_MAX(kmax-kmin+1, mmax-mmin+1)); |
| 346 |
if (cwindow_width > sp->epc_alloc) { |
| 347 |
void *p; |
| 348 |
ESL_RALLOC(sp->epc, p, sizeof(int) * cwindow_width); |
| 349 |
sp->epc_alloc = cwindow_width; |
| 350 |
} |
| 351 |
|
| 352 |
epc_threshold = (int) ceilf((float) ninc[c] * min_endpointp); |
| 353 |
|
| 354 |
|
| 355 |
esl_vec_ISet(sp->epc, imax-imin+1, 0); |
| 356 |
for (h = 0; h < sp->n; h++) if (sp->assignment[h] == c) sp->epc[sp->sp[h].i-imin]++; |
| 357 |
for (best_i = imin; best_i <= imax; best_i++) if (sp->epc[best_i-imin] >= epc_threshold) break; |
| 358 |
if (best_i > imax) best_i = imin + esl_vec_IArgMax(sp->epc, imax-imin+1); |
| 359 |
|
| 360 |
|
| 361 |
esl_vec_ISet(sp->epc, kmax-kmin+1, 0); |
| 362 |
for (h = 0; h < sp->n; h++) if (sp->assignment[h] == c) sp->epc[sp->sp[h].k-kmin]++; |
| 363 |
for (best_k = kmin; best_k <= kmax; best_k++) if (sp->epc[best_k-kmin] >= epc_threshold) break; |
| 364 |
if (best_k > kmax) best_k = kmin + esl_vec_IArgMax(sp->epc, kmax-kmin+1); |
| 365 |
|
| 366 |
|
| 367 |
esl_vec_ISet(sp->epc, jmax-jmin+1, 0); |
| 368 |
for (h = 0; h < sp->n; h++) if (sp->assignment[h] == c) sp->epc[sp->sp[h].j-jmin]++; |
| 369 |
for (best_j = jmax; best_j >= jmin; best_j--) if (sp->epc[best_j-jmin] >= epc_threshold) break; |
| 370 |
if (best_j < jmin) best_j = jmin + esl_vec_IArgMax(sp->epc, jmax-jmin+1); |
| 371 |
|
| 372 |
|
| 373 |
esl_vec_ISet(sp->epc, mmax-mmin+1, 0); |
| 374 |
for (h = 0; h < sp->n; h++) if (sp->assignment[h] == c) sp->epc[sp->sp[h].m-mmin]++; |
| 375 |
for (best_m = mmax; best_m >= mmin; best_m--) if (sp->epc[best_m-mmin] >= epc_threshold) break; |
| 376 |
if (best_m < mmin) best_m = mmin + esl_vec_IArgMax(sp->epc, mmax-mmin+1); |
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
if (best_i > best_j || best_k > best_m) continue; |
| 382 |
|
| 383 |
if (sp->nsigc >= sp->nsigc_alloc) { |
| 384 |
void *p; |
| 385 |
ESL_RALLOC(sp->sigc, p, sizeof(struct p7_spcoord_s) * sp->nsigc_alloc * 2); |
| 386 |
sp->nsigc_alloc *= 2; |
| 387 |
} |
| 388 |
|
| 389 |
sp->sigc[sp->nsigc].i = best_i; |
| 390 |
sp->sigc[sp->nsigc].j = best_j; |
| 391 |
sp->sigc[sp->nsigc].k = best_k; |
| 392 |
sp->sigc[sp->nsigc].m = best_m; |
| 393 |
sp->sigc[sp->nsigc].idx = c; |
| 394 |
sp->sigc[sp->nsigc].prob = (float) ninc[c] / (float) sp->nsamples; |
| 395 |
sp->nsigc++; |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
qsort((void *) sp->sigc, sp->nsigc, sizeof(struct p7_spcoord_s), cluster_orderer); |
| 402 |
|
| 403 |
free(ninc); |
| 404 |
*ret_nclusters = sp->nsigc; |
| 405 |
return eslOK; |
| 406 |
|
| 407 |
ERROR: |
| 408 |
if (ninc != NULL) free(ninc); |
| 409 |
*ret_nclusters = 0; |
| 410 |
return status; |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
int |
| 428 |
p7_spensemble_GetClusterCoords(P7_SPENSEMBLE *sp, int which, int *opt_i, int *opt_j, int *opt_k, int *opt_m, float *opt_p) |
| 429 |
{ |
| 430 |
if (opt_i != NULL) *opt_i = sp->sigc[which].i; |
| 431 |
if (opt_j != NULL) *opt_j = sp->sigc[which].j; |
| 432 |
if (opt_k != NULL) *opt_k = sp->sigc[which].k; |
| 433 |
if (opt_m != NULL) *opt_m = sp->sigc[which].m; |
| 434 |
if (opt_p != NULL) *opt_p = sp->sigc[which].prob; |
| 435 |
return eslOK; |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
void |
| 446 |
p7_spensemble_Destroy(P7_SPENSEMBLE *sp) |
| 447 |
{ |
| 448 |
if (sp == NULL) return; |
| 449 |
if (sp->sp != NULL) free(sp->sp); |
| 450 |
if (sp->workspace != NULL) free(sp->workspace); |
| 451 |
if (sp->assignment != NULL) free(sp->assignment); |
| 452 |
if (sp->epc != NULL) free(sp->epc); |
| 453 |
if (sp->sigc != NULL) free(sp->sigc); |
| 454 |
free(sp); |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
#ifdef p7SPENSEMBLE_EXAMPLE |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
#include <p7_config.h> |
| 468 |
|
| 469 |
#include <stdio.h> |
| 470 |
#include <stdlib.h> |
| 471 |
|
| 472 |
#include "easel.h" |
| 473 |
#include "esl_getopts.h" |
| 474 |
#include "esl_random.h" |
| 475 |
#include "esl_alphabet.h" |
| 476 |
#include "esl_dmatrix.h" |
| 477 |
#include "esl_sq.h" |
| 478 |
#include "esl_sqio.h" |
| 479 |
#include "esl_cluster.h" |
| 480 |
#include "esl_vectorops.h" |
| 481 |
#include "esl_stopwatch.h" |
| 482 |
#include "hmmer.h" |
| 483 |
|
| 484 |
static ESL_OPTIONS options[] = { |
| 485 |
|
| 486 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 487 |
{ "-s", eslARG_INT, "42", NULL, NULL, NULL, NULL, NULL, "set random number seed to <n>", 0 }, |
| 488 |
{ "-N", eslARG_INT, "1000", NULL, NULL, NULL, NULL, NULL, "number of trace samples to take", 0 }, |
| 489 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 490 |
}; |
| 491 |
static char usage[] = "[-options] <hmmfile> <seqfile>"; |
| 492 |
static char banner[] = "example, test, benchmark of defining domains by posterior sampling"; |
| 493 |
|
| 494 |
int |
| 495 |
main(int argc, char **argv) |
| 496 |
{ |
| 497 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 2, argc, argv, banner, usage); |
| 498 |
ESL_STOPWATCH *w = esl_stopwatch_Create(); |
| 499 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); |
| 500 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 501 |
char *seqfile = esl_opt_GetArg(go, 2); |
| 502 |
int format = eslSQFILE_FASTA; |
| 503 |
ESL_ALPHABET *abc = NULL; |
| 504 |
P7_HMMFILE *hfp = NULL; |
| 505 |
P7_HMM *hmm = NULL; |
| 506 |
P7_BG *bg = NULL; |
| 507 |
P7_PROFILE *gm = NULL; |
| 508 |
P7_OPROFILE *om = NULL; |
| 509 |
P7_OMX *fwd = NULL; |
| 510 |
ESL_SQ *sq = NULL; |
| 511 |
ESL_SQFILE *sqfp = NULL; |
| 512 |
P7_TRACE *tr = NULL; |
| 513 |
P7_SPENSEMBLE *sp = NULL; |
| 514 |
int N = esl_opt_GetInteger(go, "-N"); |
| 515 |
int t,d,nc; |
| 516 |
int i,j,k,m; |
| 517 |
float sc; |
| 518 |
float prob; |
| 519 |
int status; |
| 520 |
|
| 521 |
|
| 522 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 523 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 524 |
p7_hmmfile_Close(hfp); |
| 525 |
|
| 526 |
|
| 527 |
sq = esl_sq_CreateDigital(abc); |
| 528 |
status = esl_sqfile_Open(seqfile, format, NULL, &sqfp); |
| 529 |
if (status == eslENOTFOUND) p7_Fail("No such file."); |
| 530 |
else if (status == eslEFORMAT) p7_Fail("Format unrecognized."); |
| 531 |
else if (status == eslEINVAL) p7_Fail("Can't autodetect stdin or .gz."); |
| 532 |
else if (status != eslOK) p7_Fail("Open failed, code %d.", status); |
| 533 |
if (esl_sqio_Read(sqfp, sq) != eslOK) p7_Fail("Failed to read sequence"); |
| 534 |
esl_sqfile_Close(sqfp); |
| 535 |
|
| 536 |
|
| 537 |
bg = p7_bg_Create(abc); |
| 538 |
p7_bg_SetLength(bg, sq->n); |
| 539 |
gm = p7_profile_Create(hmm->M, abc); |
| 540 |
om = p7_oprofile_Create(hmm->M, abc); |
| 541 |
p7_ProfileConfig(hmm, bg, gm, sq->n, p7_LOCAL); |
| 542 |
p7_oprofile_Convert(gm, om); |
| 543 |
p7_oprofile_ReconfigLength(om, sq->n); |
| 544 |
|
| 545 |
|
| 546 |
fwd = p7_omx_Create(gm->M, sq->n, sq->n); |
| 547 |
p7_Forward (sq->dsq, sq->n, om, fwd, &sc); |
| 548 |
|
| 549 |
|
| 550 |
tr = p7_trace_Create(); |
| 551 |
sp = p7_spensemble_Create(1024, 64, 32); |
| 552 |
|
| 553 |
|
| 554 |
esl_stopwatch_Start(w); |
| 555 |
|
| 556 |
|
| 557 |
for (t = 0; t < N; t++) { |
| 558 |
p7_StochasticTrace(r, sq->dsq, sq->n, om, fwd, tr); |
| 559 |
p7_trace_Index(tr); |
| 560 |
|
| 561 |
for (d = 0; d < tr->ndom; d++) |
| 562 |
p7_spensemble_Add(sp, t, tr->sqfrom[d], tr->sqto[d], tr->hmmfrom[d], tr->hmmto[d]); |
| 563 |
p7_trace_Reuse(tr); |
| 564 |
} |
| 565 |
p7_spensemble_Cluster(sp, 0.8, TRUE, 4, 0.25, 0.02, &nc); |
| 566 |
for (d = 0; d < nc; d++) { |
| 567 |
p7_spensemble_GetClusterCoords(sp, d, &i, &j, &k, &m, &prob); |
| 568 |
printf("domain %-4d : %6d %6d %6d %6d p=%.4f\n", d, i, j, k, m, prob); |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
esl_stopwatch_Stop(w); |
| 573 |
esl_stopwatch_Display(stdout, w, "# CPU time: "); |
| 574 |
|
| 575 |
p7_spensemble_Destroy(sp); |
| 576 |
p7_trace_Destroy(tr); |
| 577 |
esl_sq_Destroy(sq); |
| 578 |
p7_omx_Destroy(fwd); |
| 579 |
p7_profile_Destroy(gm); |
| 580 |
p7_oprofile_Destroy(om); |
| 581 |
p7_bg_Destroy(bg); |
| 582 |
p7_hmm_Destroy(hmm); |
| 583 |
esl_stopwatch_Destroy(w); |
| 584 |
esl_randomness_Destroy(r); |
| 585 |
esl_alphabet_Destroy(abc); |
| 586 |
esl_getopts_Destroy(go); |
| 587 |
return 0; |
| 588 |
} |
| 589 |
#endif |