| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <p7_config.h> |
| 10 |
|
| 11 |
#include <stdlib.h> |
| 12 |
#include <stdio.h> |
| 13 |
#include <string.h> |
| 14 |
|
| 15 |
#include "easel.h" |
| 16 |
#include "esl_exponential.h" |
| 17 |
#include "esl_getopts.h" |
| 18 |
#include "esl_gumbel.h" |
| 19 |
#include "esl_vectorops.h" |
| 20 |
|
| 21 |
#include "hmmer.h" |
| 22 |
|
| 23 |
#include "esl_sqio.h" |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
typedef struct { |
| 29 |
ESL_SQ *tmpseq; |
| 30 |
P7_BG *bg; |
| 31 |
P7_OPROFILE *om; |
| 32 |
float *scores; |
| 33 |
float *fwd_emissions_arr; |
| 34 |
} P7_PIPELINE_LONGTARGET_OBJS; |
| 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 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
P7_PIPELINE * |
| 99 |
p7_pipeline_Create(const ESL_GETOPTS *go, int M_hint, int L_hint, int long_targets, enum p7_pipemodes_e mode) |
| 100 |
{ |
| 101 |
P7_PIPELINE *pli = NULL; |
| 102 |
int seed = (go ? esl_opt_GetInteger(go, "--seed") : 42); |
| 103 |
int status; |
| 104 |
|
| 105 |
ESL_ALLOC(pli, sizeof(P7_PIPELINE)); |
| 106 |
|
| 107 |
pli->do_alignment_score_calc = 0; |
| 108 |
pli->long_targets = long_targets; |
| 109 |
|
| 110 |
if ((pli->fwd = p7_omx_Create(M_hint, L_hint, L_hint)) == NULL) goto ERROR; |
| 111 |
if ((pli->bck = p7_omx_Create(M_hint, L_hint, L_hint)) == NULL) goto ERROR; |
| 112 |
if ((pli->oxf = p7_omx_Create(M_hint, 0, L_hint)) == NULL) goto ERROR; |
| 113 |
if ((pli->oxb = p7_omx_Create(M_hint, 0, L_hint)) == NULL) goto ERROR; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
pli->r = esl_randomness_CreateFast(seed); |
| 121 |
pli->do_reseeding = (seed == 0) ? FALSE : TRUE; |
| 122 |
pli->ddef = p7_domaindef_Create(pli->r); |
| 123 |
pli->ddef->do_reseeding = pli->do_reseeding; |
| 124 |
|
| 125 |
|
| 126 |
pli->by_E = TRUE; |
| 127 |
pli->E = (go ? esl_opt_GetReal(go, "-E") : 10.0); |
| 128 |
pli->T = 0.0; |
| 129 |
pli->dom_by_E = TRUE; |
| 130 |
pli->domE = (go ? esl_opt_GetReal(go, "--domE") : 10.0); |
| 131 |
pli->domT = 0.0; |
| 132 |
pli->use_bit_cutoffs = FALSE; |
| 133 |
if (go && esl_opt_IsOn(go, "-T")) |
| 134 |
{ |
| 135 |
pli->T = esl_opt_GetReal(go, "-T"); |
| 136 |
pli->by_E = FALSE; |
| 137 |
} |
| 138 |
if (go && esl_opt_IsOn(go, "--domT")) |
| 139 |
{ |
| 140 |
pli->domT = esl_opt_GetReal(go, "--domT"); |
| 141 |
pli->dom_by_E = FALSE; |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
pli->inc_by_E = TRUE; |
| 147 |
pli->incE = (go ? esl_opt_GetReal(go, "--incE") : 0.01); |
| 148 |
pli->incT = 0.0; |
| 149 |
pli->incdom_by_E = TRUE; |
| 150 |
pli->incdomE = (go ? esl_opt_GetReal(go, "--incdomE") : 0.01); |
| 151 |
pli->incdomT = 0.0; |
| 152 |
if (go && esl_opt_IsOn(go, "--incT")) |
| 153 |
{ |
| 154 |
pli->incT = esl_opt_GetReal(go, "--incT"); |
| 155 |
pli->inc_by_E = FALSE; |
| 156 |
} |
| 157 |
if (go && esl_opt_IsOn(go, "--incdomT")) |
| 158 |
{ |
| 159 |
pli->incdomT = esl_opt_GetReal(go, "--incdomT"); |
| 160 |
pli->incdom_by_E = FALSE; |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
if (go && esl_opt_GetBoolean(go, "--cut_ga")) |
| 166 |
{ |
| 167 |
pli->T = pli->domT = 0.0; |
| 168 |
pli->by_E = pli->dom_by_E = FALSE; |
| 169 |
pli->incT = pli->incdomT = 0.0; |
| 170 |
pli->inc_by_E = pli->incdom_by_E = FALSE; |
| 171 |
pli->use_bit_cutoffs = p7H_GA; |
| 172 |
} |
| 173 |
if (go && esl_opt_GetBoolean(go, "--cut_nc")) |
| 174 |
{ |
| 175 |
pli->T = pli->domT = 0.0; |
| 176 |
pli->by_E = pli->dom_by_E = FALSE; |
| 177 |
pli->incT = pli->incdomT = 0.0; |
| 178 |
pli->inc_by_E = pli->incdom_by_E = FALSE; |
| 179 |
pli->use_bit_cutoffs = p7H_NC; |
| 180 |
} |
| 181 |
if (go && esl_opt_GetBoolean(go, "--cut_tc")) |
| 182 |
{ |
| 183 |
pli->T = pli->domT = 0.0; |
| 184 |
pli->by_E = pli->dom_by_E = FALSE; |
| 185 |
pli->incT = pli->incdomT = 0.0; |
| 186 |
pli->inc_by_E = pli->incdom_by_E = FALSE; |
| 187 |
pli->use_bit_cutoffs = p7H_TC; |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
pli->Z = pli->domZ = 0.0; |
| 193 |
pli->Z_setby = pli->domZ_setby = p7_ZSETBY_NTARGETS; |
| 194 |
if (go && esl_opt_IsOn(go, "-Z")) |
| 195 |
{ |
| 196 |
pli->Z_setby = p7_ZSETBY_OPTION; |
| 197 |
pli->Z = esl_opt_GetReal(go, "-Z"); |
| 198 |
} |
| 199 |
if (go && esl_opt_IsOn(go, "--domZ")) |
| 200 |
{ |
| 201 |
pli->domZ_setby = p7_ZSETBY_OPTION; |
| 202 |
pli->domZ = esl_opt_GetReal(go, "--domZ"); |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
pli->do_max = FALSE; |
| 208 |
pli->do_biasfilter = TRUE; |
| 209 |
pli->do_null2 = TRUE; |
| 210 |
pli->F1 = ((go && esl_opt_IsOn(go, "--F1")) ? ESL_MIN(1.0, esl_opt_GetReal(go, "--F1")) : 0.02); |
| 211 |
pli->F2 = (go ? ESL_MIN(1.0, esl_opt_GetReal(go, "--F2")) : 1e-3); |
| 212 |
pli->F3 = (go ? ESL_MIN(1.0, esl_opt_GetReal(go, "--F3")) : 1e-5); |
| 213 |
if (long_targets) { |
| 214 |
pli->B1 = (go ? esl_opt_GetInteger(go, "--B1") : 100); |
| 215 |
pli->B2 = (go ? esl_opt_GetInteger(go, "--B2") : 240); |
| 216 |
pli->B3 = (go ? esl_opt_GetInteger(go, "--B3") : 1000); |
| 217 |
} else { |
| 218 |
pli->B1 = pli->B2 = pli->B3 = -1; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
if (go && esl_opt_GetBoolean(go, "--max")) |
| 223 |
{ |
| 224 |
pli->do_max = TRUE; |
| 225 |
pli->do_biasfilter = FALSE; |
| 226 |
|
| 227 |
pli->F2 = pli->F3 = 1.0; |
| 228 |
pli->F1 = (pli->long_targets ? 0.3 : 1.0); |
| 229 |
} |
| 230 |
if (go && esl_opt_GetBoolean(go, "--nonull2")) pli->do_null2 = FALSE; |
| 231 |
if (go && esl_opt_GetBoolean(go, "--nobias")) pli->do_biasfilter = FALSE; |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
pli->nmodels = 0; |
| 236 |
pli->nseqs = 0; |
| 237 |
pli->nres = 0; |
| 238 |
pli->nnodes = 0; |
| 239 |
pli->n_past_msv = 0; |
| 240 |
pli->n_past_bias = 0; |
| 241 |
pli->n_past_vit = 0; |
| 242 |
pli->n_past_fwd = 0; |
| 243 |
pli->pos_past_msv = 0; |
| 244 |
pli->pos_past_bias = 0; |
| 245 |
pli->pos_past_vit = 0; |
| 246 |
pli->pos_past_fwd = 0; |
| 247 |
pli->mode = mode; |
| 248 |
pli->show_accessions = (go && esl_opt_GetBoolean(go, "--acc") ? TRUE : FALSE); |
| 249 |
pli->show_alignments = (go && esl_opt_GetBoolean(go, "--noali") ? FALSE : TRUE); |
| 250 |
pli->hfp = NULL; |
| 251 |
pli->errbuf[0] = '\0'; |
| 252 |
|
| 253 |
return pli; |
| 254 |
|
| 255 |
ERROR: |
| 256 |
p7_pipeline_Destroy(pli); |
| 257 |
return NULL; |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
int |
| 272 |
p7_pipeline_Reuse(P7_PIPELINE *pli) |
| 273 |
{ |
| 274 |
p7_omx_Reuse(pli->oxf); |
| 275 |
p7_omx_Reuse(pli->oxb); |
| 276 |
p7_omx_Reuse(pli->fwd); |
| 277 |
p7_omx_Reuse(pli->bck); |
| 278 |
p7_domaindef_Reuse(pli->ddef); |
| 279 |
return eslOK; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
void |
| 290 |
p7_pipeline_Destroy(P7_PIPELINE *pli) |
| 291 |
{ |
| 292 |
if (pli == NULL) return; |
| 293 |
|
| 294 |
p7_omx_Destroy(pli->oxf); |
| 295 |
p7_omx_Destroy(pli->oxb); |
| 296 |
p7_omx_Destroy(pli->fwd); |
| 297 |
p7_omx_Destroy(pli->bck); |
| 298 |
esl_randomness_Destroy(pli->r); |
| 299 |
p7_domaindef_Destroy(pli->ddef); |
| 300 |
free(pli); |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
int |
| 323 |
p7_pli_ExtendAndMergeWindows (P7_OPROFILE *om, const P7_SCOREDATA *data, P7_HMM_WINDOWLIST *windowlist, float pct_overlap) { |
| 324 |
|
| 325 |
int i; |
| 326 |
P7_HMM_WINDOW *prev_window = NULL; |
| 327 |
P7_HMM_WINDOW *curr_window = NULL; |
| 328 |
int64_t window_start; |
| 329 |
int64_t window_end; |
| 330 |
int32_t window_len; |
| 331 |
int64_t tmp; |
| 332 |
int new_hit_cnt = 0; |
| 333 |
|
| 334 |
if (windowlist->count == 0) |
| 335 |
return eslOK; |
| 336 |
|
| 337 |
|
| 338 |
for (i=0; i<windowlist->count; i++) { |
| 339 |
|
| 340 |
curr_window = windowlist->windows+i; |
| 341 |
|
| 342 |
if ( curr_window->complementarity == p7_COMPLEMENT) { |
| 343 |
|
| 344 |
curr_window->n = curr_window->target_len - curr_window->n + 1; |
| 345 |
|
| 346 |
window_start = ESL_MAX( 1 , curr_window->n - curr_window->length - (om->max_length * (0.1 + data->suffix_lengths[curr_window->k] ) ) ) ; |
| 347 |
window_end = ESL_MIN( curr_window->target_len, curr_window->n + (om->max_length * (0.1 + data->prefix_lengths[curr_window->k - curr_window->length + 1] )) ) ; |
| 348 |
tmp = window_end; |
| 349 |
window_end = curr_window->target_len - window_start; |
| 350 |
window_start = curr_window->target_len - tmp ; |
| 351 |
|
| 352 |
curr_window->n = curr_window->target_len - curr_window->n + 1; |
| 353 |
|
| 354 |
} else { |
| 355 |
|
| 356 |
|
| 357 |
window_start = ESL_MAX( 1 , curr_window->n - (om->max_length * (0.1 + data->prefix_lengths[curr_window->k - curr_window->length + 1] )) ) ; |
| 358 |
window_end = ESL_MIN( curr_window->target_len, curr_window->n + curr_window->length + (om->max_length * (0.1 + data->suffix_lengths[curr_window->k] ) ) ) ; |
| 359 |
} |
| 360 |
|
| 361 |
curr_window->length = window_end - window_start + 1; |
| 362 |
|
| 363 |
curr_window->fm_n -= (curr_window->n - window_start); |
| 364 |
curr_window->n = window_start; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
for (i=1; i<windowlist->count; i++) { |
| 370 |
prev_window = windowlist->windows+new_hit_cnt; |
| 371 |
curr_window = windowlist->windows+i; |
| 372 |
|
| 373 |
window_start = ESL_MAX(prev_window->n, curr_window->n); |
| 374 |
window_end = ESL_MIN(prev_window->n+prev_window->length-1, curr_window->n+curr_window->length-1); |
| 375 |
window_len = window_end - window_start + 1; |
| 376 |
|
| 377 |
if ( prev_window->complementarity == curr_window->complementarity && |
| 378 |
prev_window->id == curr_window->id && |
| 379 |
(float)(window_len)/ESL_MIN(prev_window->length, curr_window->length) > pct_overlap |
| 380 |
|
| 381 |
) |
| 382 |
{ |
| 383 |
|
| 384 |
window_start = ESL_MIN(prev_window->n, curr_window->n); |
| 385 |
window_end = ESL_MAX(prev_window->n+prev_window->length-1, curr_window->n+curr_window->length-1); |
| 386 |
prev_window->fm_n -= (prev_window->n - window_start); |
| 387 |
prev_window->n = window_start; |
| 388 |
prev_window->length = window_end - window_start + 1; |
| 389 |
} else { |
| 390 |
new_hit_cnt++; |
| 391 |
windowlist->windows[new_hit_cnt] = windowlist->windows[i]; |
| 392 |
} |
| 393 |
} |
| 394 |
windowlist->count = new_hit_cnt+1; |
| 395 |
|
| 396 |
return eslOK; |
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
int |
| 407 |
p7_pli_TargetReportable(P7_PIPELINE *pli, float score, double lnP) |
| 408 |
{ |
| 409 |
if ( pli->by_E ) |
| 410 |
{ |
| 411 |
if ( !pli->long_targets && exp(lnP) * pli->Z <= pli->E) return TRUE; |
| 412 |
if ( pli->long_targets && exp(lnP) <= pli->E) return TRUE; |
| 413 |
} |
| 414 |
else if (! pli->by_E && score >= pli->T) return TRUE; |
| 415 |
|
| 416 |
return FALSE; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
int |
| 427 |
p7_pli_DomainReportable(P7_PIPELINE *pli, float dom_score, double lnP) |
| 428 |
{ |
| 429 |
if ( pli->dom_by_E ) |
| 430 |
{ |
| 431 |
if ( !pli->long_targets && exp(lnP) * pli->domZ <= pli->domE) return TRUE; |
| 432 |
if ( pli->long_targets && exp(lnP) <= pli->domE) return TRUE; |
| 433 |
} |
| 434 |
else if (! pli->dom_by_E && dom_score >= pli->domT) return TRUE; |
| 435 |
return FALSE; |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
int |
| 442 |
p7_pli_TargetIncludable(P7_PIPELINE *pli, float score, double lnP) |
| 443 |
{ |
| 444 |
if ( pli->inc_by_E ) |
| 445 |
{ |
| 446 |
if ( !pli->long_targets && exp(lnP) * pli->Z <= pli->incE) return TRUE; |
| 447 |
if ( pli->long_targets && exp(lnP) <= pli->incE) return TRUE; |
| 448 |
} |
| 449 |
|
| 450 |
else if (! pli->inc_by_E && score >= pli->incT) return TRUE; |
| 451 |
|
| 452 |
return FALSE; |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
int |
| 459 |
p7_pli_DomainIncludable(P7_PIPELINE *pli, float dom_score, double lnP) |
| 460 |
{ |
| 461 |
if ( pli->incdom_by_E && exp(lnP) * pli->domZ <= pli->incdomE) return TRUE; |
| 462 |
else if (! pli->incdom_by_E && dom_score >= pli->incdomT) return TRUE; |
| 463 |
else return FALSE; |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
int |
| 492 |
p7_pli_NewModel(P7_PIPELINE *pli, const P7_OPROFILE *om, P7_BG *bg) |
| 493 |
{ |
| 494 |
int status = eslOK; |
| 495 |
|
| 496 |
pli->nmodels++; |
| 497 |
pli->nnodes += om->M; |
| 498 |
if (pli->Z_setby == p7_ZSETBY_NTARGETS && pli->mode == p7_SCAN_MODELS) pli->Z = pli->nmodels; |
| 499 |
|
| 500 |
if (pli->do_biasfilter) p7_bg_SetFilter(bg, om->M, om->compo); |
| 501 |
|
| 502 |
if (pli->mode == p7_SEARCH_SEQS) |
| 503 |
status = p7_pli_NewModelThresholds(pli, om); |
| 504 |
|
| 505 |
pli->W = om->max_length; |
| 506 |
|
| 507 |
return status; |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
int |
| 535 |
p7_pli_NewModelThresholds(P7_PIPELINE *pli, const P7_OPROFILE *om) |
| 536 |
{ |
| 537 |
|
| 538 |
if (pli->use_bit_cutoffs) |
| 539 |
{ |
| 540 |
if (pli->use_bit_cutoffs == p7H_GA) |
| 541 |
{ |
| 542 |
if (om->cutoff[p7_GA1] == p7_CUTOFF_UNSET) |
| 543 |
ESL_FAIL(eslEINVAL, pli->errbuf, "GA bit thresholds unavailable on model %s\n", om->name); |
| 544 |
pli->T = pli->incT = om->cutoff[p7_GA1]; |
| 545 |
pli->domT = pli->incdomT = om->cutoff[p7_GA2]; |
| 546 |
} |
| 547 |
else if (pli->use_bit_cutoffs == p7H_TC) |
| 548 |
{ |
| 549 |
if (om->cutoff[p7_TC1] == p7_CUTOFF_UNSET) |
| 550 |
ESL_FAIL(eslEINVAL, pli->errbuf, "TC bit thresholds unavailable on model %s\n", om->name); |
| 551 |
pli->T = pli->incT = om->cutoff[p7_TC1]; |
| 552 |
pli->domT = pli->incdomT = om->cutoff[p7_TC2]; |
| 553 |
} |
| 554 |
else if (pli->use_bit_cutoffs == p7H_NC) |
| 555 |
{ |
| 556 |
if (om->cutoff[p7_NC1] == p7_CUTOFF_UNSET) |
| 557 |
ESL_FAIL(eslEINVAL, pli->errbuf, "NC bit thresholds unavailable on model %s\n", om->name); |
| 558 |
pli->T = pli->incT = om->cutoff[p7_NC1]; |
| 559 |
pli->domT = pli->incdomT = om->cutoff[p7_NC2]; |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
return eslOK; |
| 564 |
} |
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
int |
| 576 |
p7_pli_NewSeq(P7_PIPELINE *pli, const ESL_SQ *sq) |
| 577 |
{ |
| 578 |
if (! pli->long_targets) { |
| 579 |
pli->nseqs++; |
| 580 |
if (pli->Z_setby == p7_ZSETBY_NTARGETS && pli->mode == p7_SEARCH_SEQS) pli->Z = pli->nseqs; |
| 581 |
} |
| 582 |
pli->nres += sq->n; |
| 583 |
return eslOK; |
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
} |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
int |
| 618 |
p7_pipeline_Merge(P7_PIPELINE *p1, P7_PIPELINE *p2) |
| 619 |
{ |
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
if (p1->mode == p7_SEARCH_SEQS) |
| 624 |
{ |
| 625 |
p1->nseqs += p2->nseqs; |
| 626 |
p1->nres += p2->nres; |
| 627 |
} |
| 628 |
else |
| 629 |
{ |
| 630 |
p1->nmodels += p2->nmodels; |
| 631 |
p1->nnodes += p2->nnodes; |
| 632 |
} |
| 633 |
|
| 634 |
p1->n_past_msv += p2->n_past_msv; |
| 635 |
p1->n_past_bias += p2->n_past_bias; |
| 636 |
p1->n_past_vit += p2->n_past_vit; |
| 637 |
p1->n_past_fwd += p2->n_past_fwd; |
| 638 |
p1->n_output += p2->n_output; |
| 639 |
|
| 640 |
p1->pos_past_msv += p2->pos_past_msv; |
| 641 |
p1->pos_past_bias += p2->pos_past_bias; |
| 642 |
p1->pos_past_vit += p2->pos_past_vit; |
| 643 |
p1->pos_past_fwd += p2->pos_past_fwd; |
| 644 |
p1->pos_output += p2->pos_output; |
| 645 |
|
| 646 |
if (p1->Z_setby == p7_ZSETBY_NTARGETS) |
| 647 |
{ |
| 648 |
p1->Z += (p1->mode == p7_SCAN_MODELS) ? p2->nmodels : p2->nseqs; |
| 649 |
} |
| 650 |
else |
| 651 |
{ |
| 652 |
p1->Z = p2->Z; |
| 653 |
} |
| 654 |
|
| 655 |
return eslOK; |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
int |
| 697 |
p7_Pipeline(P7_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, const ESL_SQ *sq, const ESL_SQ *ntsq, P7_TOPHITS *hitlist) |
| 698 |
{ |
| 699 |
P7_HIT *hit = NULL; |
| 700 |
float usc, vfsc, fwdsc; |
| 701 |
float filtersc; |
| 702 |
float nullsc; |
| 703 |
float seqbias; |
| 704 |
float seq_score; |
| 705 |
float sum_score; |
| 706 |
float pre_score, pre2_score; |
| 707 |
double P; |
| 708 |
double lnP; |
| 709 |
int Ld; |
| 710 |
int d; |
| 711 |
int status; |
| 712 |
|
| 713 |
if (sq->n == 0) return eslOK; |
| 714 |
if (sq->n > 100000) ESL_EXCEPTION(eslETYPE, "Target sequence length > 100K, over comparison pipeline limit.\n(Did you mean to use nhmmer/nhmmscan?)"); |
| 715 |
|
| 716 |
p7_omx_GrowTo(pli->oxf, om->M, 0, sq->n); |
| 717 |
|
| 718 |
|
| 719 |
p7_bg_NullOne (bg, sq->dsq, sq->n, &nullsc); |
| 720 |
|
| 721 |
|
| 722 |
p7_MSVFilter(sq->dsq, sq->n, om, pli->oxf, &usc); |
| 723 |
seq_score = (usc - nullsc) / eslCONST_LOG2; |
| 724 |
P = esl_gumbel_surv(seq_score, om->evparam[p7_MMU], om->evparam[p7_MLAMBDA]); |
| 725 |
if (P > pli->F1) return eslOK; |
| 726 |
pli->n_past_msv++; |
| 727 |
|
| 728 |
|
| 729 |
if (pli->do_biasfilter) |
| 730 |
{ |
| 731 |
p7_bg_FilterScore(bg, sq->dsq, sq->n, &filtersc); |
| 732 |
seq_score = (usc - filtersc) / eslCONST_LOG2; |
| 733 |
P = esl_gumbel_surv(seq_score, om->evparam[p7_MMU], om->evparam[p7_MLAMBDA]); |
| 734 |
if (P > pli->F1) return eslOK; |
| 735 |
} |
| 736 |
else filtersc = nullsc; |
| 737 |
pli->n_past_bias++; |
| 738 |
|
| 739 |
|
| 740 |
if (pli->mode == p7_SCAN_MODELS) |
| 741 |
{ |
| 742 |
if (pli->hfp) p7_oprofile_ReadRest(pli->hfp, om); |
| 743 |
p7_oprofile_ReconfigRestLength(om, sq->n); |
| 744 |
if ((status = p7_pli_NewModelThresholds(pli, om)) != eslOK) return status; |
| 745 |
} |
| 746 |
|
| 747 |
|
| 748 |
if (P > pli->F2) |
| 749 |
{ |
| 750 |
p7_ViterbiFilter(sq->dsq, sq->n, om, pli->oxf, &vfsc); |
| 751 |
seq_score = (vfsc-filtersc) / eslCONST_LOG2; |
| 752 |
P = esl_gumbel_surv(seq_score, om->evparam[p7_VMU], om->evparam[p7_VLAMBDA]); |
| 753 |
if (P > pli->F2) return eslOK; |
| 754 |
} |
| 755 |
pli->n_past_vit++; |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
p7_ForwardParser(sq->dsq, sq->n, om, pli->oxf, &fwdsc); |
| 760 |
seq_score = (fwdsc-filtersc) / eslCONST_LOG2; |
| 761 |
P = esl_exp_surv(seq_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 762 |
if (P > pli->F3) return eslOK; |
| 763 |
pli->n_past_fwd++; |
| 764 |
|
| 765 |
|
| 766 |
p7_omx_GrowTo(pli->oxb, om->M, 0, sq->n); |
| 767 |
p7_BackwardParser(sq->dsq, sq->n, om, pli->oxf, pli->oxb, NULL); |
| 768 |
|
| 769 |
status = p7_domaindef_ByPosteriorHeuristics(sq, ntsq, om, pli->oxf, pli->oxb, pli->fwd, pli->bck, pli->ddef, bg, FALSE, NULL, NULL, NULL); |
| 770 |
if (status != eslOK) ESL_FAIL(status, pli->errbuf, "domain definition workflow failure"); |
| 771 |
if (pli->ddef->nregions == 0) return eslOK; |
| 772 |
if (pli->ddef->nenvelopes == 0) return eslOK; |
| 773 |
if (pli->ddef->ndom == 0) return eslOK; |
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
if (pli->do_null2) |
| 778 |
{ |
| 779 |
seqbias = esl_vec_FSum(pli->ddef->n2sc, sq->n+1); |
| 780 |
seqbias = p7_FLogsum(0.0, log(bg->omega) + seqbias); |
| 781 |
} |
| 782 |
else seqbias = 0.0; |
| 783 |
pre_score = (fwdsc - nullsc) / eslCONST_LOG2; |
| 784 |
seq_score = (fwdsc - (nullsc + seqbias)) / eslCONST_LOG2; |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
sum_score = 0.0f; |
| 793 |
seqbias = 0.0f; |
| 794 |
|
| 795 |
Ld = 0; |
| 796 |
if (pli->do_null2) |
| 797 |
{ |
| 798 |
for (d = 0; d < pli->ddef->ndom; d++) |
| 799 |
{ |
| 800 |
if (pli->ddef->dcl[d].envsc - pli->ddef->dcl[d].domcorrection > 0.0) |
| 801 |
{ |
| 802 |
sum_score += pli->ddef->dcl[d].envsc; |
| 803 |
Ld += pli->ddef->dcl[d].jenv - pli->ddef->dcl[d].ienv + 1; |
| 804 |
seqbias += pli->ddef->dcl[d].domcorrection; |
| 805 |
} |
| 806 |
} |
| 807 |
seqbias = p7_FLogsum(0.0, log(bg->omega) + seqbias); |
| 808 |
} |
| 809 |
else |
| 810 |
{ |
| 811 |
for (d = 0; d < pli->ddef->ndom; d++) |
| 812 |
{ |
| 813 |
if (pli->ddef->dcl[d].envsc > 0.0) |
| 814 |
{ |
| 815 |
sum_score += pli->ddef->dcl[d].envsc; |
| 816 |
Ld += pli->ddef->dcl[d].jenv - pli->ddef->dcl[d].ienv + 1; |
| 817 |
} |
| 818 |
} |
| 819 |
seqbias = 0.0; |
| 820 |
} |
| 821 |
sum_score += (sq->n-Ld) * log((float) sq->n / (float) (sq->n+3)); |
| 822 |
pre2_score = (sum_score - nullsc) / eslCONST_LOG2; |
| 823 |
sum_score = (sum_score - (nullsc + seqbias)) / eslCONST_LOG2; |
| 824 |
|
| 825 |
|
| 826 |
if (Ld > 0 && sum_score > seq_score) |
| 827 |
{ |
| 828 |
seq_score = sum_score; |
| 829 |
pre_score = pre2_score; |
| 830 |
} |
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
lnP = esl_exp_logsurv (seq_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 838 |
if (p7_pli_TargetReportable(pli, seq_score, lnP)) |
| 839 |
{ |
| 840 |
p7_tophits_CreateNextHit(hitlist, &hit); |
| 841 |
if (pli->mode == p7_SEARCH_SEQS) { |
| 842 |
if ( (status = esl_strdup(sq->name, -1, &(hit->name))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 843 |
if (sq->acc[0] != '\0' && (status = esl_strdup(sq->acc, -1, &(hit->acc))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 844 |
if (sq->desc[0] != '\0' && (status = esl_strdup(sq->desc, -1, &(hit->desc))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 845 |
} else { |
| 846 |
if ((status = esl_strdup(om->name, -1, &(hit->name))) != eslOK) esl_fatal("allocation failure"); |
| 847 |
if ((status = esl_strdup(om->acc, -1, &(hit->acc))) != eslOK) esl_fatal("allocation failure"); |
| 848 |
if ((status = esl_strdup(om->desc, -1, &(hit->desc))) != eslOK) esl_fatal("allocation failure"); |
| 849 |
} |
| 850 |
hit->ndom = pli->ddef->ndom; |
| 851 |
hit->nexpected = pli->ddef->nexpected; |
| 852 |
hit->nregions = pli->ddef->nregions; |
| 853 |
hit->nclustered = pli->ddef->nclustered; |
| 854 |
hit->noverlaps = pli->ddef->noverlaps; |
| 855 |
hit->nenvelopes = pli->ddef->nenvelopes; |
| 856 |
|
| 857 |
hit->pre_score = pre_score; |
| 858 |
hit->pre_lnP = esl_exp_logsurv (hit->pre_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 859 |
|
| 860 |
hit->score = seq_score; |
| 861 |
hit->lnP = lnP; |
| 862 |
hit->sortkey = pli->inc_by_E ? -lnP : seq_score; |
| 863 |
|
| 864 |
hit->sum_score = sum_score; |
| 865 |
hit->sum_lnP = esl_exp_logsurv (hit->sum_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
hit->dcl = pli->ddef->dcl; |
| 876 |
pli->ddef->dcl = NULL; |
| 877 |
hit->best_domain = 0; |
| 878 |
for (d = 0; d < hit->ndom; d++) |
| 879 |
{ |
| 880 |
Ld = hit->dcl[d].jenv - hit->dcl[d].ienv + 1; |
| 881 |
hit->dcl[d].bitscore = hit->dcl[d].envsc + (sq->n-Ld) * log((float) sq->n / (float) (sq->n+3)); |
| 882 |
hit->dcl[d].dombias = (pli->do_null2 ? p7_FLogsum(0.0, log(bg->omega) + hit->dcl[d].domcorrection) : 0.0); |
| 883 |
hit->dcl[d].bitscore = (hit->dcl[d].bitscore - (nullsc + hit->dcl[d].dombias)) / eslCONST_LOG2; |
| 884 |
hit->dcl[d].lnP = esl_exp_logsurv (hit->dcl[d].bitscore, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 885 |
|
| 886 |
if (hit->dcl[d].bitscore > hit->dcl[hit->best_domain].bitscore) hit->best_domain = d; |
| 887 |
} |
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
if (pli->use_bit_cutoffs) |
| 914 |
{ |
| 915 |
if (p7_pli_TargetReportable(pli, hit->score, hit->lnP)) |
| 916 |
{ |
| 917 |
hit->flags |= p7_IS_REPORTED; |
| 918 |
if (p7_pli_TargetIncludable(pli, hit->score, hit->lnP)) |
| 919 |
hit->flags |= p7_IS_INCLUDED; |
| 920 |
} |
| 921 |
|
| 922 |
for (d = 0; d < hit->ndom; d++) |
| 923 |
{ |
| 924 |
if (p7_pli_DomainReportable(pli, hit->dcl[d].bitscore, hit->dcl[d].lnP)) |
| 925 |
{ |
| 926 |
hit->dcl[d].is_reported = TRUE; |
| 927 |
if (p7_pli_DomainIncludable(pli, hit->dcl[d].bitscore, hit->dcl[d].lnP)) |
| 928 |
hit->dcl[d].is_included = TRUE; |
| 929 |
} |
| 930 |
} |
| 931 |
} |
| 932 |
|
| 933 |
} |
| 934 |
|
| 935 |
return eslOK; |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
static int |
| 958 |
p7_pli_computeAliScores(P7_DOMAIN *dom, ESL_DSQ *seq, const P7_SCOREDATA *data, int K) |
| 959 |
{ |
| 960 |
int status; |
| 961 |
int i, j, k; |
| 962 |
float sc; |
| 963 |
|
| 964 |
|
| 965 |
ESL_ALLOC( dom->scores_per_pos, sizeof(float) * dom->ad->N ); |
| 966 |
for (i=0; i<dom->ad->N; i++) dom->scores_per_pos[i] = 0.0; |
| 967 |
|
| 968 |
i = dom->iali - 1; |
| 969 |
j = dom->ad->hmmfrom - 1; |
| 970 |
k = 0; |
| 971 |
while ( k<dom->ad->N) { |
| 972 |
if (dom->ad->model[k] != '.' && dom->ad->aseq[k] != '-') { |
| 973 |
i++; j++; |
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
dom->scores_per_pos[k] = data->fwd_scores[K * j + seq[i]] |
| 979 |
+ (j==1 ? 0 : log(data->fwd_transitions[p7O_MM][j]) ); |
| 980 |
k++; |
| 981 |
} else if (dom->ad->model[k] == '.' ) { |
| 982 |
|
| 983 |
dom->scores_per_pos[k] = -eslINFINITY; |
| 984 |
|
| 985 |
sc = log(data->fwd_transitions[p7O_MI][j]); |
| 986 |
i++; k++; |
| 987 |
while (k<dom->ad->N && dom->ad->model[k] == '.') { |
| 988 |
dom->scores_per_pos[k] = -eslINFINITY; |
| 989 |
sc += log(data->fwd_transitions[p7O_II][j]); |
| 990 |
i++; k++; |
| 991 |
} |
| 992 |
sc += log(data->fwd_transitions[p7O_IM][j+1]) - log(data->fwd_transitions[p7O_MM][j+1]); |
| 993 |
dom->scores_per_pos[k-1] = sc; |
| 994 |
|
| 995 |
} else if (dom->ad->aseq[k] == '-' ) { |
| 996 |
dom->scores_per_pos[k] = -eslINFINITY; |
| 997 |
sc = log(data->fwd_transitions[p7O_MD][j]); |
| 998 |
j++; k++; |
| 999 |
while (k<dom->ad->N && dom->ad->aseq[k] == '-') { |
| 1000 |
dom->scores_per_pos[k] = -eslINFINITY; |
| 1001 |
sc += log(data->fwd_transitions[p7O_DD][j]); |
| 1002 |
j++; k++; |
| 1003 |
} |
| 1004 |
sc += log(data->fwd_transitions[p7O_DM][j+1]) - log(data->fwd_transitions[p7O_MM][j+1]); |
| 1005 |
dom->scores_per_pos[k-1] = sc; |
| 1006 |
} |
| 1007 |
} |
| 1008 |
|
| 1009 |
return eslOK; |
| 1010 |
|
| 1011 |
ERROR: |
| 1012 |
return eslEMEM; |
| 1013 |
|
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
static int |
| 1065 |
p7_pli_postViterbi_LongTarget(P7_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, P7_TOPHITS *hitlist, const P7_SCOREDATA *data, |
| 1066 |
int64_t seqidx, int window_start, int window_len, ESL_DSQ *subseq, |
| 1067 |
int64_t seq_start, char *seq_name, char *seq_source, char* seq_acc, char* seq_desc, int seq_len, |
| 1068 |
int complementarity, int *overlap, P7_PIPELINE_LONGTARGET_OBJS *pli_tmp) |
| 1069 |
{ |
| 1070 |
P7_DOMAIN *dom = NULL; |
| 1071 |
P7_HIT *hit = NULL; |
| 1072 |
float fwdsc; |
| 1073 |
float nullsc; |
| 1074 |
float filtersc; |
| 1075 |
float bias_filtersc; |
| 1076 |
float seq_score; |
| 1077 |
double P; |
| 1078 |
int d; |
| 1079 |
int status; |
| 1080 |
|
| 1081 |
ESL_DSQ *dsq_holder; |
| 1082 |
|
| 1083 |
int env_len; |
| 1084 |
int ali_len; |
| 1085 |
float bitscore; |
| 1086 |
float dom_bias; |
| 1087 |
float dom_score; |
| 1088 |
double dom_lnP; |
| 1089 |
|
| 1090 |
int F3_L = ESL_MIN( window_len, pli->B3); |
| 1091 |
|
| 1092 |
p7_bg_SetLength(bg, window_len); |
| 1093 |
p7_bg_NullOne (bg, subseq, window_len, &nullsc); |
| 1094 |
if (pli->do_biasfilter) |
| 1095 |
{ |
| 1096 |
p7_bg_FilterScore(bg, subseq, window_len, &bias_filtersc); |
| 1097 |
bias_filtersc -= nullsc; |
| 1098 |
} else { |
| 1099 |
bias_filtersc = 0; |
| 1100 |
} |
| 1101 |
|
| 1102 |
p7_oprofile_ReconfigRestLength(om, window_len); |
| 1103 |
|
| 1104 |
|
| 1105 |
p7_ForwardParser(subseq, window_len, om, pli->oxf, &fwdsc); |
| 1106 |
filtersc = nullsc + (bias_filtersc * ( F3_L>window_len ? 1.0 : (float)F3_L/window_len) ); |
| 1107 |
seq_score = (fwdsc - filtersc) / eslCONST_LOG2; |
| 1108 |
P = esl_exp_surv(seq_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 1109 |
if (P > pli->F3 ) return eslOK; |
| 1110 |
|
| 1111 |
pli->pos_past_fwd += window_len - *overlap; |
| 1112 |
|
| 1113 |
*overlap = -1; |
| 1114 |
|
| 1115 |
|
| 1116 |
if ((status = esl_sq_SetName (pli_tmp->tmpseq, seq_name)) != eslOK) goto ERROR; |
| 1117 |
if ((status = esl_sq_SetSource (pli_tmp->tmpseq, seq_source)) != eslOK) goto ERROR; |
| 1118 |
if ((status = esl_sq_SetAccession(pli_tmp->tmpseq, seq_acc)) != eslOK) goto ERROR; |
| 1119 |
if ((status = esl_sq_SetDesc (pli_tmp->tmpseq, seq_desc)) != eslOK) goto ERROR; |
| 1120 |
pli_tmp->tmpseq->L = seq_len; |
| 1121 |
pli_tmp->tmpseq->n = window_len; |
| 1122 |
dsq_holder = pli_tmp->tmpseq->dsq; |
| 1123 |
pli_tmp->tmpseq->dsq = subseq; |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
p7_omx_GrowTo(pli->oxb, om->M, 0, window_len); |
| 1128 |
p7_BackwardParser(subseq, window_len, om, pli->oxf, pli->oxb, NULL); |
| 1129 |
|
| 1130 |
|
| 1131 |
status = p7_domaindef_ByPosteriorHeuristics(pli_tmp->tmpseq, NULL, om, pli->oxf, pli->oxb, pli->fwd, pli->bck, pli->ddef, bg, TRUE, |
| 1132 |
pli_tmp->bg, (pli->do_null2?pli_tmp->scores:NULL), pli_tmp->fwd_emissions_arr); |
| 1133 |
|
| 1134 |
pli_tmp->tmpseq->dsq = dsq_holder; |
| 1135 |
if (status != eslOK) ESL_FAIL(status, pli->errbuf, "domain definition workflow failure"); |
| 1136 |
if (pli->ddef->nregions == 0) return eslOK; |
| 1137 |
if (pli->ddef->nenvelopes == 0) return eslOK; |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
for (d = 0; d < pli->ddef->ndom; d++) |
| 1153 |
{ |
| 1154 |
|
| 1155 |
dom = pli->ddef->dcl + d; |
| 1156 |
|
| 1157 |
|
| 1158 |
env_len = dom->jenv - dom->ienv + 1; |
| 1159 |
ali_len = dom->jali - dom->iali + 1; |
| 1160 |
bitscore = dom->envsc ; |
| 1161 |
|
| 1162 |
|
| 1163 |
if (ali_len < 8) { |
| 1164 |
p7_alidisplay_Destroy(dom->ad); |
| 1165 |
continue; |
| 1166 |
} |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
bitscore -= 2 * log(2. / (env_len+2)) ; |
| 1176 |
bitscore += 2 * log(2. / (om->max_length+2)) ; |
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
bitscore -= (env_len-ali_len) * log((float)env_len / (env_len+2)); |
| 1182 |
bitscore += (ESL_MAX(om->max_length, env_len) - ali_len) * log((float)om->max_length / (float) (om->max_length+2)); |
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
dom_bias = dom->domcorrection; |
| 1189 |
p7_bg_SetLength(bg, ESL_MAX(om->max_length, env_len)); |
| 1190 |
p7_bg_NullOne (bg, subseq, ESL_MAX(om->max_length, env_len), &nullsc); |
| 1191 |
dom_score = (bitscore - (nullsc)) / eslCONST_LOG2; |
| 1192 |
dom_lnP = esl_exp_logsurv(dom_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 1193 |
|
| 1194 |
if (pli->do_alignment_score_calc) |
| 1195 |
p7_pli_computeAliScores(dom, subseq, data, om->abc->Kp); |
| 1196 |
|
| 1197 |
p7_tophits_CreateNextHit(hitlist, &hit); |
| 1198 |
|
| 1199 |
hit->ndom = 1; |
| 1200 |
hit->best_domain = 0; |
| 1201 |
|
| 1202 |
hit->window_length = om->max_length; |
| 1203 |
hit->seqidx = seqidx; |
| 1204 |
hit->subseq_start = seq_start; |
| 1205 |
|
| 1206 |
ESL_ALLOC(hit->dcl, sizeof(P7_DOMAIN) ); |
| 1207 |
hit->dcl[0] = pli->ddef->dcl[d]; |
| 1208 |
|
| 1209 |
hit->dcl[0].ad->L = seq_len; |
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
if (complementarity == p7_NOCOMPLEMENT) { |
| 1214 |
hit->dcl[0].ienv += seq_start + window_start - 2; |
| 1215 |
hit->dcl[0].jenv += seq_start + window_start - 2; |
| 1216 |
hit->dcl[0].iali += seq_start + window_start - 2; |
| 1217 |
hit->dcl[0].jali += seq_start + window_start - 2; |
| 1218 |
hit->dcl[0].ad->sqfrom += seq_start + window_start - 2; |
| 1219 |
hit->dcl[0].ad->sqto += seq_start + window_start - 2; |
| 1220 |
} else { |
| 1221 |
hit->dcl[0].ienv = seq_start - (window_start + hit->dcl[0].ienv) + 2; |
| 1222 |
hit->dcl[0].jenv = seq_start - (window_start + hit->dcl[0].jenv) + 2; |
| 1223 |
hit->dcl[0].iali = seq_start - (window_start + hit->dcl[0].iali) + 2; |
| 1224 |
hit->dcl[0].jali = seq_start - (window_start + hit->dcl[0].jali) + 2; |
| 1225 |
hit->dcl[0].ad->sqfrom = seq_start - (window_start + hit->dcl[0].ad->sqfrom) + 2; |
| 1226 |
hit->dcl[0].ad->sqto = seq_start - (window_start + hit->dcl[0].ad->sqto) + 2; |
| 1227 |
} |
| 1228 |
hit->pre_score = bitscore / eslCONST_LOG2; |
| 1229 |
hit->pre_lnP = esl_exp_logsurv (hit->pre_score, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]); |
| 1230 |
|
| 1231 |
hit->dcl[0].dombias = dom_bias; |
| 1232 |
hit->sum_score = hit->score = hit->dcl[0].bitscore = dom_score; |
| 1233 |
hit->sum_lnP = hit->lnP = hit->dcl[0].lnP = dom_lnP; |
| 1234 |
|
| 1235 |
|
| 1236 |
if (pli->mode == p7_SEARCH_SEQS) |
| 1237 |
{ |
| 1238 |
if ( (status = esl_strdup(seq_name, -1, &(hit->name))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 1239 |
if (seq_acc[0] != '\0' && (status = esl_strdup(seq_acc, -1, &(hit->acc))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 1240 |
if (seq_desc[0] != '\0' && (status = esl_strdup(seq_desc, -1, &(hit->desc))) != eslOK) ESL_EXCEPTION(eslEMEM, "allocation failure"); |
| 1241 |
} else { |
| 1242 |
if ((status = esl_strdup(om->name, -1, &(hit->name))) != eslOK) esl_fatal("allocation failure"); |
| 1243 |
if ((status = esl_strdup(om->acc, -1, &(hit->acc))) != eslOK) esl_fatal("allocation failure"); |
| 1244 |
if ((status = esl_strdup(om->desc, -1, &(hit->desc))) != eslOK) esl_fatal("allocation failure"); |
| 1245 |
} |
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
if (pli->use_bit_cutoffs) |
| 1253 |
{ |
| 1254 |
if (p7_pli_TargetReportable(pli, hit->score, hit->lnP)) |
| 1255 |
{ |
| 1256 |
hit->flags |= p7_IS_REPORTED; |
| 1257 |
if (p7_pli_TargetIncludable(pli, hit->score, hit->lnP)) |
| 1258 |
hit->flags |= p7_IS_INCLUDED; |
| 1259 |
} |
| 1260 |
|
| 1261 |
if (p7_pli_DomainReportable(pli, hit->dcl[0].bitscore, hit->dcl[0].lnP)) |
| 1262 |
{ |
| 1263 |
hit->dcl[0].is_reported = TRUE; |
| 1264 |
if (p7_pli_DomainIncludable(pli, hit->dcl[0].bitscore, hit->dcl[0].lnP)) |
| 1265 |
hit->dcl[0].is_included = TRUE; |
| 1266 |
} |
| 1267 |
|
| 1268 |
} |
| 1269 |
|
| 1270 |
} |
| 1271 |
|
| 1272 |
return eslOK; |
| 1273 |
|
| 1274 |
ERROR: |
| 1275 |
ESL_EXCEPTION(eslEMEM, "Error in LongTarget pipeline\n"); |
| 1276 |
|
| 1277 |
} |
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
static int |
| 1331 |
p7_pli_postSSV_LongTarget(P7_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, P7_TOPHITS *hitlist, const P7_SCOREDATA *data, |
| 1332 |
int64_t seqidx, uint64_t window_start, int window_len, ESL_DSQ *subseq, |
| 1333 |
uint64_t seq_start, char *seq_name, char *seq_source, char* seq_acc, char* seq_desc, int seq_len, |
| 1334 |
float nullsc, float usc, int complementarity, P7_HMM_WINDOWLIST *vit_windowlist, |
| 1335 |
P7_PIPELINE_LONGTARGET_OBJS *pli_tmp |
| 1336 |
) |
| 1337 |
{ |
| 1338 |
float filtersc; |
| 1339 |
float bias_filtersc; |
| 1340 |
float seq_score; |
| 1341 |
double P; |
| 1342 |
int i; |
| 1343 |
int overlap; |
| 1344 |
uint64_t new_n; |
| 1345 |
uint32_t new_len; |
| 1346 |
|
| 1347 |
int loc_window_len; |
| 1348 |
|
| 1349 |
int max_window_len = 80000; |
| 1350 |
int overlap_len = ESL_MIN(40000, om->max_length); |
| 1351 |
|
| 1352 |
int F1_L = ESL_MIN( window_len, pli->B1); |
| 1353 |
int F2_L = ESL_MIN( window_len, pli->B2); |
| 1354 |
|
| 1355 |
|
| 1356 |
if (pli->do_biasfilter) { |
| 1357 |
p7_bg_SetLength(bg, window_len); |
| 1358 |
p7_bg_FilterScore(bg, subseq, window_len, &bias_filtersc); |
| 1359 |
bias_filtersc -= nullsc; |
| 1360 |
filtersc = nullsc + (bias_filtersc * (float)(( F1_L>window_len ? 1.0 : (float)F1_L/window_len))); |
| 1361 |
seq_score = (usc - filtersc) / eslCONST_LOG2; |
| 1362 |
P = esl_gumbel_surv(seq_score, om->evparam[p7_MMU], om->evparam[p7_MLAMBDA]); |
| 1363 |
if (P > pli->F1) return eslOK; |
| 1364 |
} else { |
| 1365 |
bias_filtersc = 0; |
| 1366 |
} |
| 1367 |
pli->pos_past_bias += window_len; |
| 1368 |
|
| 1369 |
|
| 1370 |
loc_window_len = ESL_MIN(window_len,om->max_length); |
| 1371 |
|
| 1372 |
|
| 1373 |
p7_bg_SetLength(bg, loc_window_len); |
| 1374 |
p7_bg_NullOne (bg, subseq, loc_window_len, &nullsc); |
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
filtersc = nullsc + (bias_filtersc * ( F2_L>window_len ? 1.0 : (float)F2_L/window_len) ); |
| 1380 |
|
| 1381 |
|
| 1382 |
p7_oprofile_ReconfigRestLength(om, loc_window_len); |
| 1383 |
|
| 1384 |
|
| 1385 |
p7_omx_GrowTo(pli->oxf, om->M, 0, window_len); |
| 1386 |
|
| 1387 |
|
| 1388 |
p7_ViterbiFilter_longtarget(subseq, window_len, om, pli->oxf, filtersc, pli->F2, vit_windowlist); |
| 1389 |
|
| 1390 |
p7_pli_ExtendAndMergeWindows (om, data, vit_windowlist, 0.5); |
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
for (i=0; i<vit_windowlist->count; i++) { |
| 1395 |
|
| 1396 |
if (vit_windowlist->windows[i].length > max_window_len) { |
| 1397 |
|
| 1398 |
|
| 1399 |
new_n = vit_windowlist->windows[i].n ; |
| 1400 |
new_len = vit_windowlist->windows[i].length ; |
| 1401 |
vit_windowlist->windows[i].length = max_window_len; |
| 1402 |
|
| 1403 |
do { |
| 1404 |
int shift = max_window_len - overlap_len; |
| 1405 |
new_n += shift; |
| 1406 |
new_len -= shift; |
| 1407 |
p7_hmmwindow_new(vit_windowlist, 0, new_n, 0, 0, ESL_MIN(max_window_len,new_len), 0.0, p7_NOCOMPLEMENT, new_len ); |
| 1408 |
} while (new_len > max_window_len); |
| 1409 |
} |
| 1410 |
} |
| 1411 |
|
| 1412 |
overlap = 0; |
| 1413 |
for (i=0; i<vit_windowlist->count; i++) { |
| 1414 |
pli->pos_past_vit += vit_windowlist->windows[i].length; |
| 1415 |
|
| 1416 |
if (i>0) |
| 1417 |
pli->pos_past_vit -= ESL_MAX(0, vit_windowlist->windows[i-1].n + vit_windowlist->windows[i-1].length - vit_windowlist->windows[i].n ); |
| 1418 |
|
| 1419 |
p7_pli_postViterbi_LongTarget(pli, om, bg, hitlist, data, seqidx, |
| 1420 |
window_start+vit_windowlist->windows[i].n-1, vit_windowlist->windows[i].length, |
| 1421 |
subseq + vit_windowlist->windows[i].n - 1, |
| 1422 |
seq_start, seq_name, seq_source, seq_acc, seq_desc, seq_len, complementarity, &overlap, |
| 1423 |
pli_tmp |
| 1424 |
); |
| 1425 |
if (overlap == -1 && i<vit_windowlist->count-1) { |
| 1426 |
overlap = ESL_MAX(0, vit_windowlist->windows[i].n + vit_windowlist->windows[i].length - vit_windowlist->windows[i+1].n ); |
| 1427 |
} else { |
| 1428 |
|
| 1429 |
overlap = 0; |
| 1430 |
} |
| 1431 |
|
| 1432 |
pli->ddef->ndom = 0; |
| 1433 |
|
| 1434 |
} |
| 1435 |
|
| 1436 |
return eslOK; |
| 1437 |
|
| 1438 |
} |
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
int |
| 1496 |
p7_Pipeline_LongTarget(P7_PIPELINE *pli, P7_OPROFILE *om, P7_SCOREDATA *data, |
| 1497 |
P7_BG *bg, P7_TOPHITS *hitlist, |
| 1498 |
int64_t seqidx, const ESL_SQ *sq, int complementarity, |
| 1499 |
const FM_DATA *fmf, const FM_DATA *fmb, FM_CFG *fm_cfg |
| 1500 |
) |
| 1501 |
{ |
| 1502 |
int i; |
| 1503 |
int status; |
| 1504 |
float nullsc; |
| 1505 |
float usc; |
| 1506 |
float P; |
| 1507 |
float bias_filtersc; |
| 1508 |
|
| 1509 |
ESL_DSQ *subseq; |
| 1510 |
uint64_t seq_start; |
| 1511 |
|
| 1512 |
|
| 1513 |
P7_HMM_WINDOWLIST msv_windowlist; |
| 1514 |
P7_HMM_WINDOWLIST vit_windowlist; |
| 1515 |
P7_HMM_WINDOW *window; |
| 1516 |
FM_SEQDATA seq_data; |
| 1517 |
|
| 1518 |
P7_PIPELINE_LONGTARGET_OBJS *pli_tmp; |
| 1519 |
|
| 1520 |
if ((sq && (sq->n == 0)) || (fmf && (fmf->N == 0))) return eslOK; |
| 1521 |
|
| 1522 |
|
| 1523 |
ESL_ALLOC(pli_tmp, sizeof(P7_PIPELINE_LONGTARGET_OBJS)); |
| 1524 |
pli_tmp->tmpseq = NULL; |
| 1525 |
pli_tmp->bg = p7_bg_Clone(bg); |
| 1526 |
pli_tmp->om = p7_oprofile_Create(om->M, om->abc); |
| 1527 |
ESL_ALLOC(pli_tmp->scores, sizeof(float) * om->abc->Kp * 4); |
| 1528 |
ESL_ALLOC(pli_tmp->fwd_emissions_arr, sizeof(float) * om->abc->Kp * (om->M+1)); |
| 1529 |
|
| 1530 |
msv_windowlist.windows = NULL; |
| 1531 |
vit_windowlist.windows = NULL; |
| 1532 |
p7_hmmwindow_init(&msv_windowlist); |
| 1533 |
|
| 1534 |
p7_omx_GrowTo(pli->oxf, om->M, 0, om->max_length); |
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
p7_oprofile_ReconfigMSVLength(om, om->max_length); |
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
if (fmf) |
| 1547 |
p7_SSVFM_longlarget(om, 2.0, bg, pli->F1, fmf, fmb, fm_cfg, data, pli->strands, pli->r, &msv_windowlist ); |
| 1548 |
else |
| 1549 |
p7_SSVFilter_longtarget(sq->dsq, sq->n, om, pli->oxf, data, bg, pli->F1, &msv_windowlist); |
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
if ( msv_windowlist.count > 0 ) { |
| 1555 |
|
| 1556 |
|
| 1557 |
if (!fmf && pli->hfp) |
| 1558 |
{ |
| 1559 |
if (om->base_w == 0 && om->scale_w == 0) { |
| 1560 |
p7_oprofile_ReadRest(pli->hfp, om); |
| 1561 |
if ((status = p7_pli_NewModelThresholds(pli, om)) != eslOK) goto ERROR; |
| 1562 |
} |
| 1563 |
} |
| 1564 |
|
| 1565 |
p7_oprofile_GetFwdEmissionArray(om, bg, pli_tmp->fwd_emissions_arr); |
| 1566 |
|
| 1567 |
if (data->prefix_lengths == NULL) |
| 1568 |
p7_hmm_ScoreDataComputeRest(om, data); |
| 1569 |
|
| 1570 |
p7_pli_ExtendAndMergeWindows (om, data, &msv_windowlist, 0); |
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
if (fmf) { |
| 1577 |
for (i=0; i<msv_windowlist.count; i++) { |
| 1578 |
int again = TRUE; |
| 1579 |
window = msv_windowlist.windows + i; |
| 1580 |
|
| 1581 |
while (again) { |
| 1582 |
uint32_t seg_id; |
| 1583 |
uint64_t seg_pos; |
| 1584 |
again = FALSE; |
| 1585 |
|
| 1586 |
status = fm_getOriginalPosition (fmf, fm_cfg->meta, 0, window->length, window->complementarity, window->fm_n, &seg_id, &seg_pos); |
| 1587 |
|
| 1588 |
if (status == eslERANGE) { |
| 1589 |
int overext; |
| 1590 |
int use_length; |
| 1591 |
int is_compl = (window->complementarity == p7_COMPLEMENT); |
| 1592 |
|
| 1593 |
overext = (seg_pos + window->length) - (fm_cfg->meta->seq_data[ seg_id ].target_start + fm_cfg->meta->seq_data[ seg_id ].length - 1) ; |
| 1594 |
|
| 1595 |
use_length = window->length - overext + 1; |
| 1596 |
|
| 1597 |
if (use_length >= 8 && window->length >= 8) { |
| 1598 |
p7_hmmwindow_new(&msv_windowlist, seg_id + (is_compl?-1:1), window->n, window->fm_n, window->k+use_length-1, use_length, window->score, window->complementarity, fm_cfg->meta->seq_data[seg_id].length); |
| 1599 |
window = msv_windowlist.windows + i; |
| 1600 |
window->k += use_length; |
| 1601 |
window->length = overext; |
| 1602 |
again = TRUE; |
| 1603 |
} else if (window->length >= 8) { |
| 1604 |
window->k += use_length; |
| 1605 |
window->length = overext; |
| 1606 |
} else { |
| 1607 |
window->length = use_length; |
| 1608 |
} |
| 1609 |
|
| 1610 |
} |
| 1611 |
} |
| 1612 |
} |
| 1613 |
} |
| 1614 |
|
| 1615 |
|
| 1616 |
p7_hmmwindow_init(&vit_windowlist); |
| 1617 |
pli_tmp->tmpseq = esl_sq_CreateDigital(om->abc); |
| 1618 |
if (!fmf ) |
| 1619 |
free (pli_tmp->tmpseq->dsq); |
| 1620 |
|
| 1621 |
|
| 1622 |
for (i=0; i<msv_windowlist.count; i++){ |
| 1623 |
window = msv_windowlist.windows + i ; |
| 1624 |
|
| 1625 |
if (fmf) { |
| 1626 |
fm_convertRange2DSQ( fmf, fm_cfg->meta, window->fm_n, window->length, window->complementarity, pli_tmp->tmpseq, TRUE ); |
| 1627 |
subseq = pli_tmp->tmpseq->dsq; |
| 1628 |
} else { |
| 1629 |
subseq = sq->dsq + window->n - 1; |
| 1630 |
} |
| 1631 |
|
| 1632 |
p7_bg_SetLength(bg, window->length); |
| 1633 |
p7_bg_NullOne (bg, subseq, window->length, &nullsc); |
| 1634 |
|
| 1635 |
p7_bg_FilterScore(bg, subseq, window->length, &bias_filtersc); |
| 1636 |
|
| 1637 |
|
| 1638 |
p7_oprofile_ReconfigMSVLength(om, window->length); |
| 1639 |
p7_MSVFilter(subseq, window->length, om, pli->oxf, &usc); |
| 1640 |
P = esl_gumbel_surv( (usc-nullsc)/eslCONST_LOG2, om->evparam[p7_MMU], om->evparam[p7_MLAMBDA]); |
| 1641 |
|
| 1642 |
if (P > pli->F1 ) continue; |
| 1643 |
pli->pos_past_msv += window->length; |
| 1644 |
|
| 1645 |
if (fmf) { |
| 1646 |
seq_data = fm_cfg->meta->seq_data[window->id]; |
| 1647 |
seq_start = seq_data.target_start; |
| 1648 |
if (window->complementarity == p7_COMPLEMENT) |
| 1649 |
seq_start += seq_data.length - 2; |
| 1650 |
} |
| 1651 |
|
| 1652 |
status = p7_pli_postSSV_LongTarget(pli, om, bg, hitlist, data, |
| 1653 |
(fmf != NULL ? seq_data.target_id : seqidx), |
| 1654 |
window->n, window->length, subseq, |
| 1655 |
(fmf != NULL ? seq_start : sq->start), |
| 1656 |
(fmf != NULL ? seq_data.name : sq->name), |
| 1657 |
(fmf != NULL ? seq_data.source : sq->source), |
| 1658 |
(fmf != NULL ? seq_data.acc : sq->acc), |
| 1659 |
(fmf != NULL ? seq_data.desc : sq->desc), |
| 1660 |
(fmf != NULL ? seq_data.length : -1), |
| 1661 |
nullsc, |
| 1662 |
usc, |
| 1663 |
(fmf != NULL ? window->complementarity : complementarity), |
| 1664 |
&vit_windowlist, |
| 1665 |
pli_tmp |
| 1666 |
); |
| 1667 |
if (status != eslOK) goto ERROR; |
| 1668 |
|
| 1669 |
} |
| 1670 |
|
| 1671 |
if (fmf) free (pli_tmp->tmpseq->dsq); |
| 1672 |
|
| 1673 |
pli_tmp->tmpseq->dsq = NULL; |
| 1674 |
|
| 1675 |
esl_sq_Destroy(pli_tmp->tmpseq); |
| 1676 |
free (vit_windowlist.windows); |
| 1677 |
} |
| 1678 |
|
| 1679 |
if (msv_windowlist.windows != NULL) free (msv_windowlist.windows); |
| 1680 |
|
| 1681 |
if (pli_tmp != NULL) { |
| 1682 |
if (pli_tmp->bg != NULL) p7_bg_Destroy(pli_tmp->bg); |
| 1683 |
if (pli_tmp->om != NULL) p7_oprofile_Destroy(pli_tmp->om); |
| 1684 |
if (pli_tmp->scores != NULL) free (pli_tmp->scores); |
| 1685 |
if (pli_tmp->fwd_emissions_arr != NULL) free (pli_tmp->fwd_emissions_arr); |
| 1686 |
free(pli_tmp); |
| 1687 |
} |
| 1688 |
|
| 1689 |
return eslOK; |
| 1690 |
|
| 1691 |
ERROR: |
| 1692 |
if (msv_windowlist.windows != NULL) free (msv_windowlist.windows); |
| 1693 |
if (vit_windowlist.windows != NULL) free (vit_windowlist.windows); |
| 1694 |
|
| 1695 |
if (pli_tmp != NULL) { |
| 1696 |
if (pli_tmp->tmpseq != NULL) esl_sq_Destroy(pli_tmp->tmpseq); |
| 1697 |
if (pli_tmp->bg != NULL) p7_bg_Destroy(pli_tmp->bg); |
| 1698 |
if (pli_tmp->om != NULL) p7_oprofile_Destroy(pli_tmp->om); |
| 1699 |
if (pli_tmp->scores != NULL) free (pli_tmp->scores); |
| 1700 |
if (pli_tmp->fwd_emissions_arr != NULL) free (pli_tmp->fwd_emissions_arr); |
| 1701 |
free(pli_tmp); |
| 1702 |
} |
| 1703 |
|
| 1704 |
return status; |
| 1705 |
|
| 1706 |
} |
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
int |
| 1722 |
p7_pli_Statistics(FILE *ofp, P7_PIPELINE *pli, ESL_STOPWATCH *w) |
| 1723 |
{ |
| 1724 |
double ntargets; |
| 1725 |
|
| 1726 |
fprintf(ofp, "Internal pipeline statistics summary:\n"); |
| 1727 |
fprintf(ofp, "-------------------------------------\n"); |
| 1728 |
if (pli->mode == p7_SEARCH_SEQS) { |
| 1729 |
fprintf(ofp, "Query model(s): %15" PRId64 " (%" PRId64 " nodes)\n", pli->nmodels, pli->nnodes); |
| 1730 |
fprintf(ofp, "Target sequences: %15" PRId64 " (%" PRId64 " residues searched)\n", pli->nseqs, pli->nres); |
| 1731 |
ntargets = pli->nseqs; |
| 1732 |
} else { |
| 1733 |
fprintf(ofp, "Query sequence(s): %15" PRId64 " (%" PRId64 " residues searched)\n", pli->nseqs, pli->nres); |
| 1734 |
fprintf(ofp, "Target model(s): %15" PRId64 " (%" PRId64 " nodes)\n", pli->nmodels, pli->nnodes); |
| 1735 |
ntargets = pli->nmodels; |
| 1736 |
} |
| 1737 |
|
| 1738 |
if (pli->long_targets) { |
| 1739 |
fprintf(ofp, "Residues passing SSV filter: %15" PRId64 " (%.3g); expected (%.3g)\n", |
| 1740 |
pli->pos_past_msv, |
| 1741 |
(double)pli->pos_past_msv / (pli->nres*pli->nmodels) , |
| 1742 |
pli->F1); |
| 1743 |
|
| 1744 |
fprintf(ofp, "Residues passing bias filter:%15" PRId64 " (%.3g); expected (%.3g)\n", |
| 1745 |
pli->pos_past_bias, |
| 1746 |
(double)pli->pos_past_bias / (pli->nres*pli->nmodels) , |
| 1747 |
pli->F1); |
| 1748 |
|
| 1749 |
fprintf(ofp, "Residues passing Vit filter: %15" PRId64 " (%.3g); expected (%.3g)\n", |
| 1750 |
pli->pos_past_vit, |
| 1751 |
(double)pli->pos_past_vit / (pli->nres*pli->nmodels) , |
| 1752 |
pli->F2); |
| 1753 |
|
| 1754 |
fprintf(ofp, "Residues passing Fwd filter: %15" PRId64 " (%.3g); expected (%.3g)\n", |
| 1755 |
pli->pos_past_fwd, |
| 1756 |
(double)pli->pos_past_fwd / (pli->nres*pli->nmodels) , |
| 1757 |
pli->F3); |
| 1758 |
|
| 1759 |
fprintf(ofp, "Total number of hits: %15d (%.3g)\n", |
| 1760 |
(int)pli->n_output, |
| 1761 |
(double)pli->pos_output / (pli->nres*pli->nmodels) ); |
| 1762 |
|
| 1763 |
} else { |
| 1764 |
|
| 1765 |
fprintf(ofp, "Passed MSV filter: %15" PRId64 " (%.6g); expected %.1f (%.6g)\n", |
| 1766 |
pli->n_past_msv, |
| 1767 |
(double) pli->n_past_msv / ntargets, |
| 1768 |
pli->F1 * ntargets, |
| 1769 |
pli->F1); |
| 1770 |
|
| 1771 |
fprintf(ofp, "Passed bias filter: %15" PRId64 " (%.6g); expected %.1f (%.6g)\n", |
| 1772 |
pli->n_past_bias, |
| 1773 |
(double) pli->n_past_bias / ntargets, |
| 1774 |
pli->F1 * ntargets, |
| 1775 |
pli->F1); |
| 1776 |
|
| 1777 |
fprintf(ofp, "Passed Vit filter: %15" PRId64 " (%.6g); expected %.1f (%.6g)\n", |
| 1778 |
pli->n_past_vit, |
| 1779 |
(double) pli->n_past_vit / ntargets, |
| 1780 |
pli->F2 * ntargets, |
| 1781 |
pli->F2); |
| 1782 |
|
| 1783 |
fprintf(ofp, "Passed Fwd filter: %15" PRId64 " (%.6g); expected %.1f (%.6g)\n", |
| 1784 |
pli->n_past_fwd, |
| 1785 |
(double) pli->n_past_fwd / ntargets, |
| 1786 |
pli->F3 * ntargets, |
| 1787 |
pli->F3); |
| 1788 |
|
| 1789 |
fprintf(ofp, "Initial search space (Z): %15.0f %s\n", pli->Z, pli->Z_setby == p7_ZSETBY_OPTION ? "[as set by --Z on cmdline]" : "[actual number of targets]"); |
| 1790 |
fprintf(ofp, "Domain search space (domZ): %15.0f %s\n", pli->domZ, pli->domZ_setby == p7_ZSETBY_OPTION ? "[as set by --domZ on cmdline]" : "[number of targets reported over threshold]"); |
| 1791 |
} |
| 1792 |
|
| 1793 |
if (w != NULL) { |
| 1794 |
esl_stopwatch_Display(ofp, w, "# CPU time: "); |
| 1795 |
fprintf(ofp, "# Mc/sec: %.2f\n", |
| 1796 |
(double) pli->nres * (double) pli->nnodes / (w->elapsed * 1.0e6)); |
| 1797 |
} |
| 1798 |
|
| 1799 |
return eslOK; |
| 1800 |
} |
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
#ifdef p7PIPELINE_EXAMPLE |
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
#include <p7_config.h> |
| 1814 |
|
| 1815 |
#include "easel.h" |
| 1816 |
#include "esl_getopts.h" |
| 1817 |
#include "esl_sqio.h" |
| 1818 |
|
| 1819 |
#include "hmmer.h" |
| 1820 |
|
| 1821 |
static ESL_OPTIONS options[] = { |
| 1822 |
|
| 1823 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 1824 |
{ "-E", eslARG_REAL, "10.0", NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "E-value cutoff for reporting significant sequence hits", 0 }, |
| 1825 |
{ "-T", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "bit score cutoff for reporting significant sequence hits", 0 }, |
| 1826 |
{ "-Z", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, NULL, "set # of comparisons done, for E-value calculation", 0 }, |
| 1827 |
{ "--domE", eslARG_REAL,"1000.0", NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "E-value cutoff for reporting individual domains", 0 }, |
| 1828 |
{ "--domT", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "bit score cutoff for reporting individual domains", 0 }, |
| 1829 |
{ "--domZ", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, NULL, "set # of significant seqs, for domain E-value calculation", 0 }, |
| 1830 |
{ "--cut_ga", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use GA gathering threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1831 |
{ "--cut_nc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use NC noise threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1832 |
{ "--cut_tc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use TC trusted threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1833 |
{ "--max", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--F1,--F2,--F3", "Turn all heuristic filters off (less speed, more power)", 0 }, |
| 1834 |
{ "--F1", eslARG_REAL, "0.02", NULL, NULL, NULL, NULL, "--max", "Stage 1 (MSV) threshold: promote hits w/ P <= F1", 0 }, |
| 1835 |
{ "--F2", eslARG_REAL, "1e-3", NULL, NULL, NULL, NULL, "--max", "Stage 2 (Vit) threshold: promote hits w/ P <= F2", 0 }, |
| 1836 |
{ "--F3", eslARG_REAL, "1e-5", NULL, NULL, NULL, NULL, "--max", "Stage 3 (Fwd) threshold: promote hits w/ P <= F3", 0 }, |
| 1837 |
{ "--nobias", eslARG_NONE, NULL, NULL, NULL, NULL, NULL, "--max", "turn off composition bias filter", 0 }, |
| 1838 |
{ "--nonull2", eslARG_NONE, NULL, NULL, NULL, NULL, NULL, NULL, "turn off biased composition score corrections", 0 }, |
| 1839 |
{ "--seed", eslARG_INT, "42", NULL, "n>=0", NULL, NULL, NULL, "set RNG seed to <n> (if 0: one-time arbitrary seed)", 0 }, |
| 1840 |
{ "--acc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "output target accessions instead of names if possible", 0 }, |
| 1841 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1842 |
}; |
| 1843 |
static char usage[] = "[-options] <hmmfile> <seqdb>"; |
| 1844 |
static char banner[] = "example of using acceleration pipeline in search mode (seq targets)"; |
| 1845 |
|
| 1846 |
int |
| 1847 |
main(int argc, char **argv) |
| 1848 |
{ |
| 1849 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 2, argc, argv, banner, usage); |
| 1850 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 1851 |
char *seqfile = esl_opt_GetArg(go, 2); |
| 1852 |
int format = eslSQFILE_FASTA; |
| 1853 |
P7_HMMFILE *hfp = NULL; |
| 1854 |
ESL_ALPHABET *abc = NULL; |
| 1855 |
P7_BG *bg = NULL; |
| 1856 |
P7_HMM *hmm = NULL; |
| 1857 |
P7_PROFILE *gm = NULL; |
| 1858 |
P7_OPROFILE *om = NULL; |
| 1859 |
ESL_SQFILE *sqfp = NULL; |
| 1860 |
ESL_SQ *sq = NULL; |
| 1861 |
P7_PIPELINE *pli = NULL; |
| 1862 |
P7_TOPHITS *hitlist = NULL; |
| 1863 |
int h,d,namew; |
| 1864 |
|
| 1865 |
|
| 1866 |
p7_FLogsumInit(); |
| 1867 |
|
| 1868 |
|
| 1869 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 1870 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 1871 |
p7_hmmfile_Close(hfp); |
| 1872 |
|
| 1873 |
|
| 1874 |
if (esl_sqfile_OpenDigital(abc, seqfile, format, NULL, &sqfp) != eslOK) p7_Fail("Failed to open sequence file %s\n", seqfile); |
| 1875 |
sq = esl_sq_CreateDigital(abc); |
| 1876 |
|
| 1877 |
|
| 1878 |
pli = p7_pipeline_Create(go, hmm->M, 400, FALSE, p7_SEARCH_SEQS); |
| 1879 |
hitlist = p7_tophits_Create(); |
| 1880 |
|
| 1881 |
|
| 1882 |
bg = p7_bg_Create(abc); |
| 1883 |
gm = p7_profile_Create(hmm->M, abc); |
| 1884 |
om = p7_oprofile_Create(hmm->M, abc); |
| 1885 |
p7_ProfileConfig(hmm, bg, gm, 400, p7_LOCAL); |
| 1886 |
p7_oprofile_Convert(gm, om); |
| 1887 |
p7_pli_NewModel(pli, om, bg); |
| 1888 |
|
| 1889 |
|
| 1890 |
while (esl_sqio_Read(sqfp, sq) == eslOK) |
| 1891 |
{ |
| 1892 |
p7_pli_NewSeq(pli, sq); |
| 1893 |
p7_bg_SetLength(bg, sq->n); |
| 1894 |
p7_oprofile_ReconfigLength(om, sq->n); |
| 1895 |
|
| 1896 |
p7_Pipeline(pli, om, bg, sq, NULL, hitlist); |
| 1897 |
|
| 1898 |
esl_sq_Reuse(sq); |
| 1899 |
p7_pipeline_Reuse(pli); |
| 1900 |
} |
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
|
| 1905 |
p7_tophits_SortBySortkey(hitlist); |
| 1906 |
namew = ESL_MAX(8, p7_tophits_GetMaxNameLength(hitlist)); |
| 1907 |
for (h = 0; h < hitlist->N; h++) |
| 1908 |
{ |
| 1909 |
d = hitlist->hit[h]->best_domain; |
| 1910 |
|
| 1911 |
printf("%10.2g %7.1f %6.1f %7.1f %6.1f %10.2g %6.1f %5d %-*s %s\n", |
| 1912 |
exp(hitlist->hit[h]->lnP) * (double) pli->Z, |
| 1913 |
hitlist->hit[h]->score, |
| 1914 |
hitlist->hit[h]->pre_score - hitlist->hit[h]->score, |
| 1915 |
hitlist->hit[h]->dcl[d].bitscore, |
| 1916 |
eslCONST_LOG2R * p7_FLogsum(0.0, log(bg->omega) + hitlist->hit[h]->dcl[d].domcorrection), |
| 1917 |
exp(hitlist->hit[h]->dcl[d].lnP) * (double) pli->Z, |
| 1918 |
hitlist->hit[h]->nexpected, |
| 1919 |
hitlist->hit[h]->nreported, |
| 1920 |
namew, |
| 1921 |
hitlist->hit[h]->name, |
| 1922 |
hitlist->hit[h]->desc); |
| 1923 |
} |
| 1924 |
|
| 1925 |
|
| 1926 |
p7_tophits_Destroy(hitlist); |
| 1927 |
p7_pipeline_Destroy(pli); |
| 1928 |
esl_sq_Destroy(sq); |
| 1929 |
esl_sqfile_Close(sqfp); |
| 1930 |
p7_oprofile_Destroy(om); |
| 1931 |
p7_profile_Destroy(gm); |
| 1932 |
p7_hmm_Destroy(hmm); |
| 1933 |
p7_bg_Destroy(bg); |
| 1934 |
esl_alphabet_Destroy(abc); |
| 1935 |
esl_getopts_Destroy(go); |
| 1936 |
return 0; |
| 1937 |
} |
| 1938 |
#endif |
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
#ifdef p7PIPELINE_EXAMPLE2 |
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
#include <p7_config.h> |
| 1953 |
|
| 1954 |
#include "easel.h" |
| 1955 |
#include "esl_getopts.h" |
| 1956 |
#include "esl_sqio.h" |
| 1957 |
|
| 1958 |
#include "hmmer.h" |
| 1959 |
|
| 1960 |
static ESL_OPTIONS options[] = { |
| 1961 |
|
| 1962 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 1963 |
{ "-E", eslARG_REAL, "10.0", NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "E-value cutoff for reporting significant sequence hits", 0 }, |
| 1964 |
{ "-T", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "bit score cutoff for reporting significant sequence hits", 0 }, |
| 1965 |
{ "-Z", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, NULL, "set # of comparisons done, for E-value calculation", 0 }, |
| 1966 |
{ "--domE", eslARG_REAL,"1000.0", NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "E-value cutoff for reporting individual domains", 0 }, |
| 1967 |
{ "--domT", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, "--cut_ga,--cut_nc,--cut_tc", "bit score cutoff for reporting individual domains", 0 }, |
| 1968 |
{ "--domZ", eslARG_REAL, FALSE, NULL, "x>0", NULL, NULL, NULL, "set # of significant seqs, for domain E-value calculation", 0 }, |
| 1969 |
{ "--cut_ga", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use GA gathering threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1970 |
{ "--cut_nc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use NC noise threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1971 |
{ "--cut_tc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--seqE,--seqT,--domE,--domT", "use TC trusted threshold bit score cutoffs in <hmmfile>", 0 }, |
| 1972 |
{ "--max", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, "--F1,--F2,--F3", "Turn all heuristic filters off (less speed, more power)", 0 }, |
| 1973 |
{ "--F1", eslARG_REAL, "0.02", NULL, NULL, NULL, NULL, "--max", "Stage 1 (MSV) threshold: promote hits w/ P <= F1", 0 }, |
| 1974 |
{ "--F2", eslARG_REAL, "1e-3", NULL, NULL, NULL, NULL, "--max", "Stage 2 (Vit) threshold: promote hits w/ P <= F2", 0 }, |
| 1975 |
{ "--F3", eslARG_REAL, "1e-5", NULL, NULL, NULL, NULL, "--max", "Stage 3 (Fwd) threshold: promote hits w/ P <= F3", 0 }, |
| 1976 |
{ "--nobias", eslARG_NONE, NULL, NULL, NULL, NULL, NULL, "--max", "turn off composition bias filter", 0 }, |
| 1977 |
{ "--nonull2", eslARG_NONE, NULL, NULL, NULL, NULL, NULL, NULL, "turn off biased composition score corrections", 0 }, |
| 1978 |
{ "--seed", eslARG_INT, "42", NULL, "n>=0", NULL, NULL, NULL, "set RNG seed to <n> (if 0: one-time arbitrary seed)", 0 }, |
| 1979 |
{ "--acc", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "output target accessions instead of names if possible", 0 }, |
| 1980 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1981 |
}; |
| 1982 |
static char usage[] = "[-options] <hmmfile> <seqfile>"; |
| 1983 |
static char banner[] = "example of using acceleration pipeline in scan mode (HMM targets)"; |
| 1984 |
|
| 1985 |
int |
| 1986 |
main(int argc, char **argv) |
| 1987 |
{ |
| 1988 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 2, argc, argv, banner, usage); |
| 1989 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 1990 |
char *seqfile = esl_opt_GetArg(go, 2); |
| 1991 |
int format = eslSQFILE_FASTA; |
| 1992 |
P7_HMMFILE *hfp = NULL; |
| 1993 |
ESL_ALPHABET *abc = NULL; |
| 1994 |
P7_BG *bg = NULL; |
| 1995 |
P7_OPROFILE *om = NULL; |
| 1996 |
ESL_SQFILE *sqfp = NULL; |
| 1997 |
ESL_SQ *sq = NULL; |
| 1998 |
P7_PIPELINE *pli = NULL; |
| 1999 |
P7_TOPHITS *hitlist = p7_tophits_Create(); |
| 2000 |
int h,d,namew; |
| 2001 |
|
| 2002 |
|
| 2003 |
p7_FLogsumInit(); |
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
sq = esl_sq_Create(); |
| 2009 |
if (esl_sqfile_Open(seqfile, format, NULL, &sqfp) != eslOK) p7_Fail("Failed to open sequence file %s\n", seqfile); |
| 2010 |
if (esl_sqio_Read(sqfp, sq) != eslOK) p7_Fail("Failed to read sequence from %s\n", seqfile); |
| 2011 |
esl_sqfile_Close(sqfp); |
| 2012 |
|
| 2013 |
|
| 2014 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 2015 |
|
| 2016 |
|
| 2017 |
pli = p7_pipeline_Create(go, 100, sq->n, FALSE, p7_SCAN_MODELS); |
| 2018 |
p7_pli_NewSeq(pli, sq); |
| 2019 |
|
| 2020 |
|
| 2021 |
pli->hfp = hfp; |
| 2022 |
if (! pli->Z_is_fixed && hfp->is_pressed) { pli->Z_is_fixed = TRUE; pli->Z = hfp->ssi->nprimary; } |
| 2023 |
|
| 2024 |
|
| 2025 |
while (p7_oprofile_ReadMSV(hfp, &abc, &om) == eslOK) |
| 2026 |
{ |
| 2027 |
|
| 2028 |
if (bg == NULL) |
| 2029 |
{ |
| 2030 |
bg = p7_bg_Create(abc); |
| 2031 |
if (esl_sq_Digitize(abc, sq) != eslOK) p7_Die("alphabet mismatch"); |
| 2032 |
} |
| 2033 |
p7_pli_NewModel(pli, om, bg); |
| 2034 |
p7_bg_SetLength(bg, sq->n); |
| 2035 |
p7_oprofile_ReconfigLength(om, sq->n); |
| 2036 |
|
| 2037 |
p7_Pipeline(pli, om, bg, sq, hitlist); |
| 2038 |
|
| 2039 |
p7_oprofile_Destroy(om); |
| 2040 |
p7_pipeline_Reuse(pli); |
| 2041 |
} |
| 2042 |
|
| 2043 |
|
| 2044 |
|
| 2045 |
|
| 2046 |
p7_tophits_SortBySortkey(hitlist); |
| 2047 |
namew = ESL_MAX(8, p7_tophits_GetMaxNameLength(hitlist)); |
| 2048 |
for (h = 0; h < hitlist->N; h++) |
| 2049 |
{ |
| 2050 |
d = hitlist->hit[h]->best_domain; |
| 2051 |
|
| 2052 |
printf("%10.2g %7.1f %6.1f %7.1f %6.1f %10.2g %6.1f %5d %-*s %s\n", |
| 2053 |
exp(hitlist->hit[h]->lnP) * (double) pli->Z, |
| 2054 |
hitlist->hit[h]->score, |
| 2055 |
hitlist->hit[h]->pre_score - hitlist->hit[h]->score, |
| 2056 |
hitlist->hit[h]->dcl[d].bitscore, |
| 2057 |
eslCONST_LOG2R * p7_FLogsum(0.0, log(bg->omega) + hitlist->hit[h]->dcl[d].domcorrection), |
| 2058 |
exp(hitlist->hit[h]->dcl[d].lnP) * (double) pli->Z, |
| 2059 |
hitlist->hit[h]->nexpected, |
| 2060 |
hitlist->hit[h]->nreported, |
| 2061 |
namew, |
| 2062 |
hitlist->hit[h]->name, |
| 2063 |
hitlist->hit[h]->desc); |
| 2064 |
} |
| 2065 |
|
| 2066 |
|
| 2067 |
p7_tophits_Destroy(hitlist); |
| 2068 |
p7_pipeline_Destroy(pli); |
| 2069 |
esl_sq_Destroy(sq); |
| 2070 |
p7_hmmfile_Close(hfp); |
| 2071 |
p7_bg_Destroy(bg); |
| 2072 |
esl_alphabet_Destroy(abc); |
| 2073 |
esl_getopts_Destroy(go); |
| 2074 |
return 0; |
| 2075 |
} |
| 2076 |
#endif |
| 2077 |
|
| 2078 |
|
| 2079 |
|