| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <esl_config.h> |
| 9 |
#include <p7_config.h> |
| 10 |
#include "config.h" |
| 11 |
|
| 12 |
#include <stdlib.h> |
| 13 |
#include <stdio.h> |
| 14 |
#include <string.h> |
| 15 |
|
| 16 |
#include "easel.h" |
| 17 |
#include "esl_exponential.h" |
| 18 |
#include "esl_getopts.h" |
| 19 |
#include "esl_gumbel.h" |
| 20 |
#include "esl_vectorops.h" |
| 21 |
|
| 22 |
#include "hmmer.h" |
| 23 |
|
| 24 |
#include "infernal.h" |
| 25 |
|
| 26 |
static int pli_p7_filter (CM_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, P7_SCOREDATA *msvdata, const ESL_SQ *sq, int64_t **ret_ws, int64_t **ret_we, float **ret_wb, int *ret_nwin); |
| 27 |
static int pli_p7_env_def (CM_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, const ESL_SQ *sq, int64_t *ws, int64_t *we, int nwin, P7_HMM **opt_hmm, P7_PROFILE **opt_gm, |
| 28 |
P7_PROFILE **opt_Rgm, P7_PROFILE **opt_Lgm, P7_PROFILE **opt_Tgm, int64_t **ret_es, int64_t **ret_ee, float **ret_eb, int *ret_nenv); |
| 29 |
static int pli_cyk_env_filter (CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, int64_t *p7es, int64_t *p7ee, int np7env, CM_t **opt_cm, int64_t **ret_es, int64_t **ret_ee, int *ret_nenv); |
| 30 |
static int pli_cyk_seq_filter (CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, CM_t **opt_cm, int64_t **ret_ws, int64_t **ret_we, int *ret_nwin); |
| 31 |
static int pli_final_stage (CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, int64_t *es, int64_t *ee, int nenv, CM_TOPHITS *hitlist, CM_t **opt_cm); |
| 32 |
static int pli_final_stage_hmmonly(CM_PIPELINE *pli, off_t cm_offset, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, const ESL_SQ *sq, int64_t *ws, int64_t *we, int nwin, CM_TOPHITS *hitlist, CM_t **opt_cm); |
| 33 |
static int pli_dispatch_cm_search (CM_PIPELINE *pli, CM_t *cm, ESL_DSQ *dsq, int64_t start, int64_t stop, CM_TOPHITS *hitlist, float cutoff, float env_cutoff, int qdbidx, float *ret_sc, int64_t *opt_envi, int64_t *opt_envj); |
| 34 |
static int pli_align_hit (CM_PIPELINE *pli, CM_t *cm, const ESL_SQ *sq, CM_HIT *hit); |
| 35 |
static int pli_scan_mode_read_cm (CM_PIPELINE *pli, off_t cm_offset, float *p7_evparam, int p7_max_length, CM_t **ret_cm); |
| 36 |
|
| 37 |
static int pli_pass_statistics (FILE *ofp, CM_PIPELINE *pli, int pass_idx); |
| 38 |
static int pli_hmmonly_pass_statistics(FILE *ofp, CM_PIPELINE *pli); |
| 39 |
static int pli_sum_statistics (CM_PIPELINE *pli); |
| 40 |
static void pli_copy_subseq (const ESL_SQ *src_sq, ESL_SQ *dest_sq, int64_t i, int64_t L); |
| 41 |
static char *pli_describe_pass (int pass_idx); |
| 42 |
static char *pli_describe_hits_for_pass (int pass_idx); |
| 43 |
static float pli_mxsize_limit_from_W (int W); |
| 44 |
|
| 45 |
static int pli_check_one_or_zero_envelopes(int *nA); |
| 46 |
static int pli_get_pass_of_best_envelope(float **bAA, int *nA); |
| 47 |
static int pli_check_full_length_envelopes(int64_t **esAA, int64_t **eeAA, int *nA, int64_t L); |
| 48 |
static int pli_check_overlap_envelopes(int64_t **sAA, int64_t **eAA, int *nA, int best_pass_idx, int best_env_idx, int64_t start_offset, float min_fract, int *ret_val, char *errbuf); |
| 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 |
|
| 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 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
CM_PIPELINE * |
| 173 |
cm_pipeline_Create(ESL_GETOPTS *go, ESL_ALPHABET *abc, int clen_hint, int L_hint, int64_t Z, enum cm_zsetby_e Z_setby, enum cm_pipemodes_e mode) |
| 174 |
{ |
| 175 |
CM_PIPELINE *pli = NULL; |
| 176 |
int seed = esl_opt_GetInteger(go, "--seed"); |
| 177 |
int status; |
| 178 |
double Z_Mb; |
| 179 |
int pass_idx; |
| 180 |
|
| 181 |
ESL_ALLOC(pli, sizeof(CM_PIPELINE)); |
| 182 |
|
| 183 |
|
| 184 |
if ((pli->fwd = p7_omx_Create(clen_hint, L_hint, L_hint)) == NULL) goto ERROR; |
| 185 |
if ((pli->bck = p7_omx_Create(clen_hint, L_hint, L_hint)) == NULL) goto ERROR; |
| 186 |
if ((pli->oxf = p7_omx_Create(clen_hint, 0, L_hint)) == NULL) goto ERROR; |
| 187 |
if ((pli->oxb = p7_omx_Create(clen_hint, 0, L_hint)) == NULL) goto ERROR; |
| 188 |
if ((pli->gfwd = p7_gmx_Create(clen_hint, L_hint)) == NULL) goto ERROR; |
| 189 |
if ((pli->gbck = p7_gmx_Create(clen_hint, L_hint)) == NULL) goto ERROR; |
| 190 |
if ((pli->gxf = p7_gmx_Create(clen_hint, L_hint)) == NULL) goto ERROR; |
| 191 |
if ((pli->gxb = p7_gmx_Create(clen_hint, L_hint)) == NULL) goto ERROR; |
| 192 |
|
| 193 |
|
| 194 |
pli->mode = mode; |
| 195 |
pli->abc = abc; |
| 196 |
pli->errbuf[0] = '\0'; |
| 197 |
pli->maxW = 0; |
| 198 |
pli->cmW = 0; |
| 199 |
pli->clen = 0; |
| 200 |
pli->cur_cm_idx = -1; |
| 201 |
pli->cur_clan_idx = -1; |
| 202 |
pli->cur_seq_idx = -1; |
| 203 |
pli->cur_pass_idx = -1; |
| 204 |
pli->cmfp = NULL; |
| 205 |
|
| 206 |
|
| 207 |
pli->nseqs = 0; |
| 208 |
pli->nmodels = 0; |
| 209 |
pli->nnodes = 0; |
| 210 |
pli->nmodels_hmmonly = 0; |
| 211 |
pli->nnodes_hmmonly = 0; |
| 212 |
for(pass_idx = 0; pass_idx < NPLI_PASSES; pass_idx++) { |
| 213 |
cm_pli_ZeroAccounting(&(pli->acct[pass_idx])); |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
pli->r = esl_randomness_CreateFast(seed); |
| 222 |
pli->do_reseeding = (seed == 0) ? FALSE : TRUE; |
| 223 |
pli->ddef = p7_domaindef_Create(pli->r); |
| 224 |
pli->ddef->do_reseeding = pli->do_reseeding; |
| 225 |
|
| 226 |
|
| 227 |
if(esl_opt_IsOn(go, "--mxsize")) { |
| 228 |
pli->mxsize_limit = esl_opt_GetReal(go, "--mxsize"); |
| 229 |
pli->mxsize_set = TRUE; |
| 230 |
} |
| 231 |
else { |
| 232 |
pli->mxsize_limit = 0.; |
| 233 |
pli->mxsize_set = FALSE; |
| 234 |
} |
| 235 |
pli->do_top = esl_opt_GetBoolean(go, "--bottomonly") ? FALSE : TRUE; |
| 236 |
pli->do_bot = esl_opt_GetBoolean(go, "--toponly") ? FALSE : TRUE; |
| 237 |
pli->be_verbose = esl_opt_GetBoolean(go, "--verbose") ? TRUE : FALSE; |
| 238 |
pli->show_accessions = esl_opt_GetBoolean(go, "--acc") ? TRUE : FALSE; |
| 239 |
pli->show_alignments = esl_opt_GetBoolean(go, "--noali") ? FALSE : TRUE; |
| 240 |
pli->maxtau = esl_opt_GetReal (go, "--maxtau"); |
| 241 |
pli->do_wcx = esl_opt_IsUsed (go, "--wcx") ? TRUE : FALSE; |
| 242 |
pli->wcx = esl_opt_IsUsed (go, "--wcx") ? esl_opt_GetReal(go, "--wcx") : 0.; |
| 243 |
pli->do_one_cmpass = esl_opt_GetBoolean(go, "--onepass") ? TRUE : FALSE; |
| 244 |
pli->do_one_cmpass_olap = esl_opt_GetBoolean(go, "--olonepass") ? TRUE : FALSE; |
| 245 |
pli->do_not_iterate = esl_opt_GetBoolean(go, "--noiter") ? TRUE : FALSE; |
| 246 |
pli->do_time_F1 = esl_opt_GetBoolean(go, "--timeF1") ? TRUE : FALSE; |
| 247 |
pli->do_time_F2 = esl_opt_GetBoolean(go, "--timeF2") ? TRUE : FALSE; |
| 248 |
pli->do_time_F3 = esl_opt_GetBoolean(go, "--timeF3") ? TRUE : FALSE; |
| 249 |
pli->do_time_F4 = esl_opt_GetBoolean(go, "--timeF4") ? TRUE : FALSE; |
| 250 |
pli->do_time_F5 = esl_opt_GetBoolean(go, "--timeF5") ? TRUE : FALSE; |
| 251 |
pli->do_time_F6 = esl_opt_GetBoolean(go, "--timeF6") ? TRUE : FALSE; |
| 252 |
pli->do_trm_F3 = esl_opt_GetBoolean(go, "--trmF3") ? TRUE : FALSE; |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
pli->smult = 2.0; |
| 258 |
pli->wmult = 1.0; |
| 259 |
pli->mlmult = 0.1; |
| 260 |
pli->cmult = 1.25; |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
pli->by_E = TRUE; |
| 268 |
pli->E = esl_opt_GetReal(go, "-E"); |
| 269 |
pli->T = 0.0; |
| 270 |
pli->use_bit_cutoffs = FALSE; |
| 271 |
if (esl_opt_IsOn(go, "-T")) { |
| 272 |
pli->T = esl_opt_GetReal(go, "-T"); |
| 273 |
pli->by_E = FALSE; |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
pli->inc_by_E = TRUE; |
| 278 |
pli->incE = esl_opt_GetReal(go, "--incE"); |
| 279 |
pli->incT = 0.0; |
| 280 |
if (esl_opt_IsOn(go, "--incT")) { |
| 281 |
pli->incT = esl_opt_GetReal(go, "--incT"); |
| 282 |
pli->inc_by_E = FALSE; |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
if (esl_opt_GetBoolean(go, "--cut_ga")) { |
| 287 |
pli->T = 0.0; |
| 288 |
pli->by_E = FALSE; |
| 289 |
pli->incT = 0.0; |
| 290 |
pli->inc_by_E = FALSE; |
| 291 |
pli->use_bit_cutoffs = CMH_GA; |
| 292 |
} |
| 293 |
if (esl_opt_GetBoolean(go, "--cut_nc")) { |
| 294 |
pli->T = 0.0; |
| 295 |
pli->by_E = FALSE; |
| 296 |
pli->incT = 0.0; |
| 297 |
pli->inc_by_E = FALSE; |
| 298 |
pli->use_bit_cutoffs = CMH_NC; |
| 299 |
} |
| 300 |
if (esl_opt_GetBoolean(go, "--cut_tc")) { |
| 301 |
pli->T = 0.0; |
| 302 |
pli->by_E = FALSE; |
| 303 |
pli->incT = 0.0; |
| 304 |
pli->inc_by_E = FALSE; |
| 305 |
pli->use_bit_cutoffs = CMH_TC; |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
pli->rt1 = esl_opt_GetReal(go, "--rt1"); |
| 310 |
pli->rt2 = esl_opt_GetReal(go, "--rt2"); |
| 311 |
pli->rt3 = esl_opt_GetReal(go, "--rt3"); |
| 312 |
pli->ns = esl_opt_GetInteger(go, "--ns"); |
| 313 |
pli->ddef->rt1 = pli->rt1; |
| 314 |
pli->ddef->rt2 = pli->rt2; |
| 315 |
pli->ddef->rt3 = pli->rt3; |
| 316 |
pli->ddef->nsamples = pli->ns; |
| 317 |
|
| 318 |
|
| 319 |
if(esl_opt_GetBoolean(go, "--anytrunc")) { |
| 320 |
pli->do_trunc_ends = FALSE; |
| 321 |
pli->do_trunc_any = TRUE; |
| 322 |
pli->do_trunc_int = FALSE; |
| 323 |
pli->do_trunc_only = FALSE; |
| 324 |
pli->do_trunc_5p_ends = FALSE; |
| 325 |
pli->do_trunc_3p_ends = FALSE; |
| 326 |
} |
| 327 |
else if(esl_opt_GetBoolean(go, "--inttrunc")) { |
| 328 |
pli->do_trunc_ends = FALSE; |
| 329 |
pli->do_trunc_any = FALSE; |
| 330 |
pli->do_trunc_int = TRUE; |
| 331 |
pli->do_trunc_only = FALSE; |
| 332 |
pli->do_trunc_5p_ends = FALSE; |
| 333 |
pli->do_trunc_3p_ends = FALSE; |
| 334 |
} |
| 335 |
else if(esl_opt_GetBoolean(go, "--onlytrunc")) { |
| 336 |
pli->do_trunc_ends = FALSE; |
| 337 |
pli->do_trunc_any = FALSE; |
| 338 |
pli->do_trunc_int = FALSE; |
| 339 |
pli->do_trunc_only = TRUE; |
| 340 |
pli->do_trunc_5p_ends = FALSE; |
| 341 |
pli->do_trunc_3p_ends = FALSE; |
| 342 |
} |
| 343 |
else if(esl_opt_GetBoolean(go, "--notrunc")) { |
| 344 |
pli->do_trunc_ends = FALSE; |
| 345 |
pli->do_trunc_any = FALSE; |
| 346 |
pli->do_trunc_int = FALSE; |
| 347 |
pli->do_trunc_only = FALSE; |
| 348 |
pli->do_trunc_5p_ends = FALSE; |
| 349 |
pli->do_trunc_3p_ends = FALSE; |
| 350 |
} |
| 351 |
else if(esl_opt_GetBoolean(go, "--5trunc")) { |
| 352 |
pli->do_trunc_ends = FALSE; |
| 353 |
pli->do_trunc_any = FALSE; |
| 354 |
pli->do_trunc_int = FALSE; |
| 355 |
pli->do_trunc_only = FALSE; |
| 356 |
pli->do_trunc_5p_ends = TRUE; |
| 357 |
pli->do_trunc_3p_ends = FALSE; |
| 358 |
} |
| 359 |
else if(esl_opt_GetBoolean(go, "--3trunc")) { |
| 360 |
pli->do_trunc_ends = FALSE; |
| 361 |
pli->do_trunc_any = FALSE; |
| 362 |
pli->do_trunc_int = FALSE; |
| 363 |
pli->do_trunc_only = FALSE; |
| 364 |
pli->do_trunc_5p_ends = FALSE; |
| 365 |
pli->do_trunc_3p_ends = TRUE; |
| 366 |
} |
| 367 |
else { |
| 368 |
pli->do_trunc_ends = TRUE; |
| 369 |
pli->do_trunc_any = FALSE; |
| 370 |
pli->do_trunc_int = FALSE; |
| 371 |
pli->do_trunc_only = FALSE; |
| 372 |
pli->do_trunc_5p_ends = FALSE; |
| 373 |
pli->do_trunc_3p_ends = FALSE; |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
if (esl_opt_IsOn(go, "-Z")) { |
| 384 |
pli->Z_setby = CM_ZSETBY_OPTION; |
| 385 |
pli->Z = (int64_t) (esl_opt_GetReal(go, "-Z") * 1000000.); |
| 386 |
} |
| 387 |
else { |
| 388 |
pli->Z = Z; |
| 389 |
pli->Z_setby = Z_setby; |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
pli->do_max = FALSE; |
| 423 |
pli->do_nohmm = FALSE; |
| 424 |
pli->do_mid = FALSE; |
| 425 |
pli->do_rfam = FALSE; |
| 426 |
pli->do_hmmonly_cur = FALSE; |
| 427 |
pli->do_hmmonly_always = FALSE; |
| 428 |
pli->do_hmmonly_never = FALSE; |
| 429 |
pli->do_msv = TRUE; |
| 430 |
pli->do_msvbias = FALSE; |
| 431 |
pli->do_vit = TRUE; |
| 432 |
pli->do_vitbias = TRUE; |
| 433 |
pli->do_fwd = TRUE; |
| 434 |
pli->do_fwdbias = TRUE; |
| 435 |
pli->do_gfwd = TRUE; |
| 436 |
pli->do_gfwdbias = TRUE; |
| 437 |
pli->do_edef = TRUE; |
| 438 |
pli->do_edefbias = FALSE; |
| 439 |
pli->do_fcyk = TRUE; |
| 440 |
|
| 441 |
if(esl_opt_GetBoolean(go, "--max")) { |
| 442 |
pli->do_max = TRUE; |
| 443 |
pli->do_msv = pli->do_vit = pli->do_fwd = pli->do_gfwd = pli->do_edef = pli->do_fcyk = FALSE; |
| 444 |
pli->do_msvbias = pli->do_vitbias = pli->do_fwdbias = pli->do_gfwdbias = pli->do_edefbias = pli->do_fcykenv = FALSE; |
| 445 |
pli->F1 = pli->F2 = pli->F3 = pli->F4 = pli->F5 = pli->F6 = 1.0; |
| 446 |
pli->F1b = pli->F2b = pli->F3b = pli->F4b = pli->F5b = pli->F6 = 1.0; |
| 447 |
|
| 448 |
pli->do_trunc_ends = FALSE; |
| 449 |
pli->do_trunc_any = FALSE; |
| 450 |
pli->do_trunc_int = FALSE; |
| 451 |
pli->do_trunc_only = FALSE; |
| 452 |
pli->do_trunc_5p_ends = FALSE; |
| 453 |
pli->do_trunc_3p_ends = FALSE; |
| 454 |
} |
| 455 |
else if(esl_opt_GetBoolean(go, "--nohmm")) { |
| 456 |
pli->do_nohmm = TRUE; |
| 457 |
pli->do_msv = pli->do_vit = pli->do_fwd = pli->do_gfwd = pli->do_edef = FALSE; |
| 458 |
pli->do_msvbias = pli->do_vitbias = pli->do_fwdbias = pli->do_gfwdbias = pli->do_edefbias = FALSE; |
| 459 |
pli->F1 = pli->F2 = pli->F3 = pli->F4 = pli->F5 = 1.0; |
| 460 |
pli->F1b = pli->F2b = pli->F3b = pli->F4b = pli->F5b = 1.0; |
| 461 |
pli->F6 = 0.0001; |
| 462 |
|
| 463 |
pli->do_trunc_ends = FALSE; |
| 464 |
pli->do_trunc_any = FALSE; |
| 465 |
pli->do_trunc_int = FALSE; |
| 466 |
pli->do_trunc_only = FALSE; |
| 467 |
pli->do_trunc_5p_ends = FALSE; |
| 468 |
pli->do_trunc_3p_ends = FALSE; |
| 469 |
} |
| 470 |
else if(esl_opt_GetBoolean(go, "--mid")) { |
| 471 |
pli->do_mid = TRUE; |
| 472 |
pli->do_msv = pli->do_vit = FALSE; |
| 473 |
pli->do_msvbias = pli->do_vitbias = FALSE; |
| 474 |
pli->F1 = pli->F2 = 1.0; |
| 475 |
pli->F1b = pli->F2b = 1.0; |
| 476 |
pli->F3 = pli->F3b = pli->F4 = pli->F4b = pli->F5 = pli->F5b = esl_opt_GetReal(go, "--Fmid"); |
| 477 |
pli->F6 = 0.0001; |
| 478 |
} |
| 479 |
else if(esl_opt_GetBoolean(go, "--rfam")) { |
| 480 |
pli->do_rfam = TRUE; |
| 481 |
pli->F1 = 0.06; |
| 482 |
pli->F2 = pli->F2b = 0.02; |
| 483 |
pli->F3 = pli->F3b = 0.0002; |
| 484 |
pli->F4 = pli->F4b = 0.0002; |
| 485 |
pli->F5 = pli->F5b = 0.0002; |
| 486 |
pli->F6 = 0.0001; |
| 487 |
|
| 488 |
} |
| 489 |
else { |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
Z_Mb = esl_opt_IsOn(go, "--FZ") ? esl_opt_GetReal(go, "--FZ") : pli->Z / 1000000.; |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
Z_Mb = esl_opt_IsUsed(go, "--FZ") ? esl_opt_GetReal(go, "--FZ") : pli->Z / 1000000.; |
| 505 |
|
| 506 |
|
| 507 |
pli->do_msvbias = pli->do_edefbias = FALSE; |
| 508 |
pli->F1b = pli->F5b = 1.0; |
| 509 |
|
| 510 |
|
| 511 |
if(Z_Mb >= (20000. - eslSMALLX1)) { |
| 512 |
pli->F1 = 0.06; |
| 513 |
pli->F2 = pli->F2b = 0.02; |
| 514 |
pli->F3 = pli->F3b = 0.0002; |
| 515 |
pli->F4 = pli->F4b = 0.0002; |
| 516 |
pli->F5 = pli->F5b = 0.0002; |
| 517 |
pli->F6 = 0.0001; |
| 518 |
} |
| 519 |
else if(Z_Mb >= (2000. - eslSMALLX1)) { |
| 520 |
pli->F1 = 0.15; |
| 521 |
pli->F2 = pli->F2b = 0.15; |
| 522 |
pli->F3 = pli->F3b = 0.0002; |
| 523 |
pli->F4 = pli->F4b = 0.0002; |
| 524 |
pli->F5 = pli->F5b = 0.0002; |
| 525 |
pli->F6 = 0.0001; |
| 526 |
} |
| 527 |
else if(Z_Mb >= (200. - eslSMALLX1)) { |
| 528 |
pli->F1 = 0.15; |
| 529 |
pli->F2 = pli->F2b = 0.15; |
| 530 |
pli->F3 = pli->F3b = 0.0008; |
| 531 |
pli->F4 = pli->F4b = 0.0008; |
| 532 |
pli->F5 = pli->F5b = 0.0008; |
| 533 |
pli->F6 = 0.0001; |
| 534 |
} |
| 535 |
else if(Z_Mb >= (20. - eslSMALLX1)) { |
| 536 |
pli->F1 = pli->F1b = 0.35; |
| 537 |
pli->F2 = pli->F2b = 0.15; |
| 538 |
pli->F3 = pli->F3b = 0.003; |
| 539 |
pli->F4 = pli->F4b = 0.003; |
| 540 |
pli->F5 = pli->F5b = 0.003; |
| 541 |
pli->F6 = 0.0001; |
| 542 |
} |
| 543 |
else if(Z_Mb >= (2. - eslSMALLX1)) { |
| 544 |
pli->F1 = 0.35; |
| 545 |
pli->do_vit = pli->do_vitbias = FALSE; |
| 546 |
pli->F2 = pli->F2b = 1.00; |
| 547 |
pli->F3 = pli->F3b = 0.005; |
| 548 |
pli->F4 = pli->F4b = 0.005; |
| 549 |
pli->F5 = pli->F5b = 0.005; |
| 550 |
pli->F6 = 0.0001; |
| 551 |
} |
| 552 |
else { |
| 553 |
pli->F1 = 0.35; |
| 554 |
pli->do_vit = pli->do_vitbias = FALSE; |
| 555 |
pli->F2 = pli->F2b = 1.00; |
| 556 |
pli->F3 = pli->F3b = 0.02; |
| 557 |
pli->F4 = pli->F4b = 0.02; |
| 558 |
pli->F5 = pli->F5b = 0.02; |
| 559 |
pli->F6 = 0.0001; |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
if((! pli->do_max) && (! pli->do_nohmm) && (! pli->do_mid)) { |
| 575 |
if(esl_opt_IsOn(go, "--F1")) { pli->do_msv = TRUE; pli->F1 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F1")); } |
| 576 |
if(esl_opt_IsOn(go, "--F1b")) { pli->do_msvbias = TRUE; pli->F1b = ESL_MIN(1.0, esl_opt_GetReal(go, "--F1b")); } |
| 577 |
if(esl_opt_IsOn(go, "--F2")) { pli->do_vit = TRUE; pli->F2 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F2")); } |
| 578 |
if(esl_opt_IsOn(go, "--F2b")) { pli->do_vitbias = TRUE; pli->F2b = ESL_MIN(1.0, esl_opt_GetReal(go, "--F2b")); } |
| 579 |
} |
| 580 |
if((! pli->do_max) && (! pli->do_nohmm)) { |
| 581 |
if(esl_opt_IsOn(go, "--F3")) { pli->do_fwd = TRUE; pli->F3 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F3")); } |
| 582 |
if(esl_opt_IsOn(go, "--F3b")) { pli->do_fwdbias = TRUE; pli->F3b = ESL_MIN(1.0, esl_opt_GetReal(go, "--F3b")); } |
| 583 |
if(esl_opt_IsOn(go, "--F4")) { pli->do_gfwd = TRUE; pli->F4 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F4")); } |
| 584 |
if(esl_opt_IsOn(go, "--F4b")) { pli->do_gfwdbias = TRUE; pli->F4b = ESL_MIN(1.0, esl_opt_GetReal(go, "--F4b")); } |
| 585 |
if(esl_opt_IsOn(go, "--F5")) { pli->do_edef = TRUE; pli->F5 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F5")); } |
| 586 |
if(esl_opt_IsOn(go, "--F5b")) { pli->do_edefbias = TRUE; pli->F5b = ESL_MIN(1.0, esl_opt_GetReal(go, "--F5b")); } |
| 587 |
} |
| 588 |
if(! pli->do_max) { |
| 589 |
if(esl_opt_IsOn(go, "--F6")) { pli->do_fcyk = TRUE; pli->F6 = ESL_MIN(1.0, esl_opt_GetReal(go, "--F6")); } |
| 590 |
} |
| 591 |
|
| 592 |
if(esl_opt_GetBoolean(go, "--noF1")) pli->do_msv = FALSE; |
| 593 |
if(esl_opt_GetBoolean(go, "--noF2")) pli->do_vit = FALSE; |
| 594 |
if(esl_opt_GetBoolean(go, "--noF3")) pli->do_fwd = FALSE; |
| 595 |
if(esl_opt_GetBoolean(go, "--noF4")) pli->do_gfwd = FALSE; |
| 596 |
if(esl_opt_GetBoolean(go, "--noF6")) pli->do_fcyk = FALSE; |
| 597 |
|
| 598 |
if((! pli->do_max) && (! pli->do_nohmm) && (! pli->do_mid)) { |
| 599 |
if(esl_opt_GetBoolean(go, "--doF1b")) pli->do_msvbias = TRUE; |
| 600 |
} |
| 601 |
if(esl_opt_GetBoolean(go, "--noF2b")) pli->do_vitbias = FALSE; |
| 602 |
if(esl_opt_GetBoolean(go, "--noF3b")) pli->do_fwdbias = FALSE; |
| 603 |
if(esl_opt_GetBoolean(go, "--noF4b")) pli->do_gfwdbias = FALSE; |
| 604 |
if(esl_opt_GetBoolean(go, "--doF5b")) pli->do_edefbias = TRUE; |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
pli->do_hmmonly_always = (esl_opt_GetBoolean(go, "--hmmonly")) ? TRUE : FALSE; |
| 614 |
pli->do_hmmonly_never = (esl_opt_GetBoolean(go, "--nohmmonly") || |
| 615 |
esl_opt_GetBoolean(go, "--max") || |
| 616 |
esl_opt_GetBoolean(go, "--nohmm")) ? TRUE : FALSE; |
| 617 |
|
| 618 |
pli->do_max_hmmonly = FALSE; |
| 619 |
pli->do_bias_hmmonly = TRUE; |
| 620 |
pli->do_null2_hmmonly = TRUE; |
| 621 |
pli->F1_hmmonly = ESL_MIN(1.0, esl_opt_GetReal(go, "--hmmF1")); |
| 622 |
pli->F2_hmmonly = ESL_MIN(1.0, esl_opt_GetReal(go, "--hmmF2")); |
| 623 |
pli->F3_hmmonly = ESL_MIN(1.0, esl_opt_GetReal(go, "--hmmF3")); |
| 624 |
if(esl_opt_GetBoolean(go, "--hmmmax")) { |
| 625 |
pli->do_max_hmmonly = TRUE; |
| 626 |
pli->do_bias_hmmonly = FALSE; |
| 627 |
pli->F1_hmmonly = 0.3; |
| 628 |
pli->F2_hmmonly = 1.0; |
| 629 |
pli->F3_hmmonly = 1.0; |
| 630 |
} |
| 631 |
if(esl_opt_GetBoolean(go, "--hmmnonull2")) pli->do_null2_hmmonly = FALSE; |
| 632 |
if(esl_opt_GetBoolean(go, "--hmmnobias")) pli->do_bias_hmmonly = FALSE; |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
pli->do_null2 = esl_opt_GetBoolean(go, "--null2") ? TRUE : FALSE; |
| 640 |
pli->do_null3 = esl_opt_GetBoolean(go, "--nonull3") ? FALSE : TRUE; |
| 641 |
|
| 642 |
pli->fcyk_cm_search_opts = 0; |
| 643 |
pli->final_cm_search_opts = 0; |
| 644 |
pli->fcyk_beta = esl_opt_GetReal(go, "--fbeta"); |
| 645 |
pli->fcyk_tau = esl_opt_GetReal(go, "--ftau"); |
| 646 |
pli->do_fcykenv = esl_opt_GetBoolean(go, "--nocykenv") ? FALSE : TRUE; |
| 647 |
|
| 648 |
pli->F6env = ESL_MIN(1.0, pli->F6 * (float) esl_opt_GetInteger(go, "--cykenvx")); |
| 649 |
|
| 650 |
pli->final_beta = esl_opt_GetReal(go, "--beta"); |
| 651 |
pli->final_tau = esl_opt_GetReal(go, "--tau"); |
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
if(pli->do_fcyk) { |
| 680 |
if(pli->do_nohmm) { |
| 681 |
|
| 682 |
|
| 683 |
if(esl_opt_GetBoolean(go, "--fnonbanded")) pli->fcyk_cm_search_opts |= CM_SEARCH_NONBANDED; |
| 684 |
else pli->fcyk_cm_search_opts |= CM_SEARCH_QDB; |
| 685 |
} |
| 686 |
else { |
| 687 |
if (esl_opt_GetBoolean(go, "--fnonbanded")) pli->fcyk_cm_search_opts |= CM_SEARCH_NONBANDED; |
| 688 |
else if(esl_opt_GetBoolean(go, "--fqdb")) pli->fcyk_cm_search_opts |= CM_SEARCH_QDB; |
| 689 |
else pli->fcyk_cm_search_opts |= CM_SEARCH_HBANDED; |
| 690 |
} |
| 691 |
if( esl_opt_GetBoolean(go, "--fsums")) pli->fcyk_cm_search_opts |= CM_SEARCH_SUMS; |
| 692 |
if(! esl_opt_GetBoolean(go, "--nonull3")) pli->fcyk_cm_search_opts |= CM_SEARCH_NULL3; |
| 693 |
} |
| 694 |
|
| 695 |
|
| 696 |
if(! esl_opt_GetBoolean(go, "--cyk")) pli->final_cm_search_opts |= CM_SEARCH_INSIDE; |
| 697 |
if (pli->do_max) { |
| 698 |
if(esl_opt_GetBoolean(go, "--qdb")) pli->final_cm_search_opts |= CM_SEARCH_QDB; |
| 699 |
else pli->final_cm_search_opts |= CM_SEARCH_NONBANDED; |
| 700 |
} |
| 701 |
else if(pli->do_nohmm) { |
| 702 |
if(esl_opt_GetBoolean(go, "--nonbanded")) pli->final_cm_search_opts |= CM_SEARCH_NONBANDED; |
| 703 |
else pli->final_cm_search_opts |= CM_SEARCH_QDB; |
| 704 |
} |
| 705 |
else { |
| 706 |
if (esl_opt_GetBoolean(go, "--nonbanded")) pli->final_cm_search_opts |= CM_SEARCH_NONBANDED; |
| 707 |
else if(esl_opt_GetBoolean(go, "--qdb")) pli->final_cm_search_opts |= CM_SEARCH_QDB; |
| 708 |
else pli->final_cm_search_opts |= CM_SEARCH_HBANDED; |
| 709 |
} |
| 710 |
if(esl_opt_GetBoolean(go, "--sums")) pli->final_cm_search_opts |= CM_SEARCH_SUMS; |
| 711 |
if(esl_opt_GetBoolean(go, "--nogreedy")) pli->final_cm_search_opts |= CM_SEARCH_CMNOTGREEDY; |
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
pli->cm_config_opts = 0; |
| 720 |
pli->cm_align_opts = 0; |
| 721 |
|
| 722 |
if(! esl_opt_GetBoolean(go, "-g")) { |
| 723 |
pli->cm_config_opts |= CM_CONFIG_LOCAL; |
| 724 |
if(! esl_opt_GetBoolean(go, "--cp9gloc")) { |
| 725 |
pli->cm_config_opts |= CM_CONFIG_HMMLOCAL; |
| 726 |
if(! esl_opt_GetBoolean(go, "--cp9noel")) { |
| 727 |
pli->cm_config_opts |= CM_CONFIG_HMMEL; |
| 728 |
} |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
if(pli->do_trunc_ends || pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_only || pli->do_trunc_5p_ends || pli->do_trunc_3p_ends) pli->cm_config_opts |= CM_CONFIG_TRUNC; |
| 733 |
|
| 734 |
|
| 735 |
if(pli->do_max || |
| 736 |
pli->do_nohmm || |
| 737 |
esl_opt_GetBoolean(go, "--fqdb") || |
| 738 |
esl_opt_GetBoolean(go, "--qdb")) { |
| 739 |
pli->cm_config_opts |= CM_CONFIG_SCANMX; |
| 740 |
if(pli->do_trunc_ends || pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_only || pli->do_trunc_5p_ends || pli->do_trunc_3p_ends) pli->cm_config_opts |= CM_CONFIG_TRSCANMX; |
| 741 |
} |
| 742 |
|
| 743 |
if(pli->do_max || |
| 744 |
pli->do_nohmm || |
| 745 |
esl_opt_GetBoolean(go, "--qdb")) { |
| 746 |
pli->cm_align_opts |= CM_ALIGN_SMALL; |
| 747 |
pli->cm_align_opts |= CM_ALIGN_CYK; |
| 748 |
if(pli->do_max) pli->cm_align_opts |= CM_ALIGN_NONBANDED; |
| 749 |
else pli->cm_align_opts |= CM_ALIGN_QDB; |
| 750 |
|
| 751 |
pli->do_trunc_ends = FALSE; |
| 752 |
pli->do_trunc_any = FALSE; |
| 753 |
pli->do_trunc_int = FALSE; |
| 754 |
pli->do_trunc_only = FALSE; |
| 755 |
pli->do_trunc_5p_ends = FALSE; |
| 756 |
pli->do_trunc_3p_ends = FALSE; |
| 757 |
} |
| 758 |
else { |
| 759 |
pli->cm_align_opts |= CM_ALIGN_HBANDED; |
| 760 |
pli->cm_align_opts |= CM_ALIGN_POST; |
| 761 |
if(esl_opt_GetBoolean(go, "--acyk")) pli->cm_align_opts |= CM_ALIGN_CYK; |
| 762 |
else pli->cm_align_opts |= CM_ALIGN_OPTACC; |
| 763 |
} |
| 764 |
|
| 765 |
|
| 766 |
pli->do_glocal_cm_always = (esl_opt_GetBoolean(go, "-g")) ? TRUE : FALSE; |
| 767 |
pli->do_glocal_cm_cur = pli->do_glocal_cm_always ? TRUE : FALSE; |
| 768 |
pli->do_glocal_cm_sometimes = (esl_opt_IsOn(go, "--glist")) ? TRUE : FALSE; |
| 769 |
|
| 770 |
pli->fcyk_cm_exp_mode = pli->do_glocal_cm_always ? EXP_CM_GC : EXP_CM_LC; |
| 771 |
if(pli->final_cm_search_opts & CM_SEARCH_INSIDE) { |
| 772 |
pli->final_cm_exp_mode = pli->do_glocal_cm_always ? EXP_CM_GI : EXP_CM_LI; |
| 773 |
} |
| 774 |
else { |
| 775 |
pli->final_cm_exp_mode = pli->do_glocal_cm_always ? EXP_CM_GC : EXP_CM_LC; |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
return pli; |
| 781 |
|
| 782 |
ERROR: |
| 783 |
cm_pipeline_Destroy(pli, NULL); |
| 784 |
return NULL; |
| 785 |
} |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
int |
| 800 |
cm_pipeline_Reuse(CM_PIPELINE *pli) |
| 801 |
{ |
| 802 |
p7_omx_Reuse(pli->oxf); |
| 803 |
p7_omx_Reuse(pli->oxb); |
| 804 |
p7_omx_Reuse(pli->fwd); |
| 805 |
p7_omx_Reuse(pli->bck); |
| 806 |
p7_domaindef_Reuse(pli->ddef); |
| 807 |
|
| 808 |
return eslOK; |
| 809 |
} |
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
void |
| 820 |
cm_pipeline_Destroy(CM_PIPELINE *pli, CM_t *cm) |
| 821 |
{ |
| 822 |
if (pli == NULL) return; |
| 823 |
|
| 824 |
p7_omx_Destroy(pli->oxf); |
| 825 |
p7_omx_Destroy(pli->oxb); |
| 826 |
p7_omx_Destroy(pli->fwd); |
| 827 |
p7_omx_Destroy(pli->bck); |
| 828 |
p7_gmx_Destroy(pli->gfwd); |
| 829 |
p7_gmx_Destroy(pli->gbck); |
| 830 |
p7_gmx_Destroy(pli->gxf); |
| 831 |
p7_gmx_Destroy(pli->gxb); |
| 832 |
esl_randomness_Destroy(pli->r); |
| 833 |
p7_domaindef_Destroy(pli->ddef); |
| 834 |
free(pli); |
| 835 |
} |
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
int |
| 853 |
cm_pli_TargetReportable(CM_PIPELINE *pli, float score, double Eval) |
| 854 |
{ |
| 855 |
if ( pli->by_E && Eval <= pli->E) return TRUE; |
| 856 |
else if (! pli->by_E && score >= pli->T) return TRUE; |
| 857 |
return FALSE; |
| 858 |
} |
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
int |
| 866 |
cm_pli_TargetIncludable(CM_PIPELINE *pli, float score, double Eval) |
| 867 |
{ |
| 868 |
if ( pli->by_E && Eval <= pli->incE) return TRUE; |
| 869 |
else if (! pli->by_E && score >= pli->incT) return TRUE; |
| 870 |
|
| 871 |
return FALSE; |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 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 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
int |
| 955 |
cm_pli_NewModel(CM_PIPELINE *pli, int modmode, CM_t *cm, int cm_clen, int cm_W, int cm_nbp, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, int p7_max_length, int64_t cur_cm_idx, int cur_clan_idx, ESL_KEYHASH *glocal_kh) |
| 956 |
{ |
| 957 |
int status = eslOK; |
| 958 |
float T; |
| 959 |
|
| 960 |
|
| 961 |
if(pli->mode == CM_SEARCH_SEQS) { |
| 962 |
if(modmode != CM_NEWMODEL_CM) |
| 963 |
if(cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SEARCH mode and CM is NULL"); |
| 964 |
if(cm->clen != cm_clen) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->clen != cm_clen"); |
| 965 |
if(cm->W != cm_W) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->W != cm_W"); |
| 966 |
if(CMCountNodetype(cm, MATP_nd) != cm_nbp) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->clen != cm_clen"); |
| 967 |
if(om == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SEARCH mode and om is NULL"); |
| 968 |
if(bg == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SEARCH mode and bg is NULL"); |
| 969 |
} |
| 970 |
else if(pli->mode == CM_SCAN_MODELS) { |
| 971 |
if(modmode == CM_NEWMODEL_MSV) { |
| 972 |
if(cm != NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/MSV mode, and CM is non-NULL"); |
| 973 |
if(om == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/MSV mode, and om is NULL"); |
| 974 |
if(bg == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/MSV mode, and bg is NULL"); |
| 975 |
} |
| 976 |
else if(modmode == CM_NEWMODEL_CM) { |
| 977 |
if(cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/CM mode, and CM is NULL"); |
| 978 |
if(cm->clen != cm_clen) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->clen != cm_clen"); |
| 979 |
if(cm->W != cm_W) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->W != cm_W"); |
| 980 |
if(CMCountNodetype(cm, MATP_nd) != cm_nbp) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, cm->clen != cm_clen"); |
| 981 |
if(om != NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/CM mode, and om is non-NULL"); |
| 982 |
if(bg != NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, SCAN/CM mode, and bg is non-NULL"); |
| 983 |
} |
| 984 |
} |
| 985 |
|
| 986 |
pli->cur_cm_idx = cur_cm_idx; |
| 987 |
pli->cur_clan_idx = cur_clan_idx; |
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
if(pli->mode == CM_SEARCH_SEQS || modmode == CM_NEWMODEL_MSV) { |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
if(modmode == CM_NEWMODEL_MSV && pli->do_glocal_cm_sometimes) { |
| 999 |
if(glocal_kh == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, do_glocal_cm_sometimes is TRUE but glocal_kh is NULL"); |
| 1000 |
if(pli->do_glocal_cm_always) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "cm_pli_NewModel(), contract violated, do_glocal_cm_sometimes and do_glocal_cm_always both TRUE"); |
| 1001 |
status = esl_keyhash_Lookup(glocal_kh, om->name, -1, NULL); |
| 1002 |
if(status == eslOK) { |
| 1003 |
pli->do_glocal_cm_cur = TRUE; |
| 1004 |
pli->fcyk_cm_exp_mode = EXP_CM_GC; |
| 1005 |
pli->final_cm_exp_mode = (pli->final_cm_search_opts & CM_SEARCH_INSIDE) ? EXP_CM_GI : EXP_CM_GC; |
| 1006 |
pli->cm_config_opts &= ~CM_CONFIG_LOCAL; |
| 1007 |
pli->cm_config_opts &= ~CM_CONFIG_HMMLOCAL; |
| 1008 |
pli->cm_config_opts &= ~CM_CONFIG_HMMEL; |
| 1009 |
} |
| 1010 |
else if (status == eslENOTFOUND) { |
| 1011 |
pli->do_glocal_cm_cur = FALSE; |
| 1012 |
pli->fcyk_cm_exp_mode = EXP_CM_LC; |
| 1013 |
pli->final_cm_exp_mode = (pli->final_cm_search_opts & CM_SEARCH_INSIDE) ? EXP_CM_LI : EXP_CM_LC; |
| 1014 |
pli->cm_config_opts |= CM_CONFIG_LOCAL; |
| 1015 |
pli->cm_config_opts |= CM_CONFIG_HMMLOCAL; |
| 1016 |
pli->cm_config_opts |= CM_CONFIG_HMMEL; |
| 1017 |
} |
| 1018 |
else { ESL_FAIL(status, pli->errbuf, "cm_pli_NewModel(), unexpected error looking up model %s\n", om->name); } |
| 1019 |
} |
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
if (pli->do_hmmonly_never || pli->do_glocal_cm_cur) pli->do_hmmonly_cur = FALSE; |
| 1029 |
else if(pli->do_hmmonly_always || cm_nbp == 0) pli->do_hmmonly_cur = TRUE; |
| 1030 |
else pli->do_hmmonly_cur = FALSE; |
| 1031 |
|
| 1032 |
if(pli->do_hmmonly_cur) { |
| 1033 |
pli->nmodels_hmmonly++; |
| 1034 |
pli->nnodes_hmmonly += cm_clen; |
| 1035 |
} |
| 1036 |
else { |
| 1037 |
pli->nmodels++; |
| 1038 |
pli->nnodes += cm_clen; |
| 1039 |
} |
| 1040 |
|
| 1041 |
if (pli->do_msvbias || pli->do_vitbias || pli->do_fwdbias || pli->do_gfwdbias || pli->do_edefbias) { |
| 1042 |
p7_bg_SetFilter(bg, om->M, om->compo); |
| 1043 |
} |
| 1044 |
|
| 1045 |
pli->cmW = cm_W; |
| 1046 |
pli->clen = cm_clen; |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
pli->maxW = ESL_MAX(pli->wmult * cm_W, pli->cmult * cm_clen); |
| 1056 |
} |
| 1057 |
if(pli->mode == CM_SEARCH_SEQS || modmode == CM_NEWMODEL_CM) { |
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
if(pli->do_hmmonly_cur) { |
| 1068 |
if(pli->by_E) { |
| 1069 |
pli->T = cm_p7_E2Score(pli->E, pli->Z, p7_max_length, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 1070 |
} |
| 1071 |
} |
| 1072 |
else { |
| 1073 |
if((status = UpdateExpsForDBSize(cm, pli->errbuf, pli->Z)) != eslOK) return status; |
| 1074 |
if(pli->by_E) { |
| 1075 |
if((status = E2ScoreGivenExpInfo(cm->expA[pli->final_cm_exp_mode], pli->errbuf, pli->E, &T)) != eslOK) ESL_FAIL(status, pli->errbuf, "problem determining min score for E-value %6g for model %s\n", pli->E, cm->name); |
| 1076 |
pli->T = (double) T; |
| 1077 |
} |
| 1078 |
} |
| 1079 |
|
| 1080 |
|
| 1081 |
if (pli->use_bit_cutoffs) { |
| 1082 |
if((status = cm_pli_NewModelThresholds(pli, cm)) != eslOK) return status; |
| 1083 |
} |
| 1084 |
} |
| 1085 |
return eslOK; |
| 1086 |
} |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
int |
| 1114 |
cm_pli_NewModelThresholds(CM_PIPELINE *pli, CM_t *cm) |
| 1115 |
{ |
| 1116 |
|
| 1117 |
if (pli->use_bit_cutoffs) { |
| 1118 |
if(pli->use_bit_cutoffs == CMH_GA) { |
| 1119 |
if (! (cm->flags & CMH_GA)) ESL_FAIL(eslEINVAL, pli->errbuf, "GA bit threshold unavailable for model %s\n", cm->name); |
| 1120 |
pli->T = pli->incT = cm->ga; |
| 1121 |
} |
| 1122 |
else if(pli->use_bit_cutoffs == CMH_TC) { |
| 1123 |
if (! (cm->flags & CMH_TC)) ESL_FAIL(eslEINVAL, pli->errbuf, "TC bit threshold unavailable for model %s\n", cm->name); |
| 1124 |
pli->T = pli->incT = cm->tc; |
| 1125 |
} |
| 1126 |
else if(pli->use_bit_cutoffs == CMH_NC) { |
| 1127 |
if (! (cm->flags & CMH_NC)) ESL_FAIL(eslEINVAL, pli->errbuf, "NC bit threshold unavailable for model %s\n", cm->name); |
| 1128 |
pli->T = pli->incT = cm->nc; |
| 1129 |
} |
| 1130 |
} |
| 1131 |
return eslOK; |
| 1132 |
} |
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
int |
| 1153 |
cm_pli_NewSeq(CM_PIPELINE *pli, const ESL_SQ *sq, int64_t cur_seq_idx) |
| 1154 |
{ |
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
pli->cur_seq_idx = cur_seq_idx; |
| 1159 |
|
| 1160 |
return eslOK; |
| 1161 |
} |
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
int |
| 1177 |
cm_pipeline_Merge(CM_PIPELINE *p1, CM_PIPELINE *p2) |
| 1178 |
{ |
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
int p; |
| 1183 |
|
| 1184 |
if (p1->mode == CM_SEARCH_SEQS) |
| 1185 |
{ |
| 1186 |
p1->nseqs += p2->nseqs; |
| 1187 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].npli_top += p2->acct[p].npli_top; |
| 1188 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].npli_bot += p2->acct[p].npli_bot; |
| 1189 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].nres_top += p2->acct[p].nres_top; |
| 1190 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].nres_bot += p2->acct[p].nres_bot; |
| 1191 |
} |
| 1192 |
else |
| 1193 |
{ |
| 1194 |
p1->nmodels += p2->nmodels; |
| 1195 |
p1->nnodes += p2->nnodes; |
| 1196 |
p1->nmodels_hmmonly += p2->nmodels_hmmonly; |
| 1197 |
p1->nnodes_hmmonly += p2->nnodes_hmmonly; |
| 1198 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].nres_top += p2->acct[p].nres_top; |
| 1199 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].nres_bot += p2->acct[p].nres_bot; |
| 1200 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].npli_top += p2->acct[p].npli_top; |
| 1201 |
for(p = 0; p < NPLI_PASSES; p++) p1->acct[p].npli_bot += p2->acct[p].npli_bot; |
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
p1->nseqs = ESL_MAX(p1->nseqs, p2->nseqs); |
| 1209 |
} |
| 1210 |
|
| 1211 |
for(p = 0; p < NPLI_PASSES; p++) { |
| 1212 |
p1->acct[p].n_past_msv += p2->acct[p].n_past_msv; |
| 1213 |
p1->acct[p].n_past_vit += p2->acct[p].n_past_vit; |
| 1214 |
p1->acct[p].n_past_fwd += p2->acct[p].n_past_fwd; |
| 1215 |
p1->acct[p].n_past_gfwd += p2->acct[p].n_past_gfwd; |
| 1216 |
p1->acct[p].n_past_edef += p2->acct[p].n_past_edef; |
| 1217 |
p1->acct[p].n_past_cyk += p2->acct[p].n_past_cyk; |
| 1218 |
p1->acct[p].n_past_ins += p2->acct[p].n_past_ins; |
| 1219 |
p1->acct[p].n_output += p2->acct[p].n_output; |
| 1220 |
|
| 1221 |
p1->acct[p].n_past_msvbias += p2->acct[p].n_past_msvbias; |
| 1222 |
p1->acct[p].n_past_vitbias += p2->acct[p].n_past_vitbias; |
| 1223 |
p1->acct[p].n_past_fwdbias += p2->acct[p].n_past_fwdbias; |
| 1224 |
p1->acct[p].n_past_gfwdbias += p2->acct[p].n_past_gfwdbias; |
| 1225 |
p1->acct[p].n_past_edefbias += p2->acct[p].n_past_edefbias; |
| 1226 |
|
| 1227 |
p1->acct[p].pos_past_msv += p2->acct[p].pos_past_msv; |
| 1228 |
p1->acct[p].pos_past_vit += p2->acct[p].pos_past_vit; |
| 1229 |
p1->acct[p].pos_past_fwd += p2->acct[p].pos_past_fwd; |
| 1230 |
p1->acct[p].pos_past_gfwd += p2->acct[p].pos_past_gfwd; |
| 1231 |
p1->acct[p].pos_past_edef += p2->acct[p].pos_past_edef; |
| 1232 |
p1->acct[p].pos_past_cyk += p2->acct[p].pos_past_cyk; |
| 1233 |
p1->acct[p].pos_past_ins += p2->acct[p].pos_past_ins; |
| 1234 |
p1->acct[p].pos_output += p2->acct[p].pos_output; |
| 1235 |
|
| 1236 |
p1->acct[p].pos_past_msvbias += p2->acct[p].pos_past_msvbias; |
| 1237 |
p1->acct[p].pos_past_vitbias += p2->acct[p].pos_past_vitbias; |
| 1238 |
p1->acct[p].pos_past_fwdbias += p2->acct[p].pos_past_fwdbias; |
| 1239 |
p1->acct[p].pos_past_gfwdbias+= p2->acct[p].pos_past_gfwdbias; |
| 1240 |
p1->acct[p].pos_past_edefbias += p2->acct[p].pos_past_edefbias; |
| 1241 |
|
| 1242 |
p1->acct[p].n_overflow_fcyk += p2->acct[p].n_overflow_fcyk; |
| 1243 |
p1->acct[p].n_overflow_final += p2->acct[p].n_overflow_final; |
| 1244 |
p1->acct[p].n_aln_hb += p2->acct[p].n_aln_hb; |
| 1245 |
p1->acct[p].n_aln_dccyk += p2->acct[p].n_aln_dccyk; |
| 1246 |
} |
| 1247 |
|
| 1248 |
return eslOK; |
| 1249 |
} |
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
int |
| 1284 |
cm_Pipeline(CM_PIPELINE *pli, off_t cm_offset, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, P7_SCOREDATA *msvdata, ESL_SQ *sq, CM_TOPHITS *hitlist, int in_rc, P7_HMM **opt_hmm, P7_PROFILE **opt_gm, P7_PROFILE **opt_Rgm, P7_PROFILE **opt_Lgm, P7_PROFILE **opt_Tgm, CM_t **opt_cm) |
| 1285 |
{ |
| 1286 |
int status; |
| 1287 |
int nwin = 0; |
| 1288 |
int64_t *ws = NULL; |
| 1289 |
int64_t *we = NULL; |
| 1290 |
float *wb = NULL; |
| 1291 |
int *np7envA =NULL; |
| 1292 |
int64_t **p7esAA = NULL; |
| 1293 |
int64_t **p7eeAA = NULL; |
| 1294 |
float **p7ebAA = NULL; |
| 1295 |
int nenv = 0; |
| 1296 |
int64_t *es = NULL; |
| 1297 |
int64_t *ee = NULL; |
| 1298 |
int i; |
| 1299 |
CM_HIT *hit = NULL; |
| 1300 |
|
| 1301 |
|
| 1302 |
ESL_SQ *sq2search = NULL; |
| 1303 |
ESL_SQ *term5sq = NULL; |
| 1304 |
ESL_SQ *term3sq = NULL; |
| 1305 |
int p; |
| 1306 |
int nwin_pass_std_any = -1; |
| 1307 |
int do_pass_std_any; |
| 1308 |
int do_pass_5p_only_force; |
| 1309 |
int do_pass_3p_only_force; |
| 1310 |
int do_pass_5p_and_3p_force; |
| 1311 |
int do_pass_5p_and_3p_any; |
| 1312 |
int do_pass_hmm_only_any; |
| 1313 |
int have5term; |
| 1314 |
int have3term; |
| 1315 |
int h; |
| 1316 |
int prv_ntophits; |
| 1317 |
int64_t start_offset; |
| 1318 |
|
| 1319 |
|
| 1320 |
int best_pass = -1; |
| 1321 |
int pass_olap = -1; |
| 1322 |
|
| 1323 |
if (sq->n == 0) return eslOK; |
| 1324 |
|
| 1325 |
if ((! pli->do_edef) && (pli->do_one_cmpass || pli->do_one_cmpass_olap)) { |
| 1326 |
ESL_FAIL(eslEINVAL, pli->errbuf, "cm_Pipeline() entered with do_edef as FALSE but do_one_cmpass or do_one_cmpass_olap is TRUE, coding bug."); |
| 1327 |
} |
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
if(sq->start <= sq->end) { |
| 1338 |
have5term = (sq->start == 1) ? TRUE : FALSE; |
| 1339 |
have3term = (sq->end == sq->L) ? TRUE : FALSE; |
| 1340 |
} |
| 1341 |
else { |
| 1342 |
have5term = (sq->start == sq->L) ? TRUE : FALSE; |
| 1343 |
have3term = (sq->end == 1) ? TRUE : FALSE; |
| 1344 |
} |
| 1345 |
|
| 1346 |
#if eslDEBUGLEVEL >= 2 |
| 1347 |
printf("#DEBUG: \n#DEBUG: PIPELINE ENTRANCE %-15s %15s (n: %6" PRId64 " start: %6" PRId64 " end: %6" PRId64 " C: %6" PRId64 " W: %6" PRId64 " L: %6" PRId64 " have5term: %d have3term: %d)\n", |
| 1348 |
sq->name, om->name, sq->n, sq->start, sq->end, sq->C, sq->W, sq->L, have5term, have3term); |
| 1349 |
#endif |
| 1350 |
|
| 1351 |
|
| 1352 |
if(pli->do_edef) { |
| 1353 |
ESL_ALLOC(np7envA, sizeof(int) * NPLI_PASSES); |
| 1354 |
ESL_ALLOC(p7esAA, sizeof(int *) * NPLI_PASSES); |
| 1355 |
ESL_ALLOC(p7eeAA, sizeof(int *) * NPLI_PASSES); |
| 1356 |
ESL_ALLOC(p7ebAA, sizeof(float *) * NPLI_PASSES); |
| 1357 |
for(p = 0; p < NPLI_PASSES; p++) { |
| 1358 |
np7envA[p] = 0; |
| 1359 |
p7esAA[p] = NULL; |
| 1360 |
p7eeAA[p] = NULL; |
| 1361 |
p7ebAA[p] = NULL; |
| 1362 |
} |
| 1363 |
} |
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
if(pli->do_hmmonly_cur) { |
| 1372 |
do_pass_hmm_only_any = TRUE; |
| 1373 |
do_pass_std_any = do_pass_5p_only_force = do_pass_3p_only_force = do_pass_5p_and_3p_force = do_pass_5p_and_3p_any = FALSE; |
| 1374 |
} |
| 1375 |
else if(pli->do_trunc_ends) { |
| 1376 |
do_pass_std_any = TRUE; |
| 1377 |
do_pass_5p_only_force = have5term ? TRUE : FALSE; |
| 1378 |
do_pass_3p_only_force = have3term ? TRUE : FALSE; |
| 1379 |
do_pass_5p_and_3p_force = (have5term && have3term && sq->n <= pli->maxW) ? TRUE : FALSE; |
| 1380 |
do_pass_5p_and_3p_any = do_pass_hmm_only_any = FALSE; |
| 1381 |
} |
| 1382 |
else if(pli->do_trunc_5p_ends) { |
| 1383 |
do_pass_std_any = TRUE; |
| 1384 |
do_pass_5p_only_force = have5term ? TRUE : FALSE; |
| 1385 |
do_pass_3p_only_force = do_pass_5p_and_3p_force = do_pass_5p_and_3p_any = do_pass_hmm_only_any = FALSE; |
| 1386 |
} |
| 1387 |
else if(pli->do_trunc_3p_ends) { |
| 1388 |
do_pass_std_any = TRUE; |
| 1389 |
do_pass_3p_only_force = have3term ? TRUE : FALSE; |
| 1390 |
do_pass_5p_only_force = do_pass_5p_and_3p_force = do_pass_5p_and_3p_any = do_pass_hmm_only_any = FALSE; |
| 1391 |
} |
| 1392 |
else if(pli->do_trunc_any) { |
| 1393 |
do_pass_std_any = TRUE; |
| 1394 |
do_pass_5p_only_force = have5term ? TRUE : FALSE; |
| 1395 |
do_pass_3p_only_force = have3term ? TRUE : FALSE; |
| 1396 |
do_pass_5p_and_3p_force = (have5term && have3term && sq->n <= pli->maxW) ? TRUE : FALSE; |
| 1397 |
do_pass_5p_and_3p_any = TRUE; |
| 1398 |
do_pass_hmm_only_any = FALSE; |
| 1399 |
} |
| 1400 |
else if(pli->do_trunc_int) { |
| 1401 |
do_pass_std_any = TRUE; |
| 1402 |
do_pass_5p_and_3p_any = TRUE; |
| 1403 |
do_pass_5p_only_force = do_pass_3p_only_force = do_pass_5p_and_3p_force = do_pass_hmm_only_any = FALSE; |
| 1404 |
} |
| 1405 |
else if(pli->do_trunc_only) { |
| 1406 |
do_pass_5p_and_3p_any = TRUE; |
| 1407 |
do_pass_std_any = do_pass_5p_only_force = do_pass_3p_only_force = do_pass_5p_and_3p_force = do_pass_hmm_only_any = FALSE; |
| 1408 |
} |
| 1409 |
else { |
| 1410 |
do_pass_std_any = TRUE; |
| 1411 |
do_pass_5p_only_force = do_pass_3p_only_force = do_pass_5p_and_3p_force = do_pass_5p_and_3p_any = do_pass_hmm_only_any = FALSE; |
| 1412 |
} |
| 1413 |
|
| 1414 |
#if eslDEBUGLEVEL >= 1 |
| 1415 |
printf("#DEBUG: in cm_Pipeline() %s\n", sq->name); |
| 1416 |
printf("#DEBUG: do_pass_std_any: %d\n", do_pass_std_any); |
| 1417 |
printf("#DEBUG: do_pass_5p_only_force: %d\n", do_pass_5p_only_force); |
| 1418 |
printf("#DEBUG: do_pass_3p_only_force: %d\n", do_pass_3p_only_force); |
| 1419 |
printf("#DEBUG: do_pass_5p_and_3p_force: %d\n", do_pass_5p_and_3p_force); |
| 1420 |
printf("#DEBUG: do_pass_5p_and_3p_any: %d\n", do_pass_5p_and_3p_any); |
| 1421 |
printf("#DEBUG: do_pass_hmm_only_any: %d\n", do_pass_hmm_only_any); |
| 1422 |
#endif |
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 1429 |
if(p == PLI_PASS_STD_ANY && (! do_pass_std_any)) continue; |
| 1430 |
if(p == PLI_PASS_5P_ONLY_FORCE && (! do_pass_5p_only_force)) continue; |
| 1431 |
if(p == PLI_PASS_3P_ONLY_FORCE && (! do_pass_3p_only_force)) continue; |
| 1432 |
if(p == PLI_PASS_5P_AND_3P_FORCE && (! do_pass_5p_and_3p_force)) continue; |
| 1433 |
if(p == PLI_PASS_5P_AND_3P_ANY && (! do_pass_5p_and_3p_any)) continue; |
| 1434 |
if(p == PLI_PASS_HMM_ONLY_ANY && (! do_pass_hmm_only_any)) continue; |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
if(in_rc) pli->acct[p].npli_bot++; |
| 1443 |
else pli->acct[p].npli_top++; |
| 1444 |
if(p == PLI_PASS_STD_ANY || p == PLI_PASS_5P_AND_3P_ANY || p == PLI_PASS_HMM_ONLY_ANY) { |
| 1445 |
if(in_rc) pli->acct[p].nres_bot += sq->n; |
| 1446 |
else pli->acct[p].nres_top += sq->n; |
| 1447 |
} |
| 1448 |
else { |
| 1449 |
if(in_rc) pli->acct[p].nres_bot += ESL_MIN(pli->maxW, sq->n); |
| 1450 |
else pli->acct[p].nres_top += ESL_MIN(pli->maxW, sq->n); |
| 1451 |
} |
| 1452 |
|
| 1453 |
|
| 1454 |
if(p != PLI_PASS_STD_ANY && p != PLI_PASS_HMM_ONLY_ANY && nwin_pass_std_any == 0 && (! pli->do_max)) continue; |
| 1455 |
|
| 1456 |
|
| 1457 |
start_offset = 0; |
| 1458 |
if(p == PLI_PASS_STD_ANY || p == PLI_PASS_5P_AND_3P_FORCE || p == PLI_PASS_5P_AND_3P_ANY || p == PLI_PASS_HMM_ONLY_ANY || sq->n <= pli->maxW) { |
| 1459 |
sq2search = sq; |
| 1460 |
} |
| 1461 |
else if(p == PLI_PASS_5P_ONLY_FORCE) { |
| 1462 |
term5sq = esl_sq_CreateDigital(bg->abc); |
| 1463 |
pli_copy_subseq(sq, term5sq, 1, pli->maxW); |
| 1464 |
sq2search = term5sq; |
| 1465 |
} |
| 1466 |
else if(p == PLI_PASS_3P_ONLY_FORCE) { |
| 1467 |
term3sq = esl_sq_CreateDigital(bg->abc); |
| 1468 |
pli_copy_subseq(sq, term3sq, sq->n - pli->maxW + 1, pli->maxW); |
| 1469 |
sq2search = term3sq; |
| 1470 |
start_offset = sq->n - pli->maxW; |
| 1471 |
} |
| 1472 |
pli->cur_pass_idx = p; |
| 1473 |
|
| 1474 |
|
| 1475 |
if(p == PLI_PASS_HMM_ONLY_ANY) { |
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
#if eslDEBUGLEVEL >= 2 |
| 1482 |
printf("#DEBUG:\n#DEBUG: HMM ONLY PIPELINE calling p7_filter() %s %" PRId64 " residues (pass: %d)\n", sq2search->name, sq2search->n, p); |
| 1483 |
#endif |
| 1484 |
if((status = pli_p7_filter(pli, om, bg, p7_evparam, msvdata, sq2search, &ws, &we, &wb, &nwin)) != eslOK) return status; |
| 1485 |
if(pli->do_time_F1 || pli->do_time_F2 || pli->do_time_F3) return status; |
| 1486 |
prv_ntophits = hitlist->N; |
| 1487 |
|
| 1488 |
if(pli->do_trm_F3) { |
| 1489 |
for(h = 0; h < nwin; h++) { |
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
cm_tophits_CreateNextHit(hitlist, &hit); |
| 1495 |
hit->start = ws[h]; |
| 1496 |
hit->stop = we[h]; |
| 1497 |
hit->root = -1; |
| 1498 |
hit->mode = TRMODE_J; |
| 1499 |
hit->score = wb[h]; |
| 1500 |
|
| 1501 |
hit->cm_idx = pli->cur_cm_idx; |
| 1502 |
hit->clan_idx = pli->cur_clan_idx; |
| 1503 |
hit->seq_idx = pli->cur_seq_idx; |
| 1504 |
hit->pass_idx = pli->cur_pass_idx; |
| 1505 |
hit->pvalue = 0.; |
| 1506 |
hit->srcL = sq->L; |
| 1507 |
|
| 1508 |
hit->hmmonly = TRUE; |
| 1509 |
hit->glocal = FALSE; |
| 1510 |
hit->bias = 0.; |
| 1511 |
hit->evalue = 0.; |
| 1512 |
hit->has_evalue = FALSE; |
| 1513 |
hit->ad = NULL; |
| 1514 |
|
| 1515 |
if (pli->mode == CM_SEARCH_SEQS) { |
| 1516 |
if ( (status = esl_strdup(sq->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1517 |
if (sq->acc[0] != '\0' && (status = esl_strdup(sq->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1518 |
|
| 1519 |
if ((status = esl_strdup(om->name, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1520 |
} |
| 1521 |
else { |
| 1522 |
if ((status = esl_strdup(om->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1523 |
if ((status = esl_strdup(om->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1524 |
|
| 1525 |
if ((status = esl_strdup(sq->name, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 1526 |
} |
| 1527 |
} |
| 1528 |
} |
| 1529 |
else { |
| 1530 |
if((status = pli_final_stage_hmmonly(pli, cm_offset, om, bg, p7_evparam, sq2search, ws, we, nwin, hitlist, opt_cm)) != eslOK) return status; |
| 1531 |
} |
| 1532 |
} |
| 1533 |
else { |
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
if(pli->do_edef) { |
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
#if eslDEBUGLEVEL >= 2 |
| 1544 |
printf("#DEBUG:\n#DEBUG: PIPELINE calling p7_filter() %s %" PRId64 " residues (pass: %d)\n", sq2search->name, sq2search->n, p); |
| 1545 |
#endif |
| 1546 |
if((status = pli_p7_filter(pli, om, bg, p7_evparam, msvdata, sq2search, &ws, &we, &wb, &nwin)) != eslOK) return status; |
| 1547 |
if(p == PLI_PASS_STD_ANY) nwin_pass_std_any = nwin; |
| 1548 |
if(pli->do_time_F1 || pli->do_time_F2 || pli->do_time_F3) return status; |
| 1549 |
|
| 1550 |
#if eslDEBUGLEVEL >= 2 |
| 1551 |
printf("#DEBUG:\n#DEBUG: PIPELINE calling p7_env_def() %s %" PRId64 " residues (pass: %d)\n", sq2search->name, sq2search->n, p); |
| 1552 |
#endif |
| 1553 |
if((status = pli_p7_env_def(pli, om, bg, p7_evparam, sq2search, ws, we, nwin, opt_hmm, opt_gm, opt_Rgm, opt_Lgm, opt_Tgm, &(p7esAA[p]), &(p7eeAA[p]), &(p7ebAA[p]), &(np7envA[p]))) != eslOK) return status; |
| 1554 |
} |
| 1555 |
} |
| 1556 |
if(ws != NULL) { free(ws); ws = NULL; } |
| 1557 |
if(we != NULL) { free(we); we = NULL; } |
| 1558 |
if(wb != NULL) { free(wb); wb = NULL; } |
| 1559 |
nwin = 0; |
| 1560 |
} |
| 1561 |
|
| 1562 |
|
| 1563 |
if(pli->do_one_cmpass || pli->do_one_cmpass_olap) { |
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
best_pass = -1; |
| 1578 |
if(pli_check_one_or_zero_envelopes(np7envA)) { |
| 1579 |
best_pass = pli_get_pass_of_best_envelope(p7ebAA, np7envA); |
| 1580 |
} |
| 1581 |
if(best_pass != -1) { |
| 1582 |
|
| 1583 |
if(pli->do_one_cmpass) { |
| 1584 |
|
| 1585 |
if(! pli_check_full_length_envelopes(p7esAA, p7eeAA, np7envA, sq->L)) { |
| 1586 |
|
| 1587 |
best_pass = -1; |
| 1588 |
} |
| 1589 |
} |
| 1590 |
else if(pli->do_one_cmpass_olap) { |
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
if((status = pli_check_overlap_envelopes(p7esAA, p7eeAA, np7envA, best_pass, 0, |
| 1595 |
ESL_MAX(0, sq->n - pli->maxW), |
| 1596 |
0.5, |
| 1597 |
&pass_olap, pli->errbuf)) != eslOK) return status; |
| 1598 |
if(! pass_olap) { |
| 1599 |
|
| 1600 |
best_pass = -1; |
| 1601 |
} |
| 1602 |
} |
| 1603 |
} |
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
} |
| 1608 |
|
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 1613 |
if(pli->do_trm_F3) continue; |
| 1614 |
if(best_pass != -1 && p != best_pass) continue; |
| 1615 |
if(p == PLI_PASS_STD_ANY && (! do_pass_std_any)) continue; |
| 1616 |
if(p == PLI_PASS_5P_ONLY_FORCE && (! do_pass_5p_only_force)) continue; |
| 1617 |
if(p == PLI_PASS_3P_ONLY_FORCE && (! do_pass_3p_only_force)) continue; |
| 1618 |
if(p == PLI_PASS_5P_AND_3P_FORCE && (! do_pass_5p_and_3p_force)) continue; |
| 1619 |
if(p == PLI_PASS_5P_AND_3P_ANY && (! do_pass_5p_and_3p_any)) continue; |
| 1620 |
if(p == PLI_PASS_HMM_ONLY_ANY) continue; |
| 1621 |
|
| 1622 |
|
| 1623 |
if(p != PLI_PASS_STD_ANY && p != PLI_PASS_HMM_ONLY_ANY && nwin_pass_std_any == 0 && (! pli->do_max)) continue; |
| 1624 |
|
| 1625 |
|
| 1626 |
start_offset = 0; |
| 1627 |
if(p == PLI_PASS_STD_ANY || p == PLI_PASS_5P_AND_3P_FORCE || p == PLI_PASS_5P_AND_3P_ANY || p == PLI_PASS_HMM_ONLY_ANY || sq->n <= pli->maxW) { |
| 1628 |
sq2search = sq; |
| 1629 |
} |
| 1630 |
else if(p == PLI_PASS_5P_ONLY_FORCE) { |
| 1631 |
sq2search = term5sq; |
| 1632 |
} |
| 1633 |
else if(p == PLI_PASS_3P_ONLY_FORCE) { |
| 1634 |
sq2search = term3sq; |
| 1635 |
start_offset = sq->n - pli->maxW; |
| 1636 |
} |
| 1637 |
pli->cur_pass_idx = p; |
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
if(pli->do_edef) { |
| 1647 |
if(pli->do_fcyk) { |
| 1648 |
#if eslDEBUGLEVEL >= 2 |
| 1649 |
printf("#DEBUG:\n#DEBUG: PIPELINE calling pli_cyk_env_filter() %s %" PRId64 " residues (pass: %d)\n", sq2search->name, sq2search->n, p); |
| 1650 |
#endif |
| 1651 |
if((status = pli_cyk_env_filter(pli, cm_offset, sq2search, p7esAA[p], p7eeAA[p], np7envA[p], opt_cm, &es, &ee, &nenv)) != eslOK) return status; |
| 1652 |
if(pli->do_time_F4 || pli->do_time_F5) return status; |
| 1653 |
} |
| 1654 |
else { |
| 1655 |
ESL_ALLOC(es, sizeof(int64_t) * ESL_MAX(1, np7envA[p])); |
| 1656 |
ESL_ALLOC(ee, sizeof(int64_t) * ESL_MAX(1, np7envA[p])); |
| 1657 |
for(i = 0; i < np7envA[p]; i++) { es[i] = p7esAA[p][i]; ee[i] = p7eeAA[p][i]; } |
| 1658 |
nenv = np7envA[p]; |
| 1659 |
} |
| 1660 |
} |
| 1661 |
|
| 1662 |
else if((! pli->do_edef) && pli->do_fcyk) { |
| 1663 |
|
| 1664 |
#if eslDEBUGLEVEL >= 2 |
| 1665 |
printf("#DEBUG:\n#DEBUG: PIPELINE calling pli_cyk_seq_filter() %s %" PRId64 " residues (pass: %d)\n", sq2search->name, sq2search->n, p); |
| 1666 |
#endif |
| 1667 |
if((status = pli_cyk_seq_filter(pli, cm_offset, sq2search, opt_cm, &es, &ee, &nenv)) != eslOK) return status; |
| 1668 |
} |
| 1669 |
|
| 1670 |
else { |
| 1671 |
ESL_ALLOC(es, sizeof(int64_t) * 1); |
| 1672 |
ESL_ALLOC(ee, sizeof(int64_t) * 1); |
| 1673 |
nenv = 1; es[0] = 1; ee[0] = sq2search->n; |
| 1674 |
} |
| 1675 |
if(pli->do_time_F6) return status; |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
#if eslDEBUGLEVEL >= 2 |
| 1680 |
printf("#DEBUG:\n#DEBUG: PIPELINE calling FinalStage() %s %" PRId64 " residues model: %s (pass: %d) nhits: %" PRId64 "\n", sq2search->name, sq2search->n, om->name, p, hitlist->N); |
| 1681 |
#endif |
| 1682 |
prv_ntophits = hitlist->N; |
| 1683 |
if((status = pli_final_stage(pli, cm_offset, sq2search, es, ee, nenv, hitlist, opt_cm)) != eslOK) return status; |
| 1684 |
#if eslDEBUGLEVEL >= 2 |
| 1685 |
printf("#DEBUG\n#DEBUG: PIPELINE back from FinalStage() %s %" PRId64 " residues model: %s (pass: %d) nhits: %" PRId64 "\n", sq2search->name, sq2search->n, om->name, p, hitlist->N); |
| 1686 |
#endif |
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
if(hitlist->N > prv_ntophits) { |
| 1692 |
if(start_offset != 0) { |
| 1693 |
for(h = prv_ntophits; h < hitlist->N; h++) { |
| 1694 |
hitlist->unsrt[h].start += start_offset; |
| 1695 |
hitlist->unsrt[h].stop += start_offset; |
| 1696 |
if(hitlist->unsrt[h].ad != NULL) { |
| 1697 |
hitlist->unsrt[h].ad->sqfrom += start_offset; |
| 1698 |
hitlist->unsrt[h].ad->sqto += start_offset; |
| 1699 |
} |
| 1700 |
} |
| 1701 |
} |
| 1702 |
} |
| 1703 |
if(es != NULL) { free(es); es = NULL; } |
| 1704 |
if(ee != NULL) { free(ee); ee = NULL; } |
| 1705 |
nenv = 0; |
| 1706 |
} |
| 1707 |
|
| 1708 |
if(np7envA != NULL) free(np7envA); |
| 1709 |
for(p = 0; p < NPLI_PASSES; p++) { |
| 1710 |
if(p7esAA && p7esAA[p]) free(p7esAA[p]); |
| 1711 |
if(p7eeAA && p7eeAA[p]) free(p7eeAA[p]); |
| 1712 |
if(p7ebAA && p7ebAA[p]) free(p7ebAA[p]); |
| 1713 |
} |
| 1714 |
if(p7esAA) free(p7esAA); |
| 1715 |
if(p7eeAA) free(p7eeAA); |
| 1716 |
if(p7ebAA) free(p7ebAA); |
| 1717 |
|
| 1718 |
if(term5sq != NULL) esl_sq_Destroy(term5sq); |
| 1719 |
if(term3sq != NULL) esl_sq_Destroy(term3sq); |
| 1720 |
|
| 1721 |
return eslOK; |
| 1722 |
|
| 1723 |
ERROR: |
| 1724 |
ESL_FAIL(eslEMEM, pli->errbuf, "out of memory"); |
| 1725 |
} |
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
int |
| 1742 |
cm_pli_Statistics(FILE *ofp, CM_PIPELINE *pli, ESL_STOPWATCH *w) |
| 1743 |
{ |
| 1744 |
if(pli->nmodels > 0 && pli->be_verbose) { |
| 1745 |
if(! pli->do_trunc_only) { |
| 1746 |
pli_pass_statistics(ofp, pli, PLI_PASS_STD_ANY); fprintf(ofp, "\n"); |
| 1747 |
} |
| 1748 |
|
| 1749 |
|
| 1750 |
if(pli->do_trunc_ends) { |
| 1751 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1752 |
pli_pass_statistics(ofp, pli, PLI_PASS_3P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1753 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_AND_3P_FORCE); fprintf(ofp, "\n"); |
| 1754 |
} |
| 1755 |
else if(pli->do_trunc_any) { |
| 1756 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1757 |
pli_pass_statistics(ofp, pli, PLI_PASS_3P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1758 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_AND_3P_FORCE); fprintf(ofp, "\n"); |
| 1759 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_AND_3P_ANY); fprintf(ofp, "\n"); |
| 1760 |
} |
| 1761 |
else if(pli->do_trunc_5p_ends) { |
| 1762 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1763 |
} |
| 1764 |
else if(pli->do_trunc_3p_ends) { |
| 1765 |
pli_pass_statistics(ofp, pli, PLI_PASS_3P_ONLY_FORCE); fprintf(ofp, "\n"); |
| 1766 |
} |
| 1767 |
else if(pli->do_trunc_int || pli->do_trunc_only) { |
| 1768 |
pli_pass_statistics(ofp, pli, PLI_PASS_5P_AND_3P_ANY); fprintf(ofp, "\n"); |
| 1769 |
} |
| 1770 |
} |
| 1771 |
if(pli->nmodels_hmmonly > 0) { |
| 1772 |
pli_hmmonly_pass_statistics(ofp, pli); fprintf(ofp, "\n"); |
| 1773 |
} |
| 1774 |
if(pli->nmodels > 0) { |
| 1775 |
pli_sum_statistics(pli); |
| 1776 |
pli_pass_statistics(ofp, pli, PLI_PASS_CM_SUMMED); fprintf(ofp, "\n"); |
| 1777 |
} |
| 1778 |
if(pli->nmodels > 0 && pli->nmodels_hmmonly > 0) { |
| 1779 |
fprintf(ofp, "Total CM and HMM hits reported: %15d\n\n", |
| 1780 |
(int) (pli->acct[PLI_PASS_CM_SUMMED].n_output) + |
| 1781 |
(int) (pli->acct[PLI_PASS_HMM_ONLY_ANY].n_output)); |
| 1782 |
} |
| 1783 |
if(w != NULL) esl_stopwatch_Display(ofp, w, "# CPU time: "); |
| 1784 |
|
| 1785 |
return eslOK; |
| 1786 |
} |
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
int |
| 1799 |
pli_pass_statistics(FILE *ofp, CM_PIPELINE *pli, int pass_idx) |
| 1800 |
{ |
| 1801 |
int64_t nwin_fcyk = 0; |
| 1802 |
int64_t nwin_final = 0; |
| 1803 |
int64_t n_output_trunc; |
| 1804 |
int64_t pos_output_trunc; |
| 1805 |
int64_t nres_searched = 0; |
| 1806 |
int64_t nres_researched = 0; |
| 1807 |
|
| 1808 |
CM_PLI_ACCT *pli_acct = &(pli->acct[pass_idx]); |
| 1809 |
|
| 1810 |
|
| 1811 |
nres_searched = pli_acct->nres_top + pli_acct->nres_bot; |
| 1812 |
switch(pass_idx) { |
| 1813 |
case PLI_PASS_CM_SUMMED: |
| 1814 |
nres_researched = (pli_acct->nres_top + pli->acct->nres_bot) - (pli->acct[PLI_PASS_STD_ANY].nres_top + pli->acct[PLI_PASS_STD_ANY].nres_bot); |
| 1815 |
break; |
| 1816 |
case PLI_PASS_STD_ANY: |
| 1817 |
nres_researched = 0; |
| 1818 |
break; |
| 1819 |
case PLI_PASS_5P_ONLY_FORCE: |
| 1820 |
case PLI_PASS_3P_ONLY_FORCE: |
| 1821 |
case PLI_PASS_5P_AND_3P_FORCE: |
| 1822 |
case PLI_PASS_5P_AND_3P_ANY: |
| 1823 |
nres_researched = pli_acct->nres_top + pli_acct->nres_bot; |
| 1824 |
break; |
| 1825 |
default: |
| 1826 |
nres_researched = 0; |
| 1827 |
break; |
| 1828 |
} |
| 1829 |
|
| 1830 |
if(pli->be_verbose) { |
| 1831 |
fprintf(ofp, "Internal CM pipeline statistics summary: %s\n", pli_describe_pass(pass_idx)); |
| 1832 |
} |
| 1833 |
else { |
| 1834 |
fprintf(ofp, "Internal CM pipeline statistics summary:\n"); |
| 1835 |
} |
| 1836 |
fprintf(ofp, "----------------------------------------\n"); |
| 1837 |
if (pli->mode == CM_SEARCH_SEQS) { |
| 1838 |
fprintf(ofp, "Query model(s): %15" PRId64 " (%" PRId64 " consensus positions)\n", |
| 1839 |
pli->nmodels, pli->nnodes); |
| 1840 |
if(pass_idx == PLI_PASS_STD_ANY || pass_idx == PLI_PASS_CM_SUMMED) { |
| 1841 |
fprintf(ofp, "Target sequences: %15" PRId64 " (%" PRId64 " residues searched)\n", |
| 1842 |
pli->nseqs, nres_searched - nres_researched); |
| 1843 |
} |
| 1844 |
if(pass_idx != PLI_PASS_STD_ANY) { |
| 1845 |
if(pass_idx == PLI_PASS_5P_AND_3P_FORCE) { |
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
fprintf(ofp, "Target sequences re-searched for truncated hits: %15" PRId64 " (%" PRId64 " residues re-searched)\n", |
| 1853 |
(pli->do_trunc_ends) ? ESL_MAX(pli_acct->npli_top, pli_acct->npli_bot) : 0, |
| 1854 |
nres_researched); |
| 1855 |
} |
| 1856 |
else { |
| 1857 |
if(pli->do_trunc_only) { |
| 1858 |
fprintf(ofp, "Target sequences searched for truncated hits: %15" PRId64 " (%" PRId64 " residues searched)\n", |
| 1859 |
pli->nseqs, nres_researched); |
| 1860 |
} |
| 1861 |
else { |
| 1862 |
fprintf(ofp, "Target sequences re-searched for truncated hits: %15" PRId64 " (%" PRId64 " residues re-searched)\n", |
| 1863 |
(pli->do_trunc_ends || pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_5p_ends || pli->do_trunc_3p_ends) ? pli->nseqs : 0, |
| 1864 |
nres_researched); |
| 1865 |
} |
| 1866 |
} |
| 1867 |
} |
| 1868 |
} else { |
| 1869 |
if(pass_idx == PLI_PASS_STD_ANY || pass_idx == PLI_PASS_CM_SUMMED) { |
| 1870 |
fprintf(ofp, "Query sequence(s): %15" PRId64 " (%d residues searched)\n", |
| 1871 |
pli->nseqs, (int) ((nres_searched - nres_researched) / pli->nmodels)); |
| 1872 |
} |
| 1873 |
if(pass_idx != PLI_PASS_STD_ANY) { |
| 1874 |
if(pass_idx == PLI_PASS_5P_AND_3P_FORCE) { |
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
fprintf(ofp, "Query sequences re-searched for truncated hits: %15" PRId64 " (%.1f residues re-searched, avg per model)\n", |
| 1883 |
(pli_acct->npli_top > 0 || pli_acct->npli_bot > 0) ? pli->nseqs : 0, |
| 1884 |
(pli_acct->npli_top > 0 || pli_acct->npli_bot > 0) ? (float) nres_researched / (float) (ESL_MAX(pli_acct->npli_top, pli_acct->npli_bot)) : 0.); |
| 1885 |
} |
| 1886 |
else { |
| 1887 |
if(pli->do_trunc_only) { |
| 1888 |
fprintf(ofp, "Query sequences searched for truncated hits: %15" PRId64 " (%.1f residues searched, avg per model)\n", |
| 1889 |
pli->nseqs, (float) nres_researched / (float) pli->nmodels); |
| 1890 |
} |
| 1891 |
else { |
| 1892 |
fprintf(ofp, "Query sequences re-searched for truncated hits: %15" PRId64 " (%.1f residues re-searched, avg per model)\n", |
| 1893 |
(pli->do_trunc_ends || pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_5p_ends || pli->do_trunc_3p_ends) ? pli->nseqs : 0, |
| 1894 |
(float) nres_researched / (float) pli->nmodels); |
| 1895 |
} |
| 1896 |
} |
| 1897 |
} |
| 1898 |
if(pass_idx == PLI_PASS_5P_AND_3P_FORCE) { |
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
|
| 1905 |
fprintf(ofp, "Target model(s): %15" PRId64 "\n", |
| 1906 |
ESL_MAX(pli_acct->npli_top, pli_acct->npli_bot)); |
| 1907 |
} |
| 1908 |
else { |
| 1909 |
fprintf(ofp, "Target model(s): %15" PRId64 " (%" PRId64 " consensus positions)\n", |
| 1910 |
pli->nmodels, pli->nnodes); |
| 1911 |
} |
| 1912 |
} |
| 1913 |
|
| 1914 |
if(pli->do_msv) { |
| 1915 |
fprintf(ofp, "Windows passing local HMM SSV filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1916 |
pli_acct->n_past_msv, |
| 1917 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_msv / nres_searched, |
| 1918 |
pli->F1); |
| 1919 |
nwin_fcyk = nwin_final = pli_acct->n_past_msv; |
| 1920 |
} |
| 1921 |
else { |
| 1922 |
fprintf(ofp, "Windows passing local HMM SSV filter: %15s (off)\n", ""); |
| 1923 |
} |
| 1924 |
|
| 1925 |
if(pli->do_msvbias) { |
| 1926 |
fprintf(ofp, "Windows passing local HMM MSV bias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1927 |
pli_acct->n_past_msvbias, |
| 1928 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_msvbias / nres_searched, |
| 1929 |
pli->F1b); |
| 1930 |
nwin_fcyk = nwin_final = pli_acct->n_past_msvbias; |
| 1931 |
} |
| 1932 |
|
| 1933 |
|
| 1934 |
if(pli->do_vit) { |
| 1935 |
fprintf(ofp, "Windows passing local HMM Viterbi filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1936 |
pli_acct->n_past_vit, |
| 1937 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_vit / nres_searched, |
| 1938 |
pli->F2); |
| 1939 |
nwin_fcyk = nwin_final = pli_acct->n_past_vit; |
| 1940 |
} |
| 1941 |
else { |
| 1942 |
fprintf(ofp, "Windows passing local HMM Viterbi filter: %15s (off)\n", ""); |
| 1943 |
} |
| 1944 |
|
| 1945 |
if(pli->do_vitbias) { |
| 1946 |
fprintf(ofp, "Windows passing local HMM Viterbi bias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1947 |
pli_acct->n_past_vitbias, |
| 1948 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_vitbias / nres_searched, |
| 1949 |
pli->F2b); |
| 1950 |
nwin_fcyk = nwin_final = pli_acct->n_past_vitbias; |
| 1951 |
} |
| 1952 |
else { |
| 1953 |
fprintf(ofp, "Windows passing local HMM Viterbi bias filter: %15s (off)\n", ""); |
| 1954 |
} |
| 1955 |
|
| 1956 |
if(pli->do_fwd) { |
| 1957 |
fprintf(ofp, "Windows passing local HMM Forward filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1958 |
pli_acct->n_past_fwd, |
| 1959 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_fwd / nres_searched, |
| 1960 |
pli->F3); |
| 1961 |
nwin_fcyk = nwin_final = pli_acct->n_past_fwd; |
| 1962 |
} |
| 1963 |
else { |
| 1964 |
fprintf(ofp, "Windows passing local HMM Forward filter: %15s (off)\n", ""); |
| 1965 |
} |
| 1966 |
|
| 1967 |
if(pli->do_fwdbias) { |
| 1968 |
fprintf(ofp, "Windows passing local HMM Forward bias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1969 |
pli_acct->n_past_fwdbias, |
| 1970 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_fwdbias / nres_searched, |
| 1971 |
pli->F3b); |
| 1972 |
nwin_fcyk = nwin_final = pli_acct->n_past_fwdbias; |
| 1973 |
} |
| 1974 |
else { |
| 1975 |
fprintf(ofp, "Windows passing local HMM Forward bias filter: %15s (off)\n", ""); |
| 1976 |
} |
| 1977 |
|
| 1978 |
if(pli->do_gfwd) { |
| 1979 |
fprintf(ofp, "Windows passing glocal HMM Forward filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1980 |
pli_acct->n_past_gfwd, |
| 1981 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_gfwd / nres_searched, |
| 1982 |
pli->F4); |
| 1983 |
nwin_fcyk = nwin_final = pli_acct->n_past_gfwd; |
| 1984 |
} |
| 1985 |
else { |
| 1986 |
fprintf(ofp, "Windows passing glocal HMM Forward filter: %15s (off)\n", ""); |
| 1987 |
} |
| 1988 |
if(pli->do_gfwdbias) { |
| 1989 |
fprintf(ofp, "Windows passing glocal HMM Forward bias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 1990 |
pli_acct->n_past_gfwdbias, |
| 1991 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_gfwdbias / nres_searched, |
| 1992 |
pli->F4b); |
| 1993 |
nwin_fcyk = nwin_final = pli_acct->n_past_gfwdbias; |
| 1994 |
} |
| 1995 |
else { |
| 1996 |
fprintf(ofp, "Windows passing glocal HMM Forward bias filter: %15s (off)\n", ""); |
| 1997 |
} |
| 1998 |
|
| 1999 |
if(pli->do_edef) { |
| 2000 |
fprintf(ofp, "Envelopes passing glocal HMM envelope defn filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2001 |
pli_acct->n_past_edef, |
| 2002 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_edef / nres_searched, |
| 2003 |
pli->F5); |
| 2004 |
nwin_fcyk = nwin_final = pli_acct->n_past_edef; |
| 2005 |
} |
| 2006 |
else { |
| 2007 |
fprintf(ofp, "Envelopes passing glocal HMM envelope defn filter: %15s (off)\n", ""); |
| 2008 |
} |
| 2009 |
|
| 2010 |
if(pli->do_edefbias) { |
| 2011 |
fprintf(ofp, "Envelopes passing glocal HMM envelope bias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2012 |
pli_acct->n_past_edefbias, |
| 2013 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_edefbias / nres_searched, |
| 2014 |
pli->F5b); |
| 2015 |
nwin_fcyk = nwin_final = pli_acct->n_past_edefbias; |
| 2016 |
} |
| 2017 |
|
| 2018 |
|
| 2019 |
if(pli->do_fcyk) { |
| 2020 |
fprintf(ofp, "Envelopes passing %6s CM CYK filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2021 |
(pli->do_glocal_cm_always || pli->do_glocal_cm_sometimes) ? ((pli->do_glocal_cm_always) ? "glocal" : "") : "local", |
| 2022 |
pli_acct->n_past_cyk, |
| 2023 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_cyk / nres_searched, |
| 2024 |
pli->F6); |
| 2025 |
nwin_final = pli_acct->n_past_cyk; |
| 2026 |
} |
| 2027 |
else { |
| 2028 |
fprintf(ofp, "Envelopes passing %6s CM CYK filter: %15s (off)\n", |
| 2029 |
(pli->do_glocal_cm_always || pli->do_glocal_cm_sometimes) ? ((pli->do_glocal_cm_always) ? "glocal" : "") : "local", |
| 2030 |
""); |
| 2031 |
} |
| 2032 |
|
| 2033 |
if(pass_idx == PLI_PASS_CM_SUMMED) { |
| 2034 |
if(pli->do_trunc_ends) { |
| 2035 |
n_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].n_output + pli->acct[PLI_PASS_3P_ONLY_FORCE].n_output + pli->acct[PLI_PASS_5P_AND_3P_FORCE].n_output; |
| 2036 |
pos_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].pos_output + pli->acct[PLI_PASS_3P_ONLY_FORCE].pos_output + pli->acct[PLI_PASS_5P_AND_3P_FORCE].pos_output; |
| 2037 |
} |
| 2038 |
else if(pli->do_trunc_any) { |
| 2039 |
n_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].n_output + pli->acct[PLI_PASS_3P_ONLY_FORCE].n_output + pli->acct[PLI_PASS_5P_AND_3P_FORCE].n_output + pli->acct[PLI_PASS_5P_AND_3P_ANY].n_output; |
| 2040 |
pos_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].pos_output + pli->acct[PLI_PASS_3P_ONLY_FORCE].pos_output + pli->acct[PLI_PASS_5P_AND_3P_FORCE].pos_output + pli->acct[PLI_PASS_5P_AND_3P_ANY].pos_output; |
| 2041 |
} |
| 2042 |
else if(pli->do_trunc_5p_ends) { |
| 2043 |
n_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].n_output; |
| 2044 |
pos_output_trunc = pli->acct[PLI_PASS_5P_ONLY_FORCE].pos_output; |
| 2045 |
} |
| 2046 |
else if(pli->do_trunc_3p_ends) { |
| 2047 |
n_output_trunc = pli->acct[PLI_PASS_3P_ONLY_FORCE].n_output; |
| 2048 |
pos_output_trunc = pli->acct[PLI_PASS_3P_ONLY_FORCE].pos_output; |
| 2049 |
} |
| 2050 |
else if(pli->do_trunc_int || pli->do_trunc_only) { |
| 2051 |
n_output_trunc = pli->acct[PLI_PASS_5P_AND_3P_ANY].n_output; |
| 2052 |
pos_output_trunc = pli->acct[PLI_PASS_5P_AND_3P_ANY].pos_output; |
| 2053 |
} |
| 2054 |
else { |
| 2055 |
n_output_trunc = 0; |
| 2056 |
pos_output_trunc = 0; |
| 2057 |
} |
| 2058 |
fprintf(ofp, "Total CM hits reported: %15d (%.4g); includes %d truncated hit(s)\n", |
| 2059 |
(int) pli_acct->n_output, |
| 2060 |
(nres_searched == 0) ? 0.0 : (double) (pli_acct->pos_output + pos_output_trunc) / nres_searched, |
| 2061 |
(int) n_output_trunc); |
| 2062 |
} |
| 2063 |
else { |
| 2064 |
fprintf(ofp, "Total %37s %15d (%.4g)\n", |
| 2065 |
(pli->be_verbose) ? pli_describe_hits_for_pass(pass_idx) : "", |
| 2066 |
(int) pli_acct->n_output, |
| 2067 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_output / nres_searched); |
| 2068 |
} |
| 2069 |
|
| 2070 |
|
| 2071 |
if(pli->be_verbose) { |
| 2072 |
fprintf(ofp, "\n"); |
| 2073 |
if(nwin_fcyk > 0) { |
| 2074 |
fprintf(ofp, "%-6s filter stage scan matrix overflows: %15" PRId64 " (%.4g)\n", |
| 2075 |
"CYK", |
| 2076 |
pli_acct->n_overflow_fcyk, |
| 2077 |
(double) pli_acct->n_overflow_fcyk / (double) nwin_fcyk); |
| 2078 |
} |
| 2079 |
else { |
| 2080 |
fprintf(ofp, "%-6s filter stage scan matrix overflows: %15d (%.4g)\n", |
| 2081 |
"CYK", |
| 2082 |
0, 0.); |
| 2083 |
} |
| 2084 |
if(nwin_final > 0) { |
| 2085 |
fprintf(ofp, "%-6s final stage scan matrix overflows: %15" PRId64 " (%.4g)\n", |
| 2086 |
(pli->final_cm_search_opts & CM_SEARCH_INSIDE) ? "Inside" : "CYK", |
| 2087 |
pli_acct->n_overflow_final, |
| 2088 |
(double) pli_acct->n_overflow_final / (double) nwin_final); |
| 2089 |
} |
| 2090 |
else { |
| 2091 |
fprintf(ofp, "%-6s final stage scan matrix overflows: %15d (%.4g)\n", |
| 2092 |
(pli->final_cm_search_opts & CM_SEARCH_INSIDE) ? "Inside" : "CYK", |
| 2093 |
0, 0.); |
| 2094 |
} |
| 2095 |
} |
| 2096 |
|
| 2097 |
return eslOK; |
| 2098 |
} |
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
|
| 2105 |
|
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
int |
| 2112 |
pli_hmmonly_pass_statistics(FILE *ofp, CM_PIPELINE *pli) |
| 2113 |
{ |
| 2114 |
CM_PLI_ACCT *pli_acct = &(pli->acct[PLI_PASS_HMM_ONLY_ANY]); |
| 2115 |
int match_cm_spacing = (pli->nmodels > 0) ? TRUE : FALSE; |
| 2116 |
int64_t nres_searched = pli_acct->nres_top + pli_acct->nres_bot; |
| 2117 |
|
| 2118 |
if(pli->do_hmmonly_always) { |
| 2119 |
fprintf(ofp, "Internal HMM-only pipeline statistics summary: (--hmmonly used)\n"); |
| 2120 |
fprintf(ofp, "---------------------------------------------------------------\n"); |
| 2121 |
} |
| 2122 |
else { |
| 2123 |
fprintf(ofp, "Internal HMM-only pipeline statistics summary: (run for model(s) with zero basepairs)\n"); |
| 2124 |
fprintf(ofp, "--------------------------------------------------------------------------------------\n"); |
| 2125 |
} |
| 2126 |
|
| 2127 |
if (pli->mode == CM_SEARCH_SEQS) { |
| 2128 |
fprintf(ofp, "Query model(s): %s%15" PRId64 " (%" PRId64 " consensus positions)\n", |
| 2129 |
match_cm_spacing ? " " : "", |
| 2130 |
pli->nmodels_hmmonly, pli->nnodes_hmmonly); |
| 2131 |
fprintf(ofp, "Target sequences: %s%15" PRId64 " (%" PRId64 " residues searched)\n", |
| 2132 |
match_cm_spacing ? " " : "", |
| 2133 |
pli->nseqs, nres_searched); |
| 2134 |
} else { |
| 2135 |
fprintf(ofp, "Query sequence(s): %s%15" PRId64 " (%d residues searched)\n", |
| 2136 |
match_cm_spacing ? " " : "", |
| 2137 |
pli->nseqs, (int) (nres_searched / pli->nmodels_hmmonly)); |
| 2138 |
fprintf(ofp, "Target model(s): %s%15" PRId64 " (%" PRId64 " consensus positions)\n", |
| 2139 |
match_cm_spacing ? " " : "", |
| 2140 |
pli->nmodels_hmmonly, pli->nnodes_hmmonly); |
| 2141 |
} |
| 2142 |
|
| 2143 |
fprintf(ofp, "Windows %spassing %slocal HMM SSV %sfilter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2144 |
match_cm_spacing ? " " : "", |
| 2145 |
match_cm_spacing ? " " : "", |
| 2146 |
match_cm_spacing ? " " : "", |
| 2147 |
pli_acct->n_past_msv, |
| 2148 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_msv / nres_searched, |
| 2149 |
pli->F1_hmmonly); |
| 2150 |
|
| 2151 |
if(pli->do_bias_hmmonly) { |
| 2152 |
fprintf(ofp, "Windows %spassing %slocal HMM MSV %sbias filter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2153 |
match_cm_spacing ? " " : "", |
| 2154 |
match_cm_spacing ? " " : "", |
| 2155 |
match_cm_spacing ? " " : "", |
| 2156 |
pli_acct->n_past_msvbias, |
| 2157 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_msvbias / nres_searched, |
| 2158 |
pli->F1_hmmonly); |
| 2159 |
} |
| 2160 |
else { |
| 2161 |
fprintf(ofp, "Windows %spassing %slocal HMM MSV %sbias filter: %15s (off)\n", |
| 2162 |
match_cm_spacing ? " " : "", |
| 2163 |
match_cm_spacing ? " " : "", |
| 2164 |
match_cm_spacing ? " " : "", |
| 2165 |
""); |
| 2166 |
} |
| 2167 |
|
| 2168 |
if(! pli->do_max_hmmonly) { |
| 2169 |
fprintf(ofp, "Windows %spassing %slocal HMM Viterbi %sfilter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2170 |
match_cm_spacing ? " " : "", |
| 2171 |
match_cm_spacing ? " " : "", |
| 2172 |
match_cm_spacing ? " " : "", |
| 2173 |
pli_acct->n_past_vit, |
| 2174 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_vit / nres_searched, |
| 2175 |
pli->F2_hmmonly); |
| 2176 |
} |
| 2177 |
else { |
| 2178 |
fprintf(ofp, "Windows %spassing %slocal HMM Viterbi %sfilter: %15s (off)\n", |
| 2179 |
match_cm_spacing ? " " : "", |
| 2180 |
match_cm_spacing ? " " : "", |
| 2181 |
match_cm_spacing ? " " : "", |
| 2182 |
""); |
| 2183 |
} |
| 2184 |
|
| 2185 |
if(! pli->do_max_hmmonly) { |
| 2186 |
fprintf(ofp, "Windows %spassing %slocal HMM Forward %sfilter: %15" PRId64 " (%.4g); expected (%.4g)\n", |
| 2187 |
match_cm_spacing ? " " : "", |
| 2188 |
match_cm_spacing ? " " : "", |
| 2189 |
match_cm_spacing ? " " : "", |
| 2190 |
pli_acct->n_past_fwd, |
| 2191 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_past_fwd / nres_searched, |
| 2192 |
pli->F3_hmmonly); |
| 2193 |
} |
| 2194 |
else { |
| 2195 |
fprintf(ofp, "Windows %spassing %slocal HMM Forward %sfilter: %15s (off)\n", |
| 2196 |
match_cm_spacing ? " " : "", |
| 2197 |
match_cm_spacing ? " " : "", |
| 2198 |
match_cm_spacing ? " " : "", |
| 2199 |
""); |
| 2200 |
} |
| 2201 |
|
| 2202 |
fprintf(ofp, "Total HMM hits reported: %s%15d (%.4g)\n", |
| 2203 |
match_cm_spacing ? " " : "", |
| 2204 |
(int) pli_acct->n_output, |
| 2205 |
(nres_searched == 0) ? 0.0 : (double) pli_acct->pos_output / nres_searched); |
| 2206 |
|
| 2207 |
return eslOK; |
| 2208 |
} |
| 2209 |
|
| 2210 |
|
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
|
| 2219 |
int |
| 2220 |
pli_sum_statistics(CM_PIPELINE *pli) |
| 2221 |
{ |
| 2222 |
int p; |
| 2223 |
|
| 2224 |
|
| 2225 |
cm_pli_ZeroAccounting(&(pli->acct[PLI_PASS_CM_SUMMED])); |
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
for(p = 1; p < NPLI_PASSES; p++) { |
| 2232 |
if(p == PLI_PASS_HMM_ONLY_ANY) continue; |
| 2233 |
if(pli->acct[p].nres_top > 0 || pli->acct[p].nres_bot > 0) { |
| 2234 |
pli->acct[PLI_PASS_CM_SUMMED].npli_top += pli->acct[p].npli_top; |
| 2235 |
pli->acct[PLI_PASS_CM_SUMMED].npli_bot += pli->acct[p].npli_bot; |
| 2236 |
pli->acct[PLI_PASS_CM_SUMMED].nres_top += pli->acct[p].nres_top; |
| 2237 |
pli->acct[PLI_PASS_CM_SUMMED].nres_bot += pli->acct[p].nres_bot; |
| 2238 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_msv += pli->acct[p].n_past_msv; |
| 2239 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_vit += pli->acct[p].n_past_vit; |
| 2240 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_fwd += pli->acct[p].n_past_fwd; |
| 2241 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_gfwd += pli->acct[p].n_past_gfwd; |
| 2242 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_edef += pli->acct[p].n_past_edef; |
| 2243 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_cyk += pli->acct[p].n_past_cyk; |
| 2244 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_ins += pli->acct[p].n_past_ins; |
| 2245 |
pli->acct[PLI_PASS_CM_SUMMED].n_output += pli->acct[p].n_output; |
| 2246 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_msvbias += pli->acct[p].n_past_msvbias; |
| 2247 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_vitbias += pli->acct[p].n_past_vitbias; |
| 2248 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_fwdbias += pli->acct[p].n_past_fwdbias; |
| 2249 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_gfwdbias += pli->acct[p].n_past_gfwdbias; |
| 2250 |
pli->acct[PLI_PASS_CM_SUMMED].n_past_edefbias += pli->acct[p].n_past_edefbias; |
| 2251 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_msv += pli->acct[p].pos_past_msv; |
| 2252 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_vit += pli->acct[p].pos_past_vit; |
| 2253 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_fwd += pli->acct[p].pos_past_fwd; |
| 2254 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_gfwd += pli->acct[p].pos_past_gfwd; |
| 2255 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_edef += pli->acct[p].pos_past_edef; |
| 2256 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_cyk += pli->acct[p].pos_past_cyk; |
| 2257 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_ins += pli->acct[p].pos_past_ins; |
| 2258 |
pli->acct[PLI_PASS_CM_SUMMED].pos_output += pli->acct[p].pos_output; |
| 2259 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_msvbias += pli->acct[p].pos_past_msvbias; |
| 2260 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_vitbias += pli->acct[p].pos_past_vitbias; |
| 2261 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_fwdbias += pli->acct[p].pos_past_fwdbias; |
| 2262 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_gfwdbias += pli->acct[p].pos_past_gfwdbias; |
| 2263 |
pli->acct[PLI_PASS_CM_SUMMED].pos_past_edefbias += pli->acct[p].pos_past_edefbias; |
| 2264 |
|
| 2265 |
pli->acct[PLI_PASS_CM_SUMMED].n_overflow_fcyk += pli->acct[p].n_overflow_fcyk; |
| 2266 |
pli->acct[PLI_PASS_CM_SUMMED].n_overflow_final += pli->acct[p].n_overflow_final; |
| 2267 |
pli->acct[PLI_PASS_CM_SUMMED].n_aln_hb += pli->acct[p].n_aln_hb; |
| 2268 |
pli->acct[PLI_PASS_CM_SUMMED].n_aln_dccyk += pli->acct[p].n_aln_dccyk; |
| 2269 |
} |
| 2270 |
} |
| 2271 |
return eslOK; |
| 2272 |
} |
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
|
| 2277 |
|
| 2278 |
|
| 2279 |
|
| 2280 |
int |
| 2281 |
cm_pli_ZeroAccounting(CM_PLI_ACCT *pli_acct) |
| 2282 |
{ |
| 2283 |
pli_acct->npli_top = 0; |
| 2284 |
pli_acct->npli_bot = 0; |
| 2285 |
pli_acct->nres_top = 0; |
| 2286 |
pli_acct->nres_bot = 0; |
| 2287 |
pli_acct->n_past_msv = 0; |
| 2288 |
pli_acct->n_past_vit = 0; |
| 2289 |
pli_acct->n_past_fwd = 0; |
| 2290 |
pli_acct->n_past_gfwd = 0; |
| 2291 |
pli_acct->n_past_edef = 0; |
| 2292 |
pli_acct->n_past_cyk = 0; |
| 2293 |
pli_acct->n_past_ins = 0; |
| 2294 |
pli_acct->n_output = 0; |
| 2295 |
pli_acct->n_past_msvbias = 0; |
| 2296 |
pli_acct->n_past_vitbias = 0; |
| 2297 |
pli_acct->n_past_fwdbias = 0; |
| 2298 |
pli_acct->n_past_gfwdbias = 0; |
| 2299 |
pli_acct->n_past_edefbias = 0; |
| 2300 |
pli_acct->pos_past_msv = 0; |
| 2301 |
pli_acct->pos_past_vit = 0; |
| 2302 |
pli_acct->pos_past_fwd = 0; |
| 2303 |
pli_acct->pos_past_gfwd = 0; |
| 2304 |
pli_acct->pos_past_edef = 0; |
| 2305 |
pli_acct->pos_past_cyk = 0; |
| 2306 |
pli_acct->pos_past_ins = 0; |
| 2307 |
pli_acct->pos_output = 0; |
| 2308 |
pli_acct->pos_past_msvbias = 0; |
| 2309 |
pli_acct->pos_past_vitbias = 0; |
| 2310 |
pli_acct->pos_past_fwdbias = 0; |
| 2311 |
pli_acct->pos_past_gfwdbias = 0; |
| 2312 |
pli_acct->pos_past_edefbias = 0; |
| 2313 |
|
| 2314 |
pli_acct->n_overflow_fcyk = 0; |
| 2315 |
pli_acct->n_overflow_final = 0; |
| 2316 |
pli_acct->n_aln_hb = 0; |
| 2317 |
pli_acct->n_aln_dccyk = 0; |
| 2318 |
|
| 2319 |
return eslOK; |
| 2320 |
} |
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
|
| 2332 |
|
| 2333 |
|
| 2334 |
|
| 2335 |
|
| 2336 |
int |
| 2337 |
cm_pli_PassEnforcesFirstRes(int pass_idx) |
| 2338 |
{ |
| 2339 |
switch (pass_idx) { |
| 2340 |
case PLI_PASS_STD_ANY: return FALSE; break; |
| 2341 |
case PLI_PASS_5P_ONLY_FORCE: return TRUE; break; |
| 2342 |
case PLI_PASS_3P_ONLY_FORCE: return FALSE; break; |
| 2343 |
case PLI_PASS_5P_AND_3P_FORCE: return TRUE; break; |
| 2344 |
case PLI_PASS_5P_AND_3P_ANY: return FALSE; break; |
| 2345 |
case PLI_PASS_HMM_ONLY_ANY: return FALSE; break; |
| 2346 |
default: return FALSE; break; |
| 2347 |
} |
| 2348 |
return FALSE; |
| 2349 |
} |
| 2350 |
|
| 2351 |
|
| 2352 |
|
| 2353 |
|
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
|
| 2358 |
|
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
int |
| 2366 |
cm_pli_PassEnforcesFinalRes(int pass_idx) |
| 2367 |
{ |
| 2368 |
switch (pass_idx) { |
| 2369 |
case PLI_PASS_STD_ANY: return FALSE; break; |
| 2370 |
case PLI_PASS_5P_ONLY_FORCE: return FALSE; break; |
| 2371 |
case PLI_PASS_3P_ONLY_FORCE: return TRUE; break; |
| 2372 |
case PLI_PASS_5P_AND_3P_FORCE: return TRUE; break; |
| 2373 |
case PLI_PASS_5P_AND_3P_ANY: return FALSE; break; |
| 2374 |
case PLI_PASS_HMM_ONLY_ANY: return FALSE; break; |
| 2375 |
default: return FALSE; break; |
| 2376 |
} |
| 2377 |
return FALSE; |
| 2378 |
} |
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
|
| 2389 |
|
| 2390 |
|
| 2391 |
|
| 2392 |
|
| 2393 |
|
| 2394 |
|
| 2395 |
int |
| 2396 |
cm_pli_PassAllowsTruncation(int pass_idx) |
| 2397 |
{ |
| 2398 |
switch (pass_idx) { |
| 2399 |
case PLI_PASS_STD_ANY: return FALSE; break; |
| 2400 |
case PLI_PASS_5P_ONLY_FORCE: return TRUE; break; |
| 2401 |
case PLI_PASS_3P_ONLY_FORCE: return TRUE; break; |
| 2402 |
case PLI_PASS_5P_AND_3P_FORCE: return TRUE; break; |
| 2403 |
case PLI_PASS_5P_AND_3P_ANY: return TRUE; break; |
| 2404 |
case PLI_PASS_HMM_ONLY_ANY: return FALSE; break; |
| 2405 |
default: return FALSE; break; |
| 2406 |
} |
| 2407 |
return FALSE; |
| 2408 |
} |
| 2409 |
|
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
|
| 2415 |
|
| 2416 |
|
| 2417 |
|
| 2418 |
|
| 2419 |
|
| 2420 |
|
| 2421 |
void |
| 2422 |
cm_pli_AdjustNresForOverlaps(CM_PIPELINE *pli, int64_t noverlap, int in_rc) |
| 2423 |
{ |
| 2424 |
if(in_rc) { |
| 2425 |
if(! pli->do_hmmonly_cur) pli->acct[PLI_PASS_STD_ANY].nres_bot -= noverlap; |
| 2426 |
else pli->acct[PLI_PASS_HMM_ONLY_ANY].nres_bot -= noverlap; |
| 2427 |
if(pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_only) pli->acct[PLI_PASS_5P_AND_3P_ANY].nres_bot -= noverlap; |
| 2428 |
} |
| 2429 |
else { |
| 2430 |
if(! pli->do_hmmonly_cur) pli->acct[PLI_PASS_STD_ANY].nres_top -= noverlap; |
| 2431 |
else pli->acct[PLI_PASS_HMM_ONLY_ANY].nres_top -= noverlap; |
| 2432 |
if(pli->do_trunc_any || pli->do_trunc_int || pli->do_trunc_only) pli->acct[PLI_PASS_5P_AND_3P_ANY].nres_top -= noverlap; |
| 2433 |
} |
| 2434 |
return; |
| 2435 |
} |
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
|
| 2458 |
|
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
|
| 2464 |
|
| 2465 |
|
| 2466 |
|
| 2467 |
|
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
|
| 2476 |
|
| 2477 |
|
| 2478 |
|
| 2479 |
int |
| 2480 |
pli_p7_filter(CM_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, P7_SCOREDATA *msvdata, const ESL_SQ *sq, int64_t **ret_ws, int64_t **ret_we, float **ret_wb, int *ret_nwin) |
| 2481 |
{ |
| 2482 |
int status; |
| 2483 |
float mfsc, vfsc, fwdsc; |
| 2484 |
float filtersc; |
| 2485 |
int have_filtersc; |
| 2486 |
float nullsc; |
| 2487 |
float wsc; |
| 2488 |
double P; |
| 2489 |
int i, i2; |
| 2490 |
int wlen; |
| 2491 |
void *p; |
| 2492 |
int *useme = NULL; |
| 2493 |
int overlap; |
| 2494 |
int **survAA = NULL; |
| 2495 |
int nalloc; |
| 2496 |
int64_t *ws = NULL; |
| 2497 |
int64_t *we = NULL; |
| 2498 |
double *wp = NULL; |
| 2499 |
float *wb = NULL; |
| 2500 |
int nwin; |
| 2501 |
int64_t *new_ws = NULL; |
| 2502 |
int64_t *new_we = NULL; |
| 2503 |
float *new_wb = NULL; |
| 2504 |
int nsurv_fwd; |
| 2505 |
ESL_DSQ *subdsq; |
| 2506 |
int have_rest; |
| 2507 |
P7_HMM_WINDOWLIST wlist; |
| 2508 |
int save_max_length = om->max_length; |
| 2509 |
|
| 2510 |
|
| 2511 |
|
| 2512 |
|
| 2513 |
|
| 2514 |
int cur_do_msv = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? TRUE : pli->do_msv; |
| 2515 |
int cur_do_msvbias = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? pli->do_bias_hmmonly : pli->do_msvbias; |
| 2516 |
int cur_do_vit = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? (! pli->do_max_hmmonly) : pli->do_vit; |
| 2517 |
int cur_do_vitbias = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? FALSE : pli->do_vitbias; |
| 2518 |
int cur_do_fwd = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? (! pli->do_max_hmmonly) : pli->do_fwd; |
| 2519 |
int cur_do_fwdbias = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? FALSE : pli->do_fwdbias; |
| 2520 |
double cur_F1 = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? pli->F1_hmmonly : pli->F1; |
| 2521 |
double cur_F1b = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? pli->F1_hmmonly : pli->F1b; |
| 2522 |
double cur_F2 = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? pli->F2_hmmonly : pli->F2; |
| 2523 |
double cur_F2b = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? 1.0 : pli->F2b; |
| 2524 |
double cur_F3 = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? pli->F3_hmmonly : pli->F3; |
| 2525 |
double cur_F3b = (pli->cur_pass_idx == PLI_PASS_HMM_ONLY_ANY) ? 1.0 : pli->F3b; |
| 2526 |
|
| 2527 |
if (sq->n == 0) return eslOK; |
| 2528 |
p7_omx_GrowTo(pli->oxf, om->M, 0, sq->n); |
| 2529 |
have_rest = (om->mode == p7_NO_MODE) ? FALSE : TRUE; |
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
p7_oprofile_ReconfigMSVLength(om, pli->maxW); |
| 2539 |
om->max_length = pli->maxW; |
| 2540 |
|
| 2541 |
#if eslDEBUGLEVEL >= 2 |
| 2542 |
printf("#DEBUG\n#DEBUG: PIPELINE pli_p7_filter() %s %" PRId64 " residues\n", sq->name, sq->n); |
| 2543 |
#endif |
| 2544 |
|
| 2545 |
|
| 2546 |
nsurv_fwd = 0; |
| 2547 |
nwin = 0; |
| 2548 |
|
| 2549 |
|
| 2550 |
|
| 2551 |
if(cur_do_msv) { |
| 2552 |
p7_hmmwindow_init(&wlist); |
| 2553 |
status = p7_SSVFilter_longtarget(sq->dsq, sq->n, om, pli->oxf, msvdata, bg, cur_F1, &wlist); |
| 2554 |
|
| 2555 |
if(wlist.count > 0) { |
| 2556 |
|
| 2557 |
if (pli->mode == CM_SCAN_MODELS && (! have_rest)) { |
| 2558 |
if (pli->cmfp) p7_oprofile_ReadRest(pli->cmfp->hfp, om); |
| 2559 |
|
| 2560 |
|
| 2561 |
have_rest = TRUE; |
| 2562 |
} |
| 2563 |
if(msvdata->prefix_lengths == NULL && msvdata->suffix_lengths == NULL) { |
| 2564 |
p7_hmm_ScoreDataComputeRest(om, msvdata); |
| 2565 |
|
| 2566 |
|
| 2567 |
|
| 2568 |
} |
| 2569 |
p7_pli_ExtendAndMergeWindows(om, msvdata, &wlist, 0.0); |
| 2570 |
} |
| 2571 |
ESL_ALLOC(ws, sizeof(int64_t) * ESL_MAX(1, wlist.count)); |
| 2572 |
ESL_ALLOC(we, sizeof(int64_t) * ESL_MAX(1, wlist.count)); |
| 2573 |
nwin = wlist.count; |
| 2574 |
for(i = 0; i < nwin; i++) { |
| 2575 |
ws[i] = wlist.windows[i].n; |
| 2576 |
we[i] = ws[i] + wlist.windows[i].length - 1; |
| 2577 |
} |
| 2578 |
|
| 2579 |
|
| 2580 |
|
| 2581 |
nalloc = nwin + 100; |
| 2582 |
ESL_ALLOC(new_ws, sizeof(int64_t) * nalloc); |
| 2583 |
ESL_ALLOC(new_we, sizeof(int64_t) * nalloc); |
| 2584 |
for (i = 0, i2 = 0; i < nwin; i++, i2++) { |
| 2585 |
wlen = we[i] - ws[i] + 1; |
| 2586 |
if((i2+1) == nalloc) { |
| 2587 |
nalloc += 100; |
| 2588 |
ESL_RALLOC(new_ws, p, sizeof(int64_t) * nalloc); |
| 2589 |
ESL_RALLOC(new_we, p, sizeof(int64_t) * nalloc); |
| 2590 |
} |
| 2591 |
if(wlen > (2 * pli->cmW)) { |
| 2592 |
|
| 2593 |
new_ws[i2] = ws[i]; |
| 2594 |
new_we[i2] = ESL_MIN((new_ws[i2] + (2 * pli->cmW) - 1), we[i]); |
| 2595 |
while(new_we[i2] < we[i]) { |
| 2596 |
i2++; |
| 2597 |
if((i2+1) == nalloc) { |
| 2598 |
nalloc += 100; |
| 2599 |
ESL_RALLOC(new_ws, p, sizeof(int64_t) * nalloc); |
| 2600 |
ESL_RALLOC(new_we, p, sizeof(int64_t) * nalloc); |
| 2601 |
} |
| 2602 |
new_ws[i2] = ESL_MIN(new_ws[i2-1] + pli->cmW, we[i]); |
| 2603 |
new_we[i2] = ESL_MIN(new_we[i2-1] + pli->cmW, we[i]); |
| 2604 |
} |
| 2605 |
} |
| 2606 |
else { |
| 2607 |
new_ws[i2] = ws[i]; |
| 2608 |
new_we[i2] = we[i]; |
| 2609 |
} |
| 2610 |
} |
| 2611 |
free(wlist.windows); |
| 2612 |
free(ws); |
| 2613 |
free(we); |
| 2614 |
ws = new_ws; |
| 2615 |
we = new_we; |
| 2616 |
nwin = i2; |
| 2617 |
} |
| 2618 |
else { |
| 2619 |
nwin = 1; |
| 2620 |
if(sq->n > (2 * pli->maxW)) { |
| 2621 |
nwin += (int) (sq->n - (2 * pli->maxW)) / ((2 * pli->maxW) - (pli->maxW - 1)); |
| 2622 |
|
| 2623 |
if(((sq->n - (2 * pli->maxW)) % ((2 * pli->maxW) - (pli->maxW - 1))) > 0) { |
| 2624 |
nwin++; |
| 2625 |
} |
| 2626 |
} |
| 2627 |
ESL_ALLOC(ws, sizeof(int64_t) * nwin); |
| 2628 |
ESL_ALLOC(we, sizeof(int64_t) * nwin); |
| 2629 |
for(i = 0; i < nwin; i++) { |
| 2630 |
ws[i] = 1 + (i * (pli->maxW + 1)); |
| 2631 |
we[i] = ESL_MIN((ws[i] + (2*pli->maxW) - 1), sq->n); |
| 2632 |
|
| 2633 |
} |
| 2634 |
} |
| 2635 |
pli->acct[pli->cur_pass_idx].n_past_msv += nwin; |
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
ESL_ALLOC(survAA, sizeof(int *) * Np7_SURV); |
| 2640 |
for (i = 0; i < Np7_SURV; i++) { |
| 2641 |
ESL_ALLOC(survAA[i], sizeof(int) * ESL_MAX(1, nwin)); |
| 2642 |
esl_vec_ISet(survAA[i], nwin, FALSE); |
| 2643 |
} |
| 2644 |
|
| 2645 |
ESL_ALLOC(wp, sizeof(double) * ESL_MAX(1, nwin)); |
| 2646 |
ESL_ALLOC(wb, sizeof(float) * ESL_MAX(1, nwin)); |
| 2647 |
for (i = 0; i < nwin; i++) { wp[i] = 1.0; } |
| 2648 |
for (i = 0; i < nwin; i++) { wb[i] = -999.0; } |
| 2649 |
|
| 2650 |
for (i = 0; i < nwin; i++) { |
| 2651 |
subdsq = sq->dsq + ws[i] - 1; |
| 2652 |
have_filtersc = FALSE; |
| 2653 |
wlen = we[i] - ws[i] + 1; |
| 2654 |
|
| 2655 |
p7_bg_SetLength(bg, wlen); |
| 2656 |
p7_bg_NullOne (bg, subdsq, wlen, &nullsc); |
| 2657 |
|
| 2658 |
#if eslDEBUGLEVEL >= 2 |
| 2659 |
if(cur_do_msv) printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived SSV ? bits ? P\n", i, ws[i], we[i]); |
| 2660 |
#endif |
| 2661 |
survAA[p7_SURV_F1][i] = TRUE; |
| 2662 |
|
| 2663 |
if (cur_do_msv && cur_do_msvbias) { |
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
p7_oprofile_ReconfigMSVLength(om, wlen); |
| 2670 |
p7_MSVFilter(subdsq, wlen, om, pli->oxf, &mfsc); |
| 2671 |
p7_bg_FilterScore(bg, subdsq, wlen, &filtersc); |
| 2672 |
have_filtersc = TRUE; |
| 2673 |
|
| 2674 |
wsc = (mfsc - filtersc) / eslCONST_LOG2; |
| 2675 |
P = esl_gumbel_surv(wsc, p7_evparam[CM_p7_LMMU], p7_evparam[CM_p7_LMLAMBDA]); |
| 2676 |
wp[i] = P; |
| 2677 |
|
| 2678 |
if (P > cur_F1b) continue; |
| 2679 |
|
| 2680 |
|
| 2681 |
} |
| 2682 |
|
| 2683 |
pli->acct[pli->cur_pass_idx].n_past_msvbias++; |
| 2684 |
survAA[p7_SURV_F1b][i] = TRUE; |
| 2685 |
|
| 2686 |
#if eslDEBUGLEVEL >= 2 |
| 2687 |
if(cur_do_msv && cur_do_msvbias) printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived MSV-Bias ? bits P ?\n", i, ws[i], we[i]); |
| 2688 |
#endif |
| 2689 |
if(pli->do_time_F1) return eslOK; |
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
|
| 2694 |
if (pli->mode == CM_SCAN_MODELS && (! have_rest)) { |
| 2695 |
if (pli->cmfp) p7_oprofile_ReadRest(pli->cmfp->hfp, om); |
| 2696 |
|
| 2697 |
|
| 2698 |
have_rest = TRUE; |
| 2699 |
} |
| 2700 |
if(cur_do_msv && cur_do_msvbias) { |
| 2701 |
p7_oprofile_ReconfigRestLength(om, wlen); |
| 2702 |
} |
| 2703 |
else { |
| 2704 |
p7_oprofile_ReconfigLength(om, wlen); |
| 2705 |
} |
| 2706 |
|
| 2707 |
if (cur_do_vit) { |
| 2708 |
|
| 2709 |
|
| 2710 |
|
| 2711 |
p7_ViterbiFilter(subdsq, wlen, om, pli->oxf, &vfsc); |
| 2712 |
wsc = (vfsc - nullsc) / eslCONST_LOG2; |
| 2713 |
P = esl_gumbel_surv(wsc, p7_evparam[CM_p7_LVMU], p7_evparam[CM_p7_LVLAMBDA]); |
| 2714 |
wp[i] = P; |
| 2715 |
wb[i] = wsc; |
| 2716 |
if (P > cur_F2) continue; |
| 2717 |
} |
| 2718 |
pli->acct[pli->cur_pass_idx].n_past_vit++; |
| 2719 |
survAA[p7_SURV_F2][i] = TRUE; |
| 2720 |
|
| 2721 |
#if eslDEBUGLEVEL >= 2 |
| 2722 |
if (cur_do_vit) printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived Vit %6.2f bits P %g\n", i, ws[i], we[i], wb[i], wp[i]); |
| 2723 |
#endif |
| 2724 |
|
| 2725 |
|
| 2726 |
if (cur_do_vit && cur_do_vitbias) { |
| 2727 |
if(! have_filtersc) { |
| 2728 |
p7_bg_FilterScore(bg, subdsq, wlen, &filtersc); |
| 2729 |
} |
| 2730 |
have_filtersc = TRUE; |
| 2731 |
wsc = (vfsc - filtersc) / eslCONST_LOG2; |
| 2732 |
P = esl_gumbel_surv(wsc, p7_evparam[CM_p7_LVMU], p7_evparam[CM_p7_LVLAMBDA]); |
| 2733 |
wp[i] = P; |
| 2734 |
wb[i] = wsc; |
| 2735 |
if (P > cur_F2b) continue; |
| 2736 |
|
| 2737 |
} |
| 2738 |
pli->acct[pli->cur_pass_idx].n_past_vitbias++; |
| 2739 |
survAA[p7_SURV_F2b][i] = TRUE; |
| 2740 |
|
| 2741 |
#if eslDEBUGLEVEL >= 2 |
| 2742 |
if (cur_do_vit && cur_do_vitbias) printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived Vit-Bias %6.2f bits P %g\n", i, ws[i], we[i], wb[i], wp[i]); |
| 2743 |
#endif |
| 2744 |
if(pli->do_time_F2) continue; |
| 2745 |
|
| 2746 |
|
| 2747 |
if(cur_do_fwd) { |
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
p7_ForwardParser(subdsq, wlen, om, pli->oxf, &fwdsc); |
| 2752 |
wsc = (fwdsc - nullsc) / eslCONST_LOG2; |
| 2753 |
P = esl_exp_surv(wsc, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 2754 |
wp[i] = P; |
| 2755 |
wb[i] = wsc; |
| 2756 |
if (P > cur_F3) continue; |
| 2757 |
} |
| 2758 |
|
| 2759 |
pli->acct[pli->cur_pass_idx].n_past_fwd++; |
| 2760 |
survAA[p7_SURV_F3][i] = TRUE; |
| 2761 |
|
| 2762 |
#if eslDEBUGLEVEL >= 2 |
| 2763 |
if(cur_do_fwd) printf("#DEBUG SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived Fwd %6.2f bits P %g\n", i, ws[i], we[i], wb[i], wp[i]); |
| 2764 |
#endif |
| 2765 |
|
| 2766 |
if (cur_do_fwd && cur_do_fwdbias) { |
| 2767 |
if (! have_filtersc) { |
| 2768 |
p7_bg_FilterScore(bg, subdsq, wlen, &filtersc); |
| 2769 |
} |
| 2770 |
have_filtersc = TRUE; |
| 2771 |
wsc = (fwdsc - filtersc) / eslCONST_LOG2; |
| 2772 |
P = esl_exp_surv(wsc, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 2773 |
wp[i] = P; |
| 2774 |
wb[i] = wsc; |
| 2775 |
if (P > cur_F3b) continue; |
| 2776 |
|
| 2777 |
} |
| 2778 |
pli->acct[pli->cur_pass_idx].n_past_fwdbias++; |
| 2779 |
nsurv_fwd++; |
| 2780 |
survAA[p7_SURV_F3b][i] = TRUE; |
| 2781 |
|
| 2782 |
#if eslDEBUGLEVEL >= 2 |
| 2783 |
if(cur_do_fwd && cur_do_fwdbias) printf("#DEBUG SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived Fwd-Bias %6.2f bits P %g\n", i, ws[i], we[i], wb[i], wp[i]); |
| 2784 |
#endif |
| 2785 |
} |
| 2786 |
|
| 2787 |
|
| 2788 |
|
| 2789 |
|
| 2790 |
|
| 2791 |
|
| 2792 |
|
| 2793 |
for(i = 0; i < nwin; i++) { |
| 2794 |
wlen = we[i] - ws[i] + 1; |
| 2795 |
|
| 2796 |
if(survAA[p7_SURV_F1][i]) pli->acct[pli->cur_pass_idx].pos_past_msv += wlen; |
| 2797 |
if(survAA[p7_SURV_F1b][i]) pli->acct[pli->cur_pass_idx].pos_past_msvbias += wlen; |
| 2798 |
if(survAA[p7_SURV_F2][i]) pli->acct[pli->cur_pass_idx].pos_past_vit += wlen; |
| 2799 |
if(survAA[p7_SURV_F2b][i]) pli->acct[pli->cur_pass_idx].pos_past_vitbias += wlen; |
| 2800 |
if(survAA[p7_SURV_F3][i]) pli->acct[pli->cur_pass_idx].pos_past_fwd += wlen; |
| 2801 |
if(survAA[p7_SURV_F3b][i]) pli->acct[pli->cur_pass_idx].pos_past_fwdbias += wlen; |
| 2802 |
|
| 2803 |
|
| 2804 |
if(i > 0) { |
| 2805 |
overlap = we[i-1] - ws[i] + 1; |
| 2806 |
if(overlap > 0) { |
| 2807 |
if(survAA[p7_SURV_F1][i] && survAA[p7_SURV_F1][i-1]) pli->acct[pli->cur_pass_idx].pos_past_msv -= overlap; |
| 2808 |
if(survAA[p7_SURV_F1b][i] && survAA[p7_SURV_F1b][i-1]) pli->acct[pli->cur_pass_idx].pos_past_msvbias -= overlap; |
| 2809 |
if(survAA[p7_SURV_F2][i] && survAA[p7_SURV_F2][i-1]) pli->acct[pli->cur_pass_idx].pos_past_vit -= overlap; |
| 2810 |
if(survAA[p7_SURV_F2b][i] && survAA[p7_SURV_F2b][i-1]) pli->acct[pli->cur_pass_idx].pos_past_vitbias -= overlap; |
| 2811 |
if(survAA[p7_SURV_F3][i] && survAA[p7_SURV_F3][i-1]) pli->acct[pli->cur_pass_idx].pos_past_fwd -= overlap; |
| 2812 |
if(survAA[p7_SURV_F3b][i] && survAA[p7_SURV_F3b][i-1]) pli->acct[pli->cur_pass_idx].pos_past_fwdbias -= overlap; |
| 2813 |
} |
| 2814 |
} |
| 2815 |
} |
| 2816 |
|
| 2817 |
|
| 2818 |
if(nsurv_fwd > 0) { |
| 2819 |
ESL_ALLOC(new_ws, sizeof(int64_t) * nsurv_fwd); |
| 2820 |
ESL_ALLOC(new_we, sizeof(int64_t) * nsurv_fwd); |
| 2821 |
ESL_ALLOC(new_wb, sizeof(float) * nsurv_fwd); |
| 2822 |
for (i = 0, i2 = 0; i < nwin; i++) { |
| 2823 |
if(survAA[p7_SURV_F3b][i]) { |
| 2824 |
new_ws[i2] = ws[i]; |
| 2825 |
new_we[i2] = we[i]; |
| 2826 |
new_wb[i2] = wb[i]; |
| 2827 |
i2++; |
| 2828 |
} |
| 2829 |
} |
| 2830 |
|
| 2831 |
ESL_ALLOC(useme, sizeof(int) * nsurv_fwd); |
| 2832 |
esl_vec_ISet(useme, nsurv_fwd, FALSE); |
| 2833 |
i2 = 0; |
| 2834 |
for(i = 0, i2 = 0; i < nsurv_fwd; i++) { |
| 2835 |
useme[i] = TRUE; |
| 2836 |
i2 = i+1; |
| 2837 |
while((i2 < nsurv_fwd) && ((new_we[i]+1) >= (new_ws[i2]))) { |
| 2838 |
useme[i2] = FALSE; |
| 2839 |
new_we[i] = new_we[i2]; |
| 2840 |
new_wb[i] = ESL_MAX(new_wb[i], new_wb[i2]); |
| 2841 |
i2++; |
| 2842 |
} |
| 2843 |
i = i2-1; |
| 2844 |
} |
| 2845 |
i2 = 0; |
| 2846 |
for(i = 0; i < nsurv_fwd; i++) { |
| 2847 |
if(useme[i]) { |
| 2848 |
new_ws[i2] = new_ws[i]; |
| 2849 |
new_we[i2] = new_we[i]; |
| 2850 |
new_wb[i2] = new_wb[i]; |
| 2851 |
i2++; |
| 2852 |
} |
| 2853 |
} |
| 2854 |
nsurv_fwd = i2; |
| 2855 |
free(useme); |
| 2856 |
free(ws); ws = NULL; |
| 2857 |
free(we); we = NULL; |
| 2858 |
free(wp); wp = NULL; |
| 2859 |
free(wb); wb = NULL; |
| 2860 |
ws = new_ws; |
| 2861 |
we = new_we; |
| 2862 |
wb = new_wb; |
| 2863 |
} |
| 2864 |
else { |
| 2865 |
if(ws != NULL) { free(ws); ws = NULL; } |
| 2866 |
if(we != NULL) { free(we); we = NULL; } |
| 2867 |
if(wp != NULL) { free(wp); wp = NULL; } |
| 2868 |
if(wb != NULL) { free(wb); wb = NULL; } |
| 2869 |
} |
| 2870 |
|
| 2871 |
if(survAA != NULL) { |
| 2872 |
for (i = 0; i < Np7_SURV; i++) free(survAA[i]); |
| 2873 |
free(survAA); |
| 2874 |
} |
| 2875 |
|
| 2876 |
om->max_length = save_max_length; |
| 2877 |
|
| 2878 |
*ret_ws = ws; |
| 2879 |
*ret_we = we; |
| 2880 |
*ret_wb = wb; |
| 2881 |
*ret_nwin = nsurv_fwd; |
| 2882 |
|
| 2883 |
return eslOK; |
| 2884 |
|
| 2885 |
ERROR: |
| 2886 |
ESL_EXCEPTION(eslEMEM, "Error allocating memory for hit list in pipeline\n"); |
| 2887 |
|
| 2888 |
} |
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
|
| 2896 |
|
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
|
| 2901 |
|
| 2902 |
|
| 2903 |
|
| 2904 |
|
| 2905 |
|
| 2906 |
|
| 2907 |
|
| 2908 |
|
| 2909 |
|
| 2910 |
|
| 2911 |
|
| 2912 |
|
| 2913 |
|
| 2914 |
|
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
int |
| 2927 |
pli_p7_env_def(CM_PIPELINE *pli, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, const ESL_SQ *sq, int64_t *ws, int64_t *we, int nwin, |
| 2928 |
P7_HMM **opt_hmm, P7_PROFILE **opt_gm, P7_PROFILE **opt_Rgm, P7_PROFILE **opt_Lgm, P7_PROFILE **opt_Tgm, int64_t **ret_es, int64_t **ret_ee, float **ret_eb, int *ret_nenv) |
| 2929 |
{ |
| 2930 |
int status; |
| 2931 |
double P; |
| 2932 |
int d, i; |
| 2933 |
void *p; |
| 2934 |
int env_len; |
| 2935 |
float env_sc; |
| 2936 |
float sc_for_pvalue; |
| 2937 |
float env_edefbias; |
| 2938 |
float env_sc_for_pvalue; |
| 2939 |
int64_t wlen; |
| 2940 |
int64_t *es = NULL; |
| 2941 |
int64_t *ee = NULL; |
| 2942 |
float *eb = NULL; |
| 2943 |
int nenv; |
| 2944 |
int nenv_alloc; |
| 2945 |
ESL_DSQ *subdsq; |
| 2946 |
ESL_SQ *seq = NULL; |
| 2947 |
float nullsc, filtersc, fwdsc, bcksc; |
| 2948 |
P7_PROFILE *gm = NULL; |
| 2949 |
int do_local_envdef; |
| 2950 |
|
| 2951 |
|
| 2952 |
P7_PROFILE *Rgm = NULL; |
| 2953 |
P7_PROFILE *Lgm = NULL; |
| 2954 |
P7_PROFILE *Tgm = NULL; |
| 2955 |
float safe_lfwdsc; |
| 2956 |
int use_gm, use_Rgm, use_Lgm, use_Tgm; |
| 2957 |
|
| 2958 |
|
| 2959 |
|
| 2960 |
float Rgm_correction; |
| 2961 |
float Lgm_correction; |
| 2962 |
|
| 2963 |
if (sq->n == 0) return eslOK; |
| 2964 |
if (nwin == 0) { |
| 2965 |
*ret_es = NULL; |
| 2966 |
*ret_ee = NULL; |
| 2967 |
*ret_eb = NULL; |
| 2968 |
*ret_nenv = 0; |
| 2969 |
return eslOK; |
| 2970 |
} |
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
|
| 2976 |
do_local_envdef = (pli->cur_pass_idx == PLI_PASS_5P_AND_3P_ANY) ? TRUE : FALSE; |
| 2977 |
|
| 2978 |
nenv_alloc = nwin; |
| 2979 |
ESL_ALLOC(es, sizeof(int64_t) * ESL_MAX(1, nenv_alloc)); |
| 2980 |
ESL_ALLOC(ee, sizeof(int64_t) * ESL_MAX(1, nenv_alloc)); |
| 2981 |
ESL_ALLOC(eb, sizeof(float) * ESL_MAX(1, nenv_alloc)); |
| 2982 |
nenv = 0; |
| 2983 |
seq = esl_sq_CreateDigital(sq->abc); |
| 2984 |
|
| 2985 |
#if eslDEBUGLEVEL >= 2 |
| 2986 |
printf("#DEBUG:\n#DEBUG: PIPELINE p7EnvelopeDef() %s %" PRId64 " residues\n", sq->name, sq->n); |
| 2987 |
#endif |
| 2988 |
|
| 2989 |
|
| 2990 |
use_gm = use_Tgm = use_Rgm = use_Lgm = FALSE; |
| 2991 |
if(! do_local_envdef) { |
| 2992 |
switch(pli->cur_pass_idx) { |
| 2993 |
case PLI_PASS_STD_ANY: use_gm = TRUE; break; |
| 2994 |
case PLI_PASS_5P_ONLY_FORCE: use_Rgm = TRUE; break; |
| 2995 |
case PLI_PASS_3P_ONLY_FORCE: use_Lgm = TRUE; break; |
| 2996 |
case PLI_PASS_5P_AND_3P_FORCE: use_Tgm = TRUE; break; |
| 2997 |
default: ESL_FAIL(eslEINVAL, pli->errbuf, "pli_p7_env_def() invalid pass index"); |
| 2998 |
} |
| 2999 |
} |
| 3000 |
|
| 3001 |
|
| 3002 |
|
| 3003 |
|
| 3004 |
if (pli->mode == CM_SCAN_MODELS && |
| 3005 |
((use_gm == TRUE && (*opt_gm) == NULL) || |
| 3006 |
(use_Rgm == TRUE && (*opt_Rgm) == NULL) || |
| 3007 |
(use_Lgm == TRUE && (*opt_Lgm) == NULL) || |
| 3008 |
(use_Tgm == TRUE && (*opt_Tgm) == NULL))) { |
| 3009 |
if((*opt_hmm) == NULL) { |
| 3010 |
|
| 3011 |
if (pli->cmfp == NULL) ESL_FAIL(eslENOTFOUND, pli->errbuf, "No file available to read HMM from in pli_p7_env_def()"); |
| 3012 |
if (pli->cmfp->hfp == NULL) ESL_FAIL(eslENOTFOUND, pli->errbuf, "No file available to read HMM from in pli_p7_env_def()"); |
| 3013 |
if((status = cm_p7_hmmfile_Read(pli->cmfp, pli->abc, om->offs[p7_MOFFSET], opt_hmm)) != eslOK) ESL_FAIL(status, pli->errbuf, "%s", pli->cmfp->errbuf); |
| 3014 |
} |
| 3015 |
|
| 3016 |
if((*opt_gm) == NULL) { |
| 3017 |
*opt_gm = p7_profile_Create((*opt_hmm)->M, pli->abc); |
| 3018 |
p7_ProfileConfig(*opt_hmm, bg, *opt_gm, 100, p7_GLOCAL); |
| 3019 |
} |
| 3020 |
if(use_Rgm && (*opt_Rgm == NULL)) { |
| 3021 |
*opt_Rgm = p7_profile_Clone(*opt_gm); |
| 3022 |
p7_ProfileConfig5PrimeTrunc(*opt_Rgm, 100); |
| 3023 |
} |
| 3024 |
if(use_Lgm && (*opt_Lgm == NULL)) { |
| 3025 |
*opt_Lgm = p7_profile_Clone(*opt_gm); |
| 3026 |
p7_ProfileConfig3PrimeTrunc(*opt_hmm, *opt_Lgm, 100); |
| 3027 |
} |
| 3028 |
if(use_Tgm && (*opt_Tgm == NULL)) { |
| 3029 |
*opt_Tgm = p7_profile_Clone(*opt_gm); |
| 3030 |
p7_ProfileConfig(*opt_hmm, bg, *opt_Tgm, 100, p7_LOCAL); |
| 3031 |
p7_ProfileConfig5PrimeAnd3PrimeTrunc(*opt_Tgm, 100); |
| 3032 |
} |
| 3033 |
} |
| 3034 |
gm = *opt_gm; |
| 3035 |
Rgm = *opt_Rgm; |
| 3036 |
Lgm = *opt_Lgm; |
| 3037 |
Tgm = *opt_Tgm; |
| 3038 |
|
| 3039 |
for (i = 0; i < nwin; i++) { |
| 3040 |
#if eslDEBUGLEVEL >= 2 |
| 3041 |
printf("#DEBUG: p7 envdef win: %4d of %4d [%6" PRId64 "..%6" PRId64 "] pass: %" PRId64 "\n", i, nwin, ws[i], we[i], pli->cur_pass_idx); |
| 3042 |
#endif |
| 3043 |
|
| 3044 |
|
| 3045 |
|
| 3046 |
if(cm_pli_PassEnforcesFirstRes(pli->cur_pass_idx) && ws[i] != 1) continue; |
| 3047 |
if(cm_pli_PassEnforcesFinalRes(pli->cur_pass_idx) && we[i] != sq->n) continue; |
| 3048 |
|
| 3049 |
wlen = we[i] - ws[i] + 1; |
| 3050 |
subdsq = sq->dsq + ws[i] - 1; |
| 3051 |
|
| 3052 |
|
| 3053 |
esl_sq_GrowTo(seq, wlen); |
| 3054 |
memcpy((void*)(seq->dsq), subdsq, (wlen+1) * sizeof(uint8_t)); |
| 3055 |
seq->dsq[0] = seq->dsq[wlen+1] = eslDSQ_SENTINEL; |
| 3056 |
seq->n = wlen; |
| 3057 |
|
| 3058 |
p7_bg_SetLength(bg, wlen); |
| 3059 |
p7_bg_NullOne(bg, seq->dsq, wlen, &nullsc); |
| 3060 |
|
| 3061 |
if(do_local_envdef) { |
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
p7_oprofile_ReconfigLength(om, wlen); |
| 3066 |
p7_ForwardParser(seq->dsq, wlen, om, pli->oxf, NULL); |
| 3067 |
p7_omx_GrowTo(pli->oxb, om->M, 0, wlen); |
| 3068 |
p7_BackwardParser(seq->dsq, wlen, om, pli->oxf, pli->oxb, NULL); |
| 3069 |
status = p7_domaindef_ByPosteriorHeuristics (seq, NULL, om, pli->oxf, pli->oxb, pli->fwd, pli->bck, pli->ddef, bg, FALSE, |
| 3070 |
NULL, NULL, NULL); |
| 3071 |
} |
| 3072 |
else { |
| 3073 |
|
| 3074 |
|
| 3075 |
|
| 3076 |
|
| 3077 |
|
| 3078 |
|
| 3079 |
if(use_Tgm) { |
| 3080 |
|
| 3081 |
p7_gmx_GrowTo(pli->gxf, Tgm->M, wlen); |
| 3082 |
p7_GForward (seq->dsq, wlen, Tgm, pli->gxf, &fwdsc); |
| 3083 |
|
| 3084 |
|
| 3085 |
|
| 3086 |
|
| 3087 |
|
| 3088 |
sc_for_pvalue = (fwdsc - nullsc) / eslCONST_LOG2; |
| 3089 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3090 |
} |
| 3091 |
else if(use_Rgm) { |
| 3092 |
p7_ReconfigLength5PrimeTrunc(Rgm, wlen); |
| 3093 |
p7_gmx_GrowTo(pli->gxf, Rgm->M, wlen); |
| 3094 |
p7_GForward (seq->dsq, wlen, Rgm, pli->gxf, &fwdsc); |
| 3095 |
|
| 3096 |
|
| 3097 |
|
| 3098 |
|
| 3099 |
|
| 3100 |
|
| 3101 |
|
| 3102 |
Rgm_correction = 0.; |
| 3103 |
safe_lfwdsc = fwdsc + Rgm_correction; |
| 3104 |
sc_for_pvalue = (safe_lfwdsc - nullsc) / eslCONST_LOG2; |
| 3105 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3106 |
} |
| 3107 |
else if(use_Lgm) { |
| 3108 |
p7_ReconfigLength3PrimeTrunc(Lgm, wlen); |
| 3109 |
p7_gmx_GrowTo(pli->gxf, Lgm->M, wlen); |
| 3110 |
p7_GForward (seq->dsq, wlen, Lgm, pli->gxf, &fwdsc); |
| 3111 |
|
| 3112 |
|
| 3113 |
|
| 3114 |
|
| 3115 |
|
| 3116 |
|
| 3117 |
Lgm_correction = log(1./Lgm->M); |
| 3118 |
safe_lfwdsc = fwdsc + Lgm_correction; |
| 3119 |
sc_for_pvalue = (safe_lfwdsc - nullsc) / eslCONST_LOG2; |
| 3120 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3121 |
} |
| 3122 |
else if(use_gm) { |
| 3123 |
p7_ReconfigLength(gm, wlen); |
| 3124 |
p7_gmx_GrowTo(pli->gxf, gm->M, wlen); |
| 3125 |
p7_GForward (seq->dsq, wlen, gm, pli->gxf, &fwdsc); |
| 3126 |
|
| 3127 |
sc_for_pvalue = (fwdsc - nullsc) / eslCONST_LOG2; |
| 3128 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_GFMU], p7_evparam[CM_p7_GFLAMBDA]); |
| 3129 |
} |
| 3130 |
|
| 3131 |
#if eslDEBUGLEVEL >= 2 |
| 3132 |
if(P > pli->F4) { |
| 3133 |
printf("#DEBUG: KILLED window %5d [%10" PRId64 "..%10" PRId64 "] gFwd %6.2f bits P %g\n", i, ws[i], we[i], sc_for_pvalue, P); |
| 3134 |
} |
| 3135 |
#endif |
| 3136 |
|
| 3137 |
if(P > pli->F4) continue; |
| 3138 |
|
| 3139 |
pli->acct[pli->cur_pass_idx].n_past_gfwd++; |
| 3140 |
pli->acct[pli->cur_pass_idx].pos_past_gfwd += wlen; |
| 3141 |
|
| 3142 |
#if eslDEBUGLEVEL >= 2 |
| 3143 |
printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived gFwd %6.2f bits P %g\n", i, ws[i], we[i], sc_for_pvalue, P); |
| 3144 |
#endif |
| 3145 |
|
| 3146 |
if(pli->do_gfwdbias) { |
| 3147 |
|
| 3148 |
p7_bg_FilterScore(bg, seq->dsq, wlen, &filtersc); |
| 3149 |
|
| 3150 |
|
| 3151 |
|
| 3152 |
if(use_Tgm) { |
| 3153 |
sc_for_pvalue = (fwdsc - filtersc) / eslCONST_LOG2; |
| 3154 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3155 |
} |
| 3156 |
else if(use_Rgm || use_Lgm) { |
| 3157 |
sc_for_pvalue = (safe_lfwdsc - nullsc) / eslCONST_LOG2; |
| 3158 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3159 |
} |
| 3160 |
else if(use_gm) { |
| 3161 |
sc_for_pvalue = (fwdsc - filtersc) / eslCONST_LOG2; |
| 3162 |
P = esl_exp_surv (sc_for_pvalue, p7_evparam[CM_p7_GFMU], p7_evparam[CM_p7_GFLAMBDA]); |
| 3163 |
} |
| 3164 |
if(P > pli->F4b) continue; |
| 3165 |
#if eslDEBUGLEVEL >= 2 |
| 3166 |
printf("#DEBUG: SURVIVOR window %5d [%10" PRId64 "..%10" PRId64 "] survived gFwdBias %6.2f bits P %g\n", i, ws[i], we[i], sc_for_pvalue, P); |
| 3167 |
#endif |
| 3168 |
pli->acct[pli->cur_pass_idx].n_past_gfwdbias++; |
| 3169 |
pli->acct[pli->cur_pass_idx].pos_past_gfwdbias += wlen; |
| 3170 |
} |
| 3171 |
if(pli->do_time_F4) continue; |
| 3172 |
|
| 3173 |
|
| 3174 |
|
| 3175 |
|
| 3176 |
|
| 3177 |
|
| 3178 |
|
| 3179 |
if(use_Tgm) { |
| 3180 |
|
| 3181 |
p7_gmx_GrowTo(pli->gxb, Tgm->M, wlen); |
| 3182 |
p7_GBackward(seq->dsq, wlen, Tgm, pli->gxb, &bcksc); |
| 3183 |
if((status = p7_domaindef_GlocalByPosteriorHeuristics(seq, Tgm, pli->gxf, pli->gxb, pli->gfwd, pli->gbck, pli->ddef, pli->do_null2)) != eslOK) ESL_FAIL(status, pli->errbuf, "unexpected failure during glocal envelope defn"); |
| 3184 |
|
| 3185 |
} |
| 3186 |
else if(use_Rgm) { |
| 3187 |
p7_gmx_GrowTo(pli->gxb, Rgm->M, wlen); |
| 3188 |
p7_GBackward(seq->dsq, wlen, Rgm, pli->gxb, &bcksc); |
| 3189 |
if((status = p7_domaindef_GlocalByPosteriorHeuristics(seq, Rgm, pli->gxf, pli->gxb, pli->gfwd, pli->gbck, pli->ddef, pli->do_null2)) != eslOK) ESL_FAIL(status, pli->errbuf, "unexpected failure during glocal envelope defn");; |
| 3190 |
|
| 3191 |
} |
| 3192 |
else if(use_Lgm) { |
| 3193 |
p7_gmx_GrowTo(pli->gxb, Lgm->M, wlen); |
| 3194 |
p7_GBackward(seq->dsq, wlen, Lgm, pli->gxb, &bcksc); |
| 3195 |
if((status = p7_domaindef_GlocalByPosteriorHeuristics(seq, Lgm, pli->gxf, pli->gxb, pli->gfwd, pli->gbck, pli->ddef, pli->do_null2)) != eslOK) ESL_FAIL(status, pli->errbuf, "unexpected failure during glocal envelope defn"); |
| 3196 |
|
| 3197 |
} |
| 3198 |
else { |
| 3199 |
p7_gmx_GrowTo(pli->gxb, gm->M, wlen); |
| 3200 |
p7_GBackward(seq->dsq, wlen, gm, pli->gxb, &bcksc); |
| 3201 |
if((status = p7_domaindef_GlocalByPosteriorHeuristics(seq, gm, pli->gxf, pli->gxb, pli->gfwd, pli->gbck, pli->ddef, pli->do_null2)) != eslOK) ESL_FAIL(status, pli->errbuf, "unexpected failure during glocal envelope defn"); |
| 3202 |
|
| 3203 |
} |
| 3204 |
} |
| 3205 |
|
| 3206 |
if (status != eslOK) ESL_FAIL(status, pli->errbuf, "envelope definition workflow failure"); |
| 3207 |
if (pli->ddef->nregions == 0) continue; |
| 3208 |
if (pli->ddef->nenvelopes == 0) continue; |
| 3209 |
|
| 3210 |
|
| 3211 |
for(d = 0; d < pli->ddef->ndom; d++) { |
| 3212 |
|
| 3213 |
if(do_local_envdef) { |
| 3214 |
p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 3215 |
pli->ddef->dcl[d].ad = NULL; |
| 3216 |
} |
| 3217 |
|
| 3218 |
env_len = pli->ddef->dcl[d].jenv - pli->ddef->dcl[d].ienv +1; |
| 3219 |
env_sc = pli->ddef->dcl[d].envsc; |
| 3220 |
|
| 3221 |
|
| 3222 |
|
| 3223 |
|
| 3224 |
|
| 3225 |
|
| 3226 |
|
| 3227 |
|
| 3228 |
|
| 3229 |
|
| 3230 |
|
| 3231 |
|
| 3232 |
env_sc = env_sc + (wlen - env_len) * log((float) wlen / (float) (wlen+3)); |
| 3233 |
env_edefbias = pli->do_null2 ? p7_FLogsum(0.0, log(bg->omega) + pli->ddef->dcl[d].domcorrection) : 0.0; |
| 3234 |
env_sc_for_pvalue = (env_sc - (nullsc + env_edefbias)) / eslCONST_LOG2; |
| 3235 |
|
| 3236 |
if(use_Rgm) env_sc_for_pvalue += Rgm_correction / eslCONST_LOG2; |
| 3237 |
if(use_Lgm) env_sc_for_pvalue += Lgm_correction / eslCONST_LOG2; |
| 3238 |
|
| 3239 |
if(do_local_envdef || use_Tgm || use_Rgm || use_Lgm) P = esl_exp_surv (env_sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3240 |
else P = esl_exp_surv (env_sc_for_pvalue, p7_evparam[CM_p7_GFMU], p7_evparam[CM_p7_GFLAMBDA]); |
| 3241 |
|
| 3242 |
|
| 3243 |
|
| 3244 |
if(P > pli->F5) { |
| 3245 |
if(pli->ddef->dcl[d].ad) p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 3246 |
continue; |
| 3247 |
} |
| 3248 |
|
| 3249 |
#if eslDEBUGLEVEL >= 2 |
| 3250 |
printf("#DEBUG: SURVIVOR envelope [%10" PRId64 "..%10" PRId64 "] survived F5 %6.2f bits P %g\n", pli->ddef->dcl[d].ienv + ws[i] - 1, pli->ddef->dcl[d].jenv + ws[i] - 1, env_sc_for_pvalue, P); |
| 3251 |
#endif |
| 3252 |
pli->acct[pli->cur_pass_idx].n_past_edef++; |
| 3253 |
pli->acct[pli->cur_pass_idx].pos_past_edef += env_len; |
| 3254 |
|
| 3255 |
|
| 3256 |
if(pli->do_edefbias) { |
| 3257 |
|
| 3258 |
|
| 3259 |
|
| 3260 |
p7_bg_FilterScore(bg, seq->dsq, wlen, &filtersc); |
| 3261 |
env_sc_for_pvalue = (env_sc - filtersc) / eslCONST_LOG2; |
| 3262 |
|
| 3263 |
if(use_Rgm) env_sc_for_pvalue += Rgm_correction / eslCONST_LOG2; |
| 3264 |
if(use_Lgm) env_sc_for_pvalue += Lgm_correction / eslCONST_LOG2; |
| 3265 |
|
| 3266 |
if(do_local_envdef || use_Tgm || use_Rgm || use_Lgm) P = esl_exp_surv (env_sc_for_pvalue, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 3267 |
else P = esl_exp_surv (env_sc_for_pvalue, p7_evparam[CM_p7_GFMU], p7_evparam[CM_p7_GFLAMBDA]); |
| 3268 |
if(P > pli->F5b) { |
| 3269 |
if(pli->ddef->dcl[d].ad) p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 3270 |
continue; |
| 3271 |
} |
| 3272 |
} |
| 3273 |
#if eslDEBUGLEVEL >= 2 |
| 3274 |
printf("#DEBUG: SURVIVOR envelope [%10" PRId64 "..%10" PRId64 "] survived F5-bias %6.2f bits P %g\n", pli->ddef->dcl[d].ienv + ws[i] - 1, pli->ddef->dcl[d].jenv + ws[i] - 1, env_sc_for_pvalue, P); |
| 3275 |
#endif |
| 3276 |
pli->acct[pli->cur_pass_idx].n_past_edefbias++; |
| 3277 |
pli->acct[pli->cur_pass_idx].pos_past_edefbias += env_len; |
| 3278 |
|
| 3279 |
if(pli->do_time_F5) { continue; } |
| 3280 |
|
| 3281 |
|
| 3282 |
if((nenv+1) == nenv_alloc) { |
| 3283 |
nenv_alloc *= 2; |
| 3284 |
ESL_RALLOC(es, p, sizeof(int64_t) * nenv_alloc); |
| 3285 |
ESL_RALLOC(ee, p, sizeof(int64_t) * nenv_alloc); |
| 3286 |
ESL_RALLOC(eb, p, sizeof(float) * nenv_alloc); |
| 3287 |
} |
| 3288 |
|
| 3289 |
es[nenv] = pli->ddef->dcl[d].ienv + ws[i] - 1; |
| 3290 |
ee[nenv] = pli->ddef->dcl[d].jenv + ws[i] - 1; |
| 3291 |
eb[nenv] = env_sc_for_pvalue; |
| 3292 |
nenv++; |
| 3293 |
} |
| 3294 |
|
| 3295 |
pli->ddef->ndom = 0; |
| 3296 |
} |
| 3297 |
|
| 3298 |
|
| 3299 |
if(seq != NULL) esl_sq_Destroy(seq); |
| 3300 |
|
| 3301 |
*ret_es = es; |
| 3302 |
*ret_ee = ee; |
| 3303 |
*ret_eb = eb; |
| 3304 |
*ret_nenv = nenv; |
| 3305 |
|
| 3306 |
return eslOK; |
| 3307 |
|
| 3308 |
ERROR: |
| 3309 |
ESL_EXCEPTION(eslEMEM, "Error: out of memory"); |
| 3310 |
} |
| 3311 |
|
| 3312 |
|
| 3313 |
|
| 3314 |
|
| 3315 |
|
| 3316 |
|
| 3317 |
|
| 3318 |
|
| 3319 |
|
| 3320 |
|
| 3321 |
|
| 3322 |
|
| 3323 |
|
| 3324 |
|
| 3325 |
|
| 3326 |
|
| 3327 |
|
| 3328 |
|
| 3329 |
|
| 3330 |
|
| 3331 |
|
| 3332 |
|
| 3333 |
|
| 3334 |
|
| 3335 |
|
| 3336 |
|
| 3337 |
|
| 3338 |
|
| 3339 |
|
| 3340 |
|
| 3341 |
|
| 3342 |
|
| 3343 |
|
| 3344 |
|
| 3345 |
int |
| 3346 |
pli_cyk_env_filter(CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, int64_t *p7es, int64_t *p7ee, int np7env, CM_t **opt_cm, |
| 3347 |
int64_t **ret_es, int64_t **ret_ee, int *ret_nenv) |
| 3348 |
{ |
| 3349 |
int status; |
| 3350 |
float sc; |
| 3351 |
double P; |
| 3352 |
int i, si; |
| 3353 |
double save_tau; |
| 3354 |
int64_t cyk_envi, cyk_envj; |
| 3355 |
float cyk_env_cutoff; |
| 3356 |
CM_t *cm = NULL; |
| 3357 |
int qdbidx; |
| 3358 |
|
| 3359 |
int *i_surv = NULL; |
| 3360 |
int64_t nenv = 0; |
| 3361 |
int64_t *es = NULL; |
| 3362 |
int64_t *ee = NULL; |
| 3363 |
int enforce_i0; |
| 3364 |
int enforce_j0; |
| 3365 |
|
| 3366 |
if (sq->n == 0) return eslOK; |
| 3367 |
if (np7env == 0) return eslOK; |
| 3368 |
|
| 3369 |
|
| 3370 |
if (pli->mode == CM_SCAN_MODELS && (*opt_cm == NULL)) { |
| 3371 |
if((status = pli_scan_mode_read_cm(pli, cm_offset, |
| 3372 |
NULL, 0, |
| 3373 |
opt_cm)) != eslOK) return status; |
| 3374 |
} |
| 3375 |
else { |
| 3376 |
if(opt_cm == NULL || *opt_cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "Entered pli_final_stage() with invalid CM"); |
| 3377 |
} |
| 3378 |
cm = *opt_cm; |
| 3379 |
save_tau = cm->tau; |
| 3380 |
|
| 3381 |
enforce_i0 = cm_pli_PassEnforcesFirstRes(pli->cur_pass_idx) ? TRUE : FALSE; |
| 3382 |
enforce_j0 = cm_pli_PassEnforcesFinalRes(pli->cur_pass_idx) ? TRUE : FALSE; |
| 3383 |
|
| 3384 |
ESL_ALLOC(i_surv, sizeof(int) * np7env); |
| 3385 |
esl_vec_ISet(i_surv, np7env, FALSE); |
| 3386 |
|
| 3387 |
|
| 3388 |
|
| 3389 |
|
| 3390 |
|
| 3391 |
|
| 3392 |
cyk_env_cutoff = cm->expA[pli->fcyk_cm_exp_mode]->mu_extrap + (log(pli->F6env) / (-1 * cm->expA[pli->fcyk_cm_exp_mode]->lambda)); |
| 3393 |
|
| 3394 |
#if eslDEBUGLEVEL >= 2 |
| 3395 |
printf("#DEBUG:\n#DEBUG: PIPELINE EnvCYKFilter() %s %" PRId64 " residues\n", sq->name, sq->n); |
| 3396 |
#endif |
| 3397 |
|
| 3398 |
for (i = 0; i < np7env; i++) { |
| 3399 |
#if eslDEBUGLEVEL >= 2 |
| 3400 |
printf("#DEBUG:\n#DEBUG: SURVIVOR Envelope %5d [%10ld..%10ld] being passed to EnvCYKFilter pass: %" PRId64 "\n", i, p7es[i], p7ee[i], pli->cur_pass_idx); |
| 3401 |
#endif |
| 3402 |
cm->search_opts = pli->fcyk_cm_search_opts; |
| 3403 |
cm->tau = pli->fcyk_tau; |
| 3404 |
qdbidx = (cm->search_opts & CM_SEARCH_NONBANDED) ? SMX_NOQDB : SMX_QDB1_TIGHT; |
| 3405 |
status = pli_dispatch_cm_search(pli, cm, sq->dsq, p7es[i], p7ee[i], NULL, 0., cyk_env_cutoff, qdbidx, &sc, |
| 3406 |
(pli->do_fcykenv) ? &cyk_envi : NULL, |
| 3407 |
(pli->do_fcykenv) ? &cyk_envj : NULL); |
| 3408 |
|
| 3409 |
if(status == eslERANGE) { |
| 3410 |
pli->acct[pli->cur_pass_idx].n_overflow_fcyk++; |
| 3411 |
continue; |
| 3412 |
} |
| 3413 |
else if(status != eslOK) return status; |
| 3414 |
|
| 3415 |
P = esl_exp_surv(sc, cm->expA[pli->fcyk_cm_exp_mode]->mu_extrap, cm->expA[pli->fcyk_cm_exp_mode]->lambda); |
| 3416 |
|
| 3417 |
if (P > pli->F6) continue; |
| 3418 |
|
| 3419 |
i_surv[i] = TRUE; |
| 3420 |
nenv++; |
| 3421 |
|
| 3422 |
if(pli->do_fcykenv && (cyk_envi != -1 && cyk_envj != -1)) { |
| 3423 |
if(! enforce_i0) { p7es[i] = cyk_envi; } |
| 3424 |
if(! enforce_j0) { p7ee[i] = cyk_envj; } |
| 3425 |
} |
| 3426 |
|
| 3427 |
#if eslDEBUGLEVEL >= 2 |
| 3428 |
printf("#DEBUG: SURVIVOR envelope [%10" PRId64 "..%10" PRId64 "] survived EnvCYKFilter %6.2f bits P %g\n", p7es[i], p7ee[i], sc, P); |
| 3429 |
#endif |
| 3430 |
} |
| 3431 |
|
| 3432 |
if(nenv > 0) { |
| 3433 |
ESL_ALLOC(es, sizeof(int64_t) * nenv); |
| 3434 |
ESL_ALLOC(ee, sizeof(int64_t) * nenv); |
| 3435 |
si = 0; |
| 3436 |
for(i = 0; i < np7env; i++) { |
| 3437 |
if(i_surv[i]) { |
| 3438 |
es[si] = p7es[i]; |
| 3439 |
ee[si] = p7ee[i]; |
| 3440 |
pli->acct[pli->cur_pass_idx].n_past_cyk++; |
| 3441 |
pli->acct[pli->cur_pass_idx].pos_past_cyk += ee[si] - es[si] + 1; |
| 3442 |
si++; |
| 3443 |
} |
| 3444 |
} |
| 3445 |
} |
| 3446 |
cm->tau = save_tau; |
| 3447 |
if(i_surv != NULL) free(i_surv); |
| 3448 |
*ret_es = es; |
| 3449 |
*ret_ee = ee; |
| 3450 |
*ret_nenv = nenv; |
| 3451 |
|
| 3452 |
return eslOK; |
| 3453 |
|
| 3454 |
ERROR: |
| 3455 |
cm->tau = save_tau; |
| 3456 |
if(i_surv != NULL) free(i_surv); |
| 3457 |
if(es != NULL) free(es); |
| 3458 |
if(ee != NULL) free(ee); |
| 3459 |
*ret_es = NULL; |
| 3460 |
*ret_ee = NULL; |
| 3461 |
*ret_nenv = 0; |
| 3462 |
ESL_FAIL(status, pli->errbuf, "out of memory"); |
| 3463 |
} |
| 3464 |
|
| 3465 |
|
| 3466 |
|
| 3467 |
|
| 3468 |
|
| 3469 |
|
| 3470 |
|
| 3471 |
|
| 3472 |
|
| 3473 |
|
| 3474 |
|
| 3475 |
|
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
|
| 3480 |
|
| 3481 |
|
| 3482 |
|
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
|
| 3488 |
|
| 3489 |
|
| 3490 |
|
| 3491 |
|
| 3492 |
|
| 3493 |
|
| 3494 |
|
| 3495 |
|
| 3496 |
|
| 3497 |
|
| 3498 |
|
| 3499 |
|
| 3500 |
|
| 3501 |
|
| 3502 |
|
| 3503 |
|
| 3504 |
int |
| 3505 |
pli_cyk_seq_filter(CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, CM_t **opt_cm, int64_t **ret_ws, int64_t **ret_we, int *ret_nwin) |
| 3506 |
{ |
| 3507 |
int status; |
| 3508 |
float sc; |
| 3509 |
double save_tau; |
| 3510 |
float cutoff; |
| 3511 |
CM_t *cm = NULL; |
| 3512 |
int qdbidx; |
| 3513 |
CM_TOPHITS *sq_hitlist = NULL; |
| 3514 |
int do_merge; |
| 3515 |
int h; |
| 3516 |
|
| 3517 |
int64_t nwin = 0; |
| 3518 |
int64_t *ws = NULL; |
| 3519 |
int64_t *we = NULL; |
| 3520 |
int alloc_size = 1000; |
| 3521 |
int nwin_alloc = 0; |
| 3522 |
int64_t iwin, jwin; |
| 3523 |
int64_t next_iwin; |
| 3524 |
|
| 3525 |
if (sq->n == 0) return eslOK; |
| 3526 |
|
| 3527 |
if(pli->fcyk_cm_search_opts & CM_SEARCH_HBANDED) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "pli_cyk_seq_filter() trying to use HMM bands"); |
| 3528 |
|
| 3529 |
|
| 3530 |
if (pli->mode == CM_SCAN_MODELS && (*opt_cm == NULL)) { |
| 3531 |
if((status = pli_scan_mode_read_cm(pli, cm_offset, |
| 3532 |
NULL, 0, |
| 3533 |
opt_cm)) != eslOK) return status; |
| 3534 |
} |
| 3535 |
else { |
| 3536 |
if(opt_cm == NULL || *opt_cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "Entered pli_final_stage() with invalid CM"); |
| 3537 |
} |
| 3538 |
cm = *opt_cm; |
| 3539 |
|
| 3540 |
cm->search_opts = pli->fcyk_cm_search_opts; |
| 3541 |
save_tau = cm->tau; |
| 3542 |
cm->tau = pli->fcyk_tau; |
| 3543 |
qdbidx = (cm->search_opts & CM_SEARCH_NONBANDED) ? SMX_NOQDB : SMX_QDB1_TIGHT; |
| 3544 |
cutoff = cm->expA[pli->fcyk_cm_exp_mode]->mu_extrap + (log(pli->F6) / (-1 * cm->expA[pli->fcyk_cm_exp_mode]->lambda)); |
| 3545 |
sq_hitlist = cm_tophits_Create(); |
| 3546 |
status = pli_dispatch_cm_search(pli, cm, sq->dsq, 1, sq->n, sq_hitlist, cutoff, 0., qdbidx, &sc, NULL, NULL); |
| 3547 |
if(status == eslERANGE) ESL_FAIL(status, pli->errbuf, "pli_cyk_seq_filter(), internal error, trying to use a HMM banded matrix"); |
| 3548 |
else if(status != eslOK) return status; |
| 3549 |
|
| 3550 |
|
| 3551 |
|
| 3552 |
|
| 3553 |
|
| 3554 |
|
| 3555 |
|
| 3556 |
|
| 3557 |
|
| 3558 |
do_merge = (pli->final_cm_search_opts & CM_SEARCH_HBANDED) ? FALSE : TRUE; |
| 3559 |
if(do_merge) { |
| 3560 |
|
| 3561 |
cm_tophits_SortByPosition(sq_hitlist); |
| 3562 |
|
| 3563 |
|
| 3564 |
} |
| 3565 |
|
| 3566 |
for(h = 0; h < sq_hitlist->N; h++) { |
| 3567 |
if(sq_hitlist->hit[h]->stop < sq_hitlist->hit[h]->start) ESL_FAIL(eslEINVAL, pli->errbuf, "pli_cyk_seq_filter() internal error: hit is in revcomp"); |
| 3568 |
|
| 3569 |
iwin = ESL_MAX(1, sq_hitlist->hit[h]->stop - (cm->W-1)); |
| 3570 |
jwin = ESL_MIN(sq->n, sq_hitlist->hit[h]->start + (cm->W-1)); |
| 3571 |
|
| 3572 |
#if eslDEBUGLEVEL >= 2 |
| 3573 |
double P = esl_exp_surv(sq_hitlist->hit[h]->score, cm->expA[pli->fcyk_cm_exp_mode]->mu_extrap, cm->expA[pli->fcyk_cm_exp_mode]->lambda); |
| 3574 |
printf("#DEBUG: SURVIVOR window [%10" PRId64 "..%10" PRId64 "] survived SeqCYKFilter %6.2f bits P %g\n", iwin, jwin, sq_hitlist->hit[h]->score, P); |
| 3575 |
#endif |
| 3576 |
|
| 3577 |
if(do_merge) { |
| 3578 |
if((h+1) < sq_hitlist->N) { |
| 3579 |
next_iwin = ((h+1) < sq_hitlist->N) ? ESL_MAX(1, sq_hitlist->hit[h+1]->stop - (cm->W-1)) : sq->n+1; |
| 3580 |
while(next_iwin <= jwin) { |
| 3581 |
h++; |
| 3582 |
jwin = ESL_MIN(sq->n, sq_hitlist->hit[h]->start + (cm->W-1)); |
| 3583 |
|
| 3584 |
next_iwin = ((h+1) < sq_hitlist->N) ? ESL_MAX(1, sq_hitlist->hit[h+1]->stop - (cm->W-1)) : sq->n+1; |
| 3585 |
|
| 3586 |
} |
| 3587 |
} |
| 3588 |
} |
| 3589 |
|
| 3590 |
if(nwin == nwin_alloc) { |
| 3591 |
nwin_alloc += alloc_size; |
| 3592 |
ESL_REALLOC(ws, sizeof(int64_t) * nwin_alloc); |
| 3593 |
ESL_REALLOC(we, sizeof(int64_t) * nwin_alloc); |
| 3594 |
} |
| 3595 |
ws[nwin] = iwin; |
| 3596 |
we[nwin] = jwin; |
| 3597 |
nwin++; |
| 3598 |
|
| 3599 |
pli->acct[pli->cur_pass_idx].n_past_cyk++; |
| 3600 |
pli->acct[pli->cur_pass_idx].pos_past_cyk += jwin-iwin+1; |
| 3601 |
} |
| 3602 |
cm->tau = save_tau; |
| 3603 |
|
| 3604 |
if(sq_hitlist != NULL) cm_tophits_Destroy(sq_hitlist); |
| 3605 |
*ret_ws = ws; |
| 3606 |
*ret_we = we; |
| 3607 |
*ret_nwin = nwin; |
| 3608 |
|
| 3609 |
return eslOK; |
| 3610 |
|
| 3611 |
ERROR: |
| 3612 |
if(sq_hitlist != NULL) cm_tophits_Destroy(sq_hitlist); |
| 3613 |
cm->tau = save_tau; |
| 3614 |
*ret_ws = NULL; |
| 3615 |
*ret_we = NULL; |
| 3616 |
*ret_nwin = 0; |
| 3617 |
ESL_FAIL(status, pli->errbuf, "out of memory"); |
| 3618 |
} |
| 3619 |
|
| 3620 |
|
| 3621 |
|
| 3622 |
|
| 3623 |
|
| 3624 |
|
| 3625 |
|
| 3626 |
|
| 3627 |
|
| 3628 |
|
| 3629 |
|
| 3630 |
|
| 3631 |
|
| 3632 |
|
| 3633 |
|
| 3634 |
|
| 3635 |
|
| 3636 |
|
| 3637 |
|
| 3638 |
|
| 3639 |
|
| 3640 |
|
| 3641 |
|
| 3642 |
|
| 3643 |
|
| 3644 |
|
| 3645 |
|
| 3646 |
int |
| 3647 |
pli_final_stage(CM_PIPELINE *pli, off_t cm_offset, const ESL_SQ *sq, int64_t *es, int64_t *ee, int nenv, CM_TOPHITS *hitlist, CM_t **opt_cm) |
| 3648 |
{ |
| 3649 |
int status; |
| 3650 |
CM_HIT *hit = NULL; |
| 3651 |
float sc; |
| 3652 |
int i, h; |
| 3653 |
int nhit; |
| 3654 |
double save_tau; |
| 3655 |
CM_t *cm = NULL; |
| 3656 |
CP9Bands_t *scan_cp9b = NULL; |
| 3657 |
int qdbidx; |
| 3658 |
|
| 3659 |
if (sq->n == 0) return eslOK; |
| 3660 |
if (nenv == 0) return eslOK; |
| 3661 |
|
| 3662 |
|
| 3663 |
if (pli->mode == CM_SCAN_MODELS && (*opt_cm == NULL)) { |
| 3664 |
if((status = pli_scan_mode_read_cm(pli, cm_offset, |
| 3665 |
NULL, 0, |
| 3666 |
opt_cm)) != eslOK) return status; |
| 3667 |
} |
| 3668 |
else { |
| 3669 |
if(opt_cm == NULL || *opt_cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "Entered pli_final_stage() with invalid CM"); |
| 3670 |
} |
| 3671 |
cm = *opt_cm; |
| 3672 |
save_tau = cm->tau; |
| 3673 |
|
| 3674 |
for (i = 0; i < nenv; i++) { |
| 3675 |
#if eslDEBUGLEVEL >= 2 |
| 3676 |
printf("#DEBUG:\n#DEBUG: SURVIVOR Envelope %5d [%10ld..%10ld] being passed to Final stage pass: %" PRId64 "\n", i, es[i], ee[i], pli->cur_pass_idx); |
| 3677 |
#endif |
| 3678 |
nhit = hitlist->N; |
| 3679 |
cm->search_opts = pli->final_cm_search_opts; |
| 3680 |
cm->tau = pli->final_tau; |
| 3681 |
qdbidx = (cm->search_opts & CM_SEARCH_NONBANDED) ? SMX_NOQDB : SMX_QDB2_LOOSE; |
| 3682 |
status = pli_dispatch_cm_search(pli, cm, sq->dsq, es[i], ee[i], hitlist, pli->T, 0., qdbidx, &sc, NULL, NULL); |
| 3683 |
if(status == eslERANGE) { |
| 3684 |
pli->acct[pli->cur_pass_idx].n_overflow_final++; |
| 3685 |
continue; |
| 3686 |
} |
| 3687 |
else if(status != eslOK) return status; |
| 3688 |
|
| 3689 |
|
| 3690 |
|
| 3691 |
|
| 3692 |
if(cm->search_opts & CM_SEARCH_HBANDED) { |
| 3693 |
scan_cp9b = cp9_CloneBands(cm->cp9b, pli->errbuf); |
| 3694 |
if(scan_cp9b == NULL) return eslEMEM; |
| 3695 |
#if eslDEBUGLEVEL >= 1 |
| 3696 |
if((status = cp9_ValidateBands(cm, pli->errbuf, cm->cp9b, es[i], ee[i], cm_pli_PassAllowsTruncation(pli->cur_pass_idx))) != eslOK) return status; |
| 3697 |
ESL_DPRINTF1(("#DEBUG: original bands validated.\n")); |
| 3698 |
if((status = cp9_ValidateBands(cm, pli->errbuf, scan_cp9b, es[i], ee[i], cm_pli_PassAllowsTruncation(pli->cur_pass_idx))) != eslOK) return status; |
| 3699 |
ESL_DPRINTF1(("#DEBUG: cloned bands validated.\n")); |
| 3700 |
#endif |
| 3701 |
} |
| 3702 |
else { |
| 3703 |
scan_cp9b = NULL; |
| 3704 |
} |
| 3705 |
|
| 3706 |
|
| 3707 |
for (h = nhit; h < hitlist->N; h++) { |
| 3708 |
hit = &(hitlist->unsrt[h]); |
| 3709 |
hit->cm_idx = pli->cur_cm_idx; |
| 3710 |
hit->clan_idx = pli->cur_clan_idx; |
| 3711 |
hit->seq_idx = pli->cur_seq_idx; |
| 3712 |
hit->pass_idx = pli->cur_pass_idx; |
| 3713 |
hit->pvalue = esl_exp_surv(hit->score, cm->expA[pli->final_cm_exp_mode]->mu_extrap, cm->expA[pli->final_cm_exp_mode]->lambda); |
| 3714 |
hit->srcL = sq->L; |
| 3715 |
hit->glocal = (pli->final_cm_exp_mode == EXP_CM_GI || pli->final_cm_exp_mode == EXP_CM_GC) ? TRUE : FALSE; |
| 3716 |
|
| 3717 |
|
| 3718 |
hit->evalue = 0.; |
| 3719 |
hit->has_evalue = FALSE; |
| 3720 |
hit->ad = NULL; |
| 3721 |
|
| 3722 |
if (pli->mode == CM_SEARCH_SEQS) { |
| 3723 |
if ( (status = esl_strdup(sq->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3724 |
if (sq->acc[0] != '\0' && (status = esl_strdup(sq->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3725 |
if (sq->desc[0] != '\0' && (status = esl_strdup(sq->desc, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3726 |
} |
| 3727 |
else { |
| 3728 |
if ((status = esl_strdup(cm->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3729 |
if ((status = esl_strdup(cm->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3730 |
if ((status = esl_strdup(cm->desc, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 3731 |
} |
| 3732 |
#if eslDEBUGLEVEL >= 2 |
| 3733 |
printf("#DEBUG: SURVIVOR envelope [%10ld..%10ld] survived Inside %6.2f bits P %g\n", hit->start, hit->stop, hit->score, hit->pvalue); |
| 3734 |
#endif |
| 3735 |
|
| 3736 |
|
| 3737 |
|
| 3738 |
|
| 3739 |
|
| 3740 |
|
| 3741 |
if(h > nhit && scan_cp9b != NULL) { |
| 3742 |
if(cm->cp9b != NULL) FreeCP9Bands(cm->cp9b); |
| 3743 |
cm->cp9b = cp9_CloneBands(scan_cp9b, pli->errbuf); |
| 3744 |
if(cm->cp9b == NULL) return status; |
| 3745 |
} |
| 3746 |
|
| 3747 |
|
| 3748 |
|
| 3749 |
|
| 3750 |
|
| 3751 |
|
| 3752 |
|
| 3753 |
|
| 3754 |
|
| 3755 |
|
| 3756 |
|
| 3757 |
if(scan_cp9b != NULL && (! (pli->cm_align_opts & CM_ALIGN_HBANDED))) { |
| 3758 |
ESL_FAIL(eslEINVAL, pli->errbuf, "used HMM bands for Inside search stage, but won't for hit alignment, this shouldn't happen"); |
| 3759 |
} |
| 3760 |
if(scan_cp9b == NULL && (pli->cm_align_opts & CM_ALIGN_HBANDED)) { |
| 3761 |
ESL_FAIL(eslEINVAL, pli->errbuf, "did not use HMM bands for Inside search stage, but will for hit alignment, this shouldn't happen"); |
| 3762 |
} |
| 3763 |
if((status = pli_align_hit(pli, cm, sq, hit)) != eslOK) return status; |
| 3764 |
|
| 3765 |
|
| 3766 |
|
| 3767 |
|
| 3768 |
|
| 3769 |
|
| 3770 |
|
| 3771 |
|
| 3772 |
|
| 3773 |
|
| 3774 |
|
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
|
| 3784 |
|
| 3785 |
|
| 3786 |
|
| 3787 |
|
| 3788 |
|
| 3789 |
|
| 3790 |
|
| 3791 |
|
| 3792 |
|
| 3793 |
|
| 3794 |
if (pli->use_bit_cutoffs) { |
| 3795 |
if (cm_pli_TargetReportable(pli, hit->score, hit->evalue)) { |
| 3796 |
hit->flags |= CM_HIT_IS_REPORTED; |
| 3797 |
if (cm_pli_TargetIncludable(pli, hit->score, hit->evalue)) |
| 3798 |
hit->flags |= CM_HIT_IS_INCLUDED; |
| 3799 |
} |
| 3800 |
} |
| 3801 |
} |
| 3802 |
if(scan_cp9b != NULL) { |
| 3803 |
FreeCP9Bands(scan_cp9b); |
| 3804 |
scan_cp9b = NULL; |
| 3805 |
} |
| 3806 |
} |
| 3807 |
cm->tau = save_tau; |
| 3808 |
|
| 3809 |
if(scan_cp9b != NULL) FreeCP9Bands(scan_cp9b); |
| 3810 |
|
| 3811 |
return eslOK; |
| 3812 |
} |
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
|
| 3819 |
|
| 3820 |
|
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
|
| 3830 |
|
| 3831 |
|
| 3832 |
|
| 3833 |
|
| 3834 |
|
| 3835 |
|
| 3836 |
|
| 3837 |
int |
| 3838 |
pli_final_stage_hmmonly(CM_PIPELINE *pli, off_t cm_offset, P7_OPROFILE *om, P7_BG *bg, float *p7_evparam, const ESL_SQ *sq, int64_t *ws, int64_t *we, int nwin, CM_TOPHITS *hitlist, CM_t **opt_cm) |
| 3839 |
{ |
| 3840 |
int status; |
| 3841 |
int i, d; |
| 3842 |
CM_HIT *hit = NULL; |
| 3843 |
CM_t *cm = NULL; |
| 3844 |
ESL_DSQ *subdsq; |
| 3845 |
ESL_SQ *seq = NULL; |
| 3846 |
int64_t wlen; |
| 3847 |
int64_t prv_sqto; |
| 3848 |
int env_len; |
| 3849 |
float nullsc; |
| 3850 |
float avgpp; |
| 3851 |
|
| 3852 |
|
| 3853 |
|
| 3854 |
|
| 3855 |
|
| 3856 |
|
| 3857 |
|
| 3858 |
|
| 3859 |
int ali_len; |
| 3860 |
float bitscore; |
| 3861 |
int loc_window_length; |
| 3862 |
int window_len; |
| 3863 |
float nullsc2; |
| 3864 |
float dom_bias; |
| 3865 |
float dom_score; |
| 3866 |
|
| 3867 |
|
| 3868 |
|
| 3869 |
|
| 3870 |
|
| 3871 |
int64_t *rerun_ws = NULL; |
| 3872 |
int64_t *rerun_we = NULL; |
| 3873 |
int64_t cur_rerun_ws; |
| 3874 |
int64_t cur_rerun_we; |
| 3875 |
int rerun_nwin = 0; |
| 3876 |
int rerun_nalloc = 0; |
| 3877 |
|
| 3878 |
if (sq->n == 0) return eslOK; |
| 3879 |
if (nwin == 0) return eslOK; |
| 3880 |
seq = esl_sq_CreateDigital(sq->abc); |
| 3881 |
|
| 3882 |
|
| 3883 |
if (pli->mode == CM_SCAN_MODELS && (*opt_cm == NULL)) { |
| 3884 |
if((status = pli_scan_mode_read_cm(pli, cm_offset, p7_evparam, om->max_length, opt_cm)) != eslOK) return status; |
| 3885 |
} |
| 3886 |
else { |
| 3887 |
if(opt_cm == NULL || *opt_cm == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "Entered pli_final_stage() with invalid CM"); |
| 3888 |
} |
| 3889 |
cm = *opt_cm; |
| 3890 |
|
| 3891 |
|
| 3892 |
|
| 3893 |
|
| 3894 |
loc_window_length = om->max_length; |
| 3895 |
nullsc2 = (float)loc_window_length * log((float)loc_window_length/(loc_window_length+1)) + log(1./(loc_window_length+1)); |
| 3896 |
|
| 3897 |
for (i = 0; i < nwin; i++) { |
| 3898 |
#if eslDEBUGLEVEL >= 2 |
| 3899 |
printf("#DEBUG: p7 final stage win: %4d of %4d [%6" PRId64 "..%6" PRId64 "] pass: %" PRId64 "\n", i, nwin, ws[i], we[i], pli->cur_pass_idx); |
| 3900 |
#endif |
| 3901 |
|
| 3902 |
wlen = we[i] - ws[i] + 1; |
| 3903 |
subdsq = sq->dsq + ws[i] - 1; |
| 3904 |
|
| 3905 |
esl_sq_GrowTo(seq, wlen); |
| 3906 |
memcpy((void*)(seq->dsq), subdsq, (wlen+1) * sizeof(uint8_t)); |
| 3907 |
seq->dsq[0] = seq->dsq[wlen+1] = eslDSQ_SENTINEL; |
| 3908 |
seq->n = wlen; |
| 3909 |
|
| 3910 |
p7_bg_SetLength(bg, wlen); |
| 3911 |
p7_bg_NullOne(bg, seq->dsq, wlen, &nullsc); |
| 3912 |
|
| 3913 |
|
| 3914 |
|
| 3915 |
|
| 3916 |
p7_oprofile_ReconfigLength(om, wlen); |
| 3917 |
p7_ForwardParser(seq->dsq, wlen, om, pli->oxf, NULL); |
| 3918 |
p7_omx_GrowTo(pli->oxb, om->M, 0, wlen); |
| 3919 |
p7_BackwardParser(seq->dsq, wlen, om, pli->oxf, pli->oxb, NULL); |
| 3920 |
status = p7_domaindef_ByPosteriorHeuristics (seq, NULL, om, pli->oxf, pli->oxb, pli->fwd, pli->bck, pli->ddef, bg, FALSE, |
| 3921 |
NULL, NULL, NULL); |
| 3922 |
|
| 3923 |
if (status != eslOK) ESL_FAIL(status, pli->errbuf, "envelope definition workflow failure"); |
| 3924 |
if (pli->ddef->nregions == 0) continue; |
| 3925 |
if (pli->ddef->nenvelopes == 0) continue; |
| 3926 |
|
| 3927 |
|
| 3928 |
for(d = 0; d < pli->ddef->ndom; d++) { |
| 3929 |
|
| 3930 |
|
| 3931 |
|
| 3932 |
|
| 3933 |
|
| 3934 |
|
| 3935 |
|
| 3936 |
if((d > 0) && (pli->ddef->dcl[d].ad->sqfrom <= prv_sqto)) { |
| 3937 |
|
| 3938 |
cur_rerun_ws = prv_sqto + ws[i] - 1 + 1; |
| 3939 |
cur_rerun_we = pli->ddef->dcl[d].ad->sqto + ws[i] - 1; |
| 3940 |
if(cur_rerun_ws <= cur_rerun_we) { |
| 3941 |
|
| 3942 |
if(rerun_nwin == rerun_nalloc) { |
| 3943 |
rerun_nalloc += 10; |
| 3944 |
ESL_REALLOC(rerun_ws, sizeof(int64_t) * rerun_nalloc); |
| 3945 |
ESL_REALLOC(rerun_we, sizeof(int64_t) * rerun_nalloc); |
| 3946 |
} |
| 3947 |
rerun_ws[rerun_nwin] = cur_rerun_ws; |
| 3948 |
rerun_we[rerun_nwin] = cur_rerun_we; |
| 3949 |
rerun_nwin++; |
| 3950 |
} |
| 3951 |
|
| 3952 |
prv_sqto = pli->ddef->dcl[d].ad->sqto; |
| 3953 |
p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 3954 |
pli->ddef->dcl[d].ad = NULL; |
| 3955 |
} |
| 3956 |
else { |
| 3957 |
|
| 3958 |
|
| 3959 |
|
| 3960 |
|
| 3961 |
|
| 3962 |
|
| 3963 |
|
| 3964 |
|
| 3965 |
|
| 3966 |
|
| 3967 |
|
| 3968 |
|
| 3969 |
|
| 3970 |
|
| 3971 |
|
| 3972 |
|
| 3973 |
|
| 3974 |
|
| 3975 |
env_len = pli->ddef->dcl[d].jenv - pli->ddef->dcl[d].ienv + 1; |
| 3976 |
ali_len = pli->ddef->dcl[d].jali - pli->ddef->dcl[d].iali + 1; |
| 3977 |
bitscore = pli->ddef->dcl[d].envsc; |
| 3978 |
window_len = wlen; |
| 3979 |
|
| 3980 |
bitscore -= 2 * log(2. / (window_len+2)) + (env_len-ali_len) * log((float)window_len / (window_len+2)); |
| 3981 |
bitscore += 2 * log(2. / (loc_window_length+2)); |
| 3982 |
|
| 3983 |
bitscore += (ESL_MAX(loc_window_length, env_len) - ali_len) * log((float)loc_window_length / (float) (loc_window_length+2)); |
| 3984 |
|
| 3985 |
dom_bias = pli->do_null2_hmmonly ? p7_FLogsum(0.0, log(bg->omega) + pli->ddef->dcl[d].domcorrection) : 0.0; |
| 3986 |
dom_score = (bitscore - (nullsc2 + dom_bias)) / eslCONST_LOG2; |
| 3987 |
prv_sqto = pli->ddef->dcl[d].ad->sqto; |
| 3988 |
|
| 3989 |
if(dom_score >= pli->T) { |
| 3990 |
cm_tophits_CreateNextHit(hitlist, &hit); |
| 3991 |
|
| 3992 |
|
| 3993 |
|
| 3994 |
|
| 3995 |
|
| 3996 |
pli->ddef->dcl[d].ad->sqfrom += ws[i] - 1; |
| 3997 |
pli->ddef->dcl[d].ad->sqto += ws[i] - 1; |
| 3998 |
hit->start = pli->ddef->dcl[d].ad->sqfrom; |
| 3999 |
hit->stop = pli->ddef->dcl[d].ad->sqto; |
| 4000 |
hit->root = -1; |
| 4001 |
hit->mode = TRMODE_J; |
| 4002 |
hit->score = dom_score; |
| 4003 |
|
| 4004 |
hit->cm_idx = pli->cur_cm_idx; |
| 4005 |
hit->clan_idx = pli->cur_clan_idx; |
| 4006 |
hit->seq_idx = pli->cur_seq_idx; |
| 4007 |
hit->pass_idx = pli->cur_pass_idx; |
| 4008 |
hit->pvalue = esl_exp_surv (hit->score, p7_evparam[CM_p7_LFTAU], p7_evparam[CM_p7_LFLAMBDA]); |
| 4009 |
hit->srcL = sq->L; |
| 4010 |
|
| 4011 |
hit->hmmonly = TRUE; |
| 4012 |
hit->glocal = FALSE; |
| 4013 |
hit->bias = dom_bias; |
| 4014 |
hit->evalue = 0.; |
| 4015 |
|
| 4016 |
|
| 4017 |
avgpp = pli->ddef->dcl[d].oasc / (1.0 + fabs((float) (pli->ddef->dcl[d].jenv - pli->ddef->dcl[d].ienv))); |
| 4018 |
if((status = cm_alidisplay_CreateFromP7(cm, pli->errbuf, sq, hit->start, hit->score, avgpp, pli->ddef->dcl[d].ad, &(hit->ad))) != eslOK) return status; |
| 4019 |
|
| 4020 |
p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 4021 |
pli->ddef->dcl[d].ad = NULL; |
| 4022 |
|
| 4023 |
#if eslDEBUGLEVEL >= 2 |
| 4024 |
printf("#DEBUG: SURVIVOR envelope [%10ld..%10ld] survived Final HMM ONLY stage %6.2f bits P %g\n", hit->start, hit->stop, hit->score, hit->pvalue); |
| 4025 |
#endif |
| 4026 |
|
| 4027 |
if (pli->mode == CM_SEARCH_SEQS) { |
| 4028 |
if ( (status = esl_strdup(sq->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4029 |
if (sq->acc[0] != '\0' && (status = esl_strdup(sq->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4030 |
if (sq->desc[0] != '\0' && (status = esl_strdup(sq->desc, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4031 |
} |
| 4032 |
else { |
| 4033 |
if ((status = esl_strdup(cm->name, -1, &(hit->name))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4034 |
if ((status = esl_strdup(cm->acc, -1, &(hit->acc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4035 |
if ((status = esl_strdup(cm->desc, -1, &(hit->desc))) != eslOK) ESL_FAIL(eslEMEM, pli->errbuf, "allocation failure"); |
| 4036 |
} |
| 4037 |
|
| 4038 |
|
| 4039 |
|
| 4040 |
|
| 4041 |
|
| 4042 |
|
| 4043 |
|
| 4044 |
|
| 4045 |
|
| 4046 |
|
| 4047 |
|
| 4048 |
|
| 4049 |
|
| 4050 |
|
| 4051 |
|
| 4052 |
|
| 4053 |
|
| 4054 |
|
| 4055 |
|
| 4056 |
|
| 4057 |
|
| 4058 |
|
| 4059 |
|
| 4060 |
|
| 4061 |
|
| 4062 |
|
| 4063 |
|
| 4064 |
|
| 4065 |
if (pli->use_bit_cutoffs) { |
| 4066 |
if (cm_pli_TargetReportable(pli, hit->score, hit->evalue)) { |
| 4067 |
hit->flags |= CM_HIT_IS_REPORTED; |
| 4068 |
if (cm_pli_TargetIncludable(pli, hit->score, hit->evalue)) |
| 4069 |
hit->flags |= CM_HIT_IS_INCLUDED; |
| 4070 |
} |
| 4071 |
} |
| 4072 |
} |
| 4073 |
else { |
| 4074 |
p7_alidisplay_Destroy(pli->ddef->dcl[d].ad); |
| 4075 |
pli->ddef->dcl[d].ad = NULL; |
| 4076 |
} |
| 4077 |
} |
| 4078 |
} |
| 4079 |
pli->ddef->ndom = 0; |
| 4080 |
} |
| 4081 |
|
| 4082 |
|
| 4083 |
|
| 4084 |
if(rerun_nwin > 0) { |
| 4085 |
pli_final_stage_hmmonly(pli, cm_offset, om, bg, p7_evparam, sq, rerun_ws, rerun_we, rerun_nwin, hitlist, opt_cm); |
| 4086 |
} |
| 4087 |
|
| 4088 |
|
| 4089 |
if(seq != NULL) esl_sq_Destroy(seq); |
| 4090 |
if(rerun_ws != NULL) free(rerun_ws); |
| 4091 |
if(rerun_we != NULL) free(rerun_we); |
| 4092 |
|
| 4093 |
return eslOK; |
| 4094 |
|
| 4095 |
ERROR: |
| 4096 |
if(rerun_ws != NULL) free(rerun_ws); |
| 4097 |
if(rerun_we != NULL) free(rerun_we); |
| 4098 |
ESL_FAIL(status, pli->errbuf, "out of memory"); |
| 4099 |
} |
| 4100 |
|
| 4101 |
|
| 4102 |
|
| 4103 |
|
| 4104 |
|
| 4105 |
|
| 4106 |
|
| 4107 |
|
| 4108 |
|
| 4109 |
|
| 4110 |
|
| 4111 |
|
| 4112 |
|
| 4113 |
|
| 4114 |
|
| 4115 |
|
| 4116 |
|
| 4117 |
|
| 4118 |
|
| 4119 |
|
| 4120 |
|
| 4121 |
|
| 4122 |
|
| 4123 |
|
| 4124 |
|
| 4125 |
|
| 4126 |
|
| 4127 |
int pli_dispatch_cm_search(CM_PIPELINE *pli, CM_t *cm, ESL_DSQ *dsq, int64_t start, int64_t stop, CM_TOPHITS *hitlist, float cutoff, |
| 4128 |
float env_cutoff, int qdbidx, float *ret_sc, int64_t *opt_envi, int64_t *opt_envj) |
| 4129 |
{ |
| 4130 |
int status; |
| 4131 |
int do_trunc = cm_pli_PassAllowsTruncation(pli->cur_pass_idx); |
| 4132 |
int do_inside = (cm->search_opts & CM_SEARCH_INSIDE) ? TRUE : FALSE; |
| 4133 |
int do_hbanded = (cm->search_opts & CM_SEARCH_HBANDED) ? TRUE : FALSE; |
| 4134 |
int do_qdb_or_nonbanded = (do_hbanded) ? FALSE : TRUE; |
| 4135 |
double save_tau = cm->tau; |
| 4136 |
float save_thresh1 = (cm->cp9b == NULL) ? -1. : cm->cp9b->thresh1; |
| 4137 |
float save_thresh2 = (cm->cp9b == NULL) ? -1. : cm->cp9b->thresh2; |
| 4138 |
float hbmx_Mb = 0.; |
| 4139 |
float sc = 0.; |
| 4140 |
float mxsize_limit = (pli->mxsize_set) ? pli->mxsize_limit : pli_mxsize_limit_from_W(cm->W); |
| 4141 |
|
| 4142 |
#if eslDEBUGLEVEL >= 1 |
| 4143 |
printf("in pli_dispatch_cm_search(): do_trunc: %d do_inside: %d cutoff: %.1f env_cutoff: %.1f do_hbanded: %d hitlist?: %d opt_envi/j?: %d start: %" PRId64 " stop: %" PRId64 "\n", |
| 4144 |
do_trunc, do_inside, cutoff, env_cutoff, do_hbanded, (hitlist == NULL) ? 0 : 1, (opt_envi == NULL && opt_envj == NULL) ? 0 : 1, start, stop); |
| 4145 |
#endif |
| 4146 |
|
| 4147 |
if(do_hbanded) { |
| 4148 |
status = cp9_IterateSeq2Bands(cm, pli->errbuf, dsq, start, stop, pli->cur_pass_idx, mxsize_limit, |
| 4149 |
TRUE, FALSE, FALSE, |
| 4150 |
(! pli->do_not_iterate), pli->maxtau, &hbmx_Mb); |
| 4151 |
if(status == eslERANGE) { |
| 4152 |
|
| 4153 |
|
| 4154 |
|
| 4155 |
|
| 4156 |
|
| 4157 |
|
| 4158 |
goto ERROR; |
| 4159 |
} |
| 4160 |
else if(status != eslOK) { |
| 4161 |
printf("pli_dispatch_cm_search(), error: %s\n", pli->errbuf); goto ERROR; |
| 4162 |
} |
| 4163 |
else if(status == eslOK) { |
| 4164 |
|
| 4165 |
if(do_trunc) { |
| 4166 |
if(do_inside) { |
| 4167 |
status = FTrInsideScanHB(cm, pli->errbuf, cm->trhb_mx, mxsize_limit, pli->cur_pass_idx, dsq, start, stop, |
| 4168 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, &sc); |
| 4169 |
} |
| 4170 |
else { |
| 4171 |
status = TrCYKScanHB(cm, pli->errbuf, cm->trhb_mx, mxsize_limit, pli->cur_pass_idx, dsq, start, stop, |
| 4172 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, &sc); |
| 4173 |
} |
| 4174 |
} |
| 4175 |
else { |
| 4176 |
if(do_inside) { |
| 4177 |
status = FastFInsideScanHB(cm, pli->errbuf, cm->hb_mx, mxsize_limit, dsq, start, stop, |
| 4178 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, &sc); |
| 4179 |
} |
| 4180 |
else { |
| 4181 |
status = FastCYKScanHB(cm, pli->errbuf, cm->hb_mx, mxsize_limit, dsq, start, stop, |
| 4182 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, &sc); |
| 4183 |
} |
| 4184 |
} |
| 4185 |
} |
| 4186 |
} |
| 4187 |
else if (do_qdb_or_nonbanded) { |
| 4188 |
if(do_trunc) { |
| 4189 |
if(cm->trsmx == NULL) ESL_XFAIL(eslEINVAL, pli->errbuf, "pli_dispatch_cm_search(), need truncated scan mx but don't have one"); |
| 4190 |
if(do_inside) { |
| 4191 |
status = RefITrInsideScan(cm, pli->errbuf, cm->trsmx, qdbidx, pli->cur_pass_idx, dsq, start, stop, |
| 4192 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, NULL, &sc); |
| 4193 |
} |
| 4194 |
else { |
| 4195 |
status = RefTrCYKScan(cm, pli->errbuf, cm->trsmx, qdbidx, pli->cur_pass_idx, dsq, start, stop, |
| 4196 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, NULL, &sc); |
| 4197 |
} |
| 4198 |
} |
| 4199 |
else { |
| 4200 |
if(cm->smx == NULL) ESL_XFAIL(eslEINVAL, pli->errbuf, "pli_dispatch_cm_search(), need standard scan mx but don't have one"); |
| 4201 |
if(do_inside) { |
| 4202 |
status = FastIInsideScan(cm, pli->errbuf, cm->smx, qdbidx, dsq, start, stop, |
| 4203 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, &sc); |
| 4204 |
} |
| 4205 |
else { |
| 4206 |
status = FastCYKScan(cm, pli->errbuf, cm->smx, qdbidx, dsq, start, stop, |
| 4207 |
cutoff, hitlist, pli->do_null3, env_cutoff, opt_envi, opt_envj, NULL, &sc); |
| 4208 |
} |
| 4209 |
} |
| 4210 |
if(status != eslOK) { printf("pli_dispatch_cm_search(), error: %s\n", pli->errbuf); goto ERROR; } |
| 4211 |
} |
| 4212 |
|
| 4213 |
|
| 4214 |
cm->tau = save_tau; |
| 4215 |
if(cm->cp9b != NULL) { |
| 4216 |
cm->cp9b->thresh1 = save_thresh1; |
| 4217 |
cm->cp9b->thresh2 = save_thresh2; |
| 4218 |
} |
| 4219 |
|
| 4220 |
*ret_sc = sc; |
| 4221 |
|
| 4222 |
return eslOK; |
| 4223 |
|
| 4224 |
ERROR: |
| 4225 |
cm->tau = save_tau; |
| 4226 |
|
| 4227 |
if(cm->cp9b != NULL) { |
| 4228 |
cm->cp9b->thresh1 = save_thresh1; |
| 4229 |
cm->cp9b->thresh2 = save_thresh2; |
| 4230 |
} |
| 4231 |
*ret_sc = IMPOSSIBLE; |
| 4232 |
if(opt_envi != NULL) *opt_envi = start; |
| 4233 |
if(opt_envj != NULL) *opt_envi = stop; |
| 4234 |
return eslERANGE; |
| 4235 |
} |
| 4236 |
|
| 4237 |
|
| 4238 |
|
| 4239 |
|
| 4240 |
|
| 4241 |
|
| 4242 |
|
| 4243 |
|
| 4244 |
|
| 4245 |
|
| 4246 |
|
| 4247 |
|
| 4248 |
|
| 4249 |
|
| 4250 |
|
| 4251 |
|
| 4252 |
|
| 4253 |
|
| 4254 |
|
| 4255 |
|
| 4256 |
|
| 4257 |
|
| 4258 |
|
| 4259 |
|
| 4260 |
int |
| 4261 |
pli_align_hit(CM_PIPELINE *pli, CM_t *cm, const ESL_SQ *sq, CM_HIT *hit) |
| 4262 |
{ |
| 4263 |
int status; |
| 4264 |
CM_ALNDATA *adata = NULL; |
| 4265 |
ESL_SQ *sq2aln = NULL; |
| 4266 |
ESL_STOPWATCH *watch = NULL; |
| 4267 |
float null3_correction; |
| 4268 |
float mxsize_limit = (pli->mxsize_set) ? pli->mxsize_limit : pli_mxsize_limit_from_W(cm->W); |
| 4269 |
|
| 4270 |
if(cm->cmcons == NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "pli_align_hit() cm->cmcons is NULL"); |
| 4271 |
|
| 4272 |
if((watch = esl_stopwatch_Create()) == NULL) ESL_XFAIL(eslEMEM, pli->errbuf, "out of memory"); |
| 4273 |
esl_stopwatch_Start(watch); |
| 4274 |
|
| 4275 |
|
| 4276 |
if((sq2aln = esl_sq_CreateDigitalFrom(cm->abc, "seq", sq->dsq + hit->start - 1, hit->stop - hit->start + 1, NULL, NULL, NULL)) == NULL) {status = eslEMEM; goto ERROR; } |
| 4277 |
|
| 4278 |
cm->align_opts = pli->cm_align_opts; |
| 4279 |
if(pli->cur_pass_idx != PLI_PASS_STD_ANY) cm->align_opts |= CM_ALIGN_TRUNC; |
| 4280 |
|
| 4281 |
|
| 4282 |
if(cm->align_opts & CM_ALIGN_HBANDED) { |
| 4283 |
|
| 4284 |
|
| 4285 |
|
| 4286 |
|
| 4287 |
|
| 4288 |
|
| 4289 |
|
| 4290 |
cp9_ShiftCMBands(cm, hit->start, hit->stop, (cm->align_opts & CM_ALIGN_TRUNC) ? TRUE : FALSE); |
| 4291 |
|
| 4292 |
|
| 4293 |
if(! (cm->align_opts & CM_ALIGN_POST)) ESL_XFAIL(eslEINVAL, pli->errbuf, "pli_align_hit() using HMM bands but CM_ALIGN_POST is down"); |
| 4294 |
|
| 4295 |
|
| 4296 |
status = DispatchSqAlignment(cm, pli->errbuf, sq2aln, -1, mxsize_limit, hit->mode, pli->cur_pass_idx, |
| 4297 |
TRUE, |
| 4298 |
NULL, NULL, NULL, &adata); |
| 4299 |
if(status != eslOK && status != eslERANGE) { |
| 4300 |
goto ERROR; |
| 4301 |
} |
| 4302 |
else if(status == eslERANGE) { |
| 4303 |
|
| 4304 |
cm->align_opts &= ~CM_ALIGN_OPTACC; |
| 4305 |
cm->align_opts &= ~CM_ALIGN_POST; |
| 4306 |
cm->align_opts |= CM_ALIGN_CYK; |
| 4307 |
|
| 4308 |
|
| 4309 |
|
| 4310 |
|
| 4311 |
|
| 4312 |
|
| 4313 |
|
| 4314 |
|
| 4315 |
|
| 4316 |
|
| 4317 |
|
| 4318 |
status = DispatchSqAlignment(cm, pli->errbuf, sq2aln, -1, 2*mxsize_limit, hit->mode, pli->cur_pass_idx, |
| 4319 |
TRUE, |
| 4320 |
NULL, NULL, NULL, &adata); |
| 4321 |
if (status == eslERANGE) ESL_XFAIL(eslEINVAL, pli->errbuf, "pli_align_hit() alignment HB retry mx too big, this shouldn't happen"); |
| 4322 |
else if(status != eslOK) goto ERROR; |
| 4323 |
} |
| 4324 |
pli->acct[pli->cur_pass_idx].n_aln_hb++; |
| 4325 |
esl_stopwatch_Stop(watch); |
| 4326 |
} |
| 4327 |
else { |
| 4328 |
esl_stopwatch_Start(watch); |
| 4329 |
if((status = DispatchSqAlignment(cm, pli->errbuf, sq2aln, -1, mxsize_limit, hit->mode, pli->cur_pass_idx, |
| 4330 |
FALSE, NULL, NULL, NULL, &adata)) != eslOK) goto ERROR; |
| 4331 |
pli->acct[pli->cur_pass_idx].n_aln_dccyk++; |
| 4332 |
esl_stopwatch_Stop(watch); |
| 4333 |
} |
| 4334 |
|
| 4335 |
|
| 4336 |
|
| 4337 |
if(pli->do_null3) { |
| 4338 |
ScoreCorrectionNull3CompUnknown(cm->abc, cm->null, sq2aln->dsq, 1, sq2aln->L, cm->null3_omega, &null3_correction); |
| 4339 |
adata->sc -= null3_correction; |
| 4340 |
hit->bias = null3_correction; |
| 4341 |
} |
| 4342 |
|
| 4343 |
|
| 4344 |
if((status = cm_alidisplay_Create(cm, pli->errbuf, adata, sq, hit->start, |
| 4345 |
(cm->align_opts & CM_ALIGN_HBANDED) ? cm->cp9b->tau : -1., |
| 4346 |
watch->elapsed, &(hit->ad))) != eslOK) goto ERROR; |
| 4347 |
|
| 4348 |
|
| 4349 |
cm->align_opts = pli->cm_align_opts; |
| 4350 |
if(adata != NULL) cm_alndata_Destroy(adata, FALSE); |
| 4351 |
if(sq2aln != NULL) esl_sq_Destroy(sq2aln); |
| 4352 |
if(watch != NULL) esl_stopwatch_Destroy(watch); |
| 4353 |
|
| 4354 |
return eslOK; |
| 4355 |
|
| 4356 |
ERROR: |
| 4357 |
cm->align_opts = pli->cm_align_opts; |
| 4358 |
if(adata != NULL) cm_alndata_Destroy(adata, FALSE); |
| 4359 |
if(sq2aln != NULL) esl_sq_Destroy(sq2aln); |
| 4360 |
if(watch != NULL) esl_stopwatch_Destroy(watch); |
| 4361 |
hit->ad = NULL; |
| 4362 |
return status; |
| 4363 |
} |
| 4364 |
|
| 4365 |
|
| 4366 |
|
| 4367 |
|
| 4368 |
|
| 4369 |
|
| 4370 |
|
| 4371 |
|
| 4372 |
|
| 4373 |
|
| 4374 |
|
| 4375 |
|
| 4376 |
|
| 4377 |
|
| 4378 |
|
| 4379 |
|
| 4380 |
|
| 4381 |
|
| 4382 |
|
| 4383 |
|
| 4384 |
|
| 4385 |
int |
| 4386 |
pli_scan_mode_read_cm(CM_PIPELINE *pli, off_t cm_offset, float *p7_evparam, int p7_max_length, CM_t **ret_cm) |
| 4387 |
{ |
| 4388 |
int status; |
| 4389 |
CM_t *cm = NULL; |
| 4390 |
int check_fcyk_beta; |
| 4391 |
int check_final_beta; |
| 4392 |
int W_from_cmdline; |
| 4393 |
|
| 4394 |
if (pli->mode != CM_SCAN_MODELS) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "pli_scan_mode_read_cm(), pipeline isn't in SCAN mode"); |
| 4395 |
if (*ret_cm != NULL) ESL_FAIL(eslEINCOMPAT, pli->errbuf, "pli_scan_mode_read_cm(), *ret_cm != NULL"); |
| 4396 |
|
| 4397 |
#ifdef HMMER_THREADS |
| 4398 |
|
| 4399 |
if (pli->cmfp->syncRead) { |
| 4400 |
if (pthread_mutex_lock (&pli->cmfp->readMutex) != 0) ESL_FAIL(eslESYS, pli->errbuf, "mutex lock failed"); |
| 4401 |
} |
| 4402 |
#endif |
| 4403 |
cm_file_Position(pli->cmfp, cm_offset); |
| 4404 |
if((status = cm_file_Read(pli->cmfp, FALSE, &(pli->abc), &cm)) != eslOK) ESL_FAIL(status, pli->errbuf, "%s", pli->cmfp->errbuf); |
| 4405 |
#ifdef HMMER_THREADS |
| 4406 |
if (pli->cmfp->syncRead) { |
| 4407 |
if (pthread_mutex_unlock (&pli->cmfp->readMutex) != 0) ESL_EXCEPTION(eslESYS, "mutex unlock failed"); |
| 4408 |
} |
| 4409 |
#endif |
| 4410 |
|
| 4411 |
|
| 4412 |
|
| 4413 |
|
| 4414 |
|
| 4415 |
cm->config_opts = pli->cm_config_opts; |
| 4416 |
cm->align_opts = pli->cm_align_opts; |
| 4417 |
|
| 4418 |
|
| 4419 |
|
| 4420 |
check_fcyk_beta = (pli->fcyk_cm_search_opts & CM_SEARCH_QDB) ? TRUE : FALSE; |
| 4421 |
check_final_beta = (pli->final_cm_search_opts & CM_SEARCH_QDB) ? TRUE : FALSE; |
| 4422 |
if((status = CheckCMQDBInfo(cm->qdbinfo, pli->fcyk_beta, check_fcyk_beta, pli->final_beta, check_final_beta)) == eslFAIL) { |
| 4423 |
cm->config_opts |= CM_CONFIG_QDB; |
| 4424 |
cm->qdbinfo->beta1 = pli->fcyk_beta; |
| 4425 |
cm->qdbinfo->beta2 = pli->final_beta; |
| 4426 |
} |
| 4427 |
|
| 4428 |
|
| 4429 |
W_from_cmdline = pli->do_wcx ? (int) (cm->clen * pli->wcx) : -1; |
| 4430 |
if((status = cm_Configure(cm, pli->errbuf, W_from_cmdline)) != eslOK) goto ERROR; |
| 4431 |
|
| 4432 |
if((status = cm_pli_NewModel(pli, CM_NEWMODEL_CM, cm, cm->clen, cm->W, CMCountNodetype(cm, MATP_nd), |
| 4433 |
NULL, NULL, p7_evparam, p7_max_length, pli->cur_cm_idx, pli->cur_clan_idx, NULL)) |
| 4434 |
!= eslOK) goto ERROR; |
| 4435 |
|
| 4436 |
*ret_cm = cm; |
| 4437 |
return eslOK; |
| 4438 |
|
| 4439 |
ERROR: |
| 4440 |
if(cm != NULL) FreeCM(cm); |
| 4441 |
*ret_cm = NULL; |
| 4442 |
return status; |
| 4443 |
} |
| 4444 |
|
| 4445 |
|
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
|
| 4450 |
|
| 4451 |
|
| 4452 |
|
| 4453 |
|
| 4454 |
|
| 4455 |
void |
| 4456 |
pli_copy_subseq(const ESL_SQ *src_sq, ESL_SQ *dest_sq, int64_t i, int64_t L) |
| 4457 |
{ |
| 4458 |
|
| 4459 |
|
| 4460 |
|
| 4461 |
|
| 4462 |
esl_sq_Reuse(dest_sq); |
| 4463 |
esl_sq_GrowTo(dest_sq, L); |
| 4464 |
memcpy((void*)(dest_sq->dsq+1), src_sq->dsq+i, L * sizeof(ESL_DSQ)); |
| 4465 |
dest_sq->dsq[0] = dest_sq->dsq[L+1] = eslDSQ_SENTINEL; |
| 4466 |
dest_sq->n = L; |
| 4467 |
dest_sq->L = src_sq->L; |
| 4468 |
|
| 4469 |
if(src_sq->start <= src_sq->end) { |
| 4470 |
ESL_DASSERT1((L <= (src_sq->end - src_sq->start + 1))); |
| 4471 |
|
| 4472 |
dest_sq->start = src_sq->start + i - 1; |
| 4473 |
dest_sq->end = dest_sq->start + L - 1; |
| 4474 |
} |
| 4475 |
else { |
| 4476 |
ESL_DASSERT1((L <= (src_sq->start - src_sq->end + 1))); |
| 4477 |
|
| 4478 |
dest_sq->start = src_sq->end + L - 1; |
| 4479 |
dest_sq->end = dest_sq->start - L + 1; |
| 4480 |
} |
| 4481 |
|
| 4482 |
|
| 4483 |
|
| 4484 |
esl_sq_SetName (dest_sq, src_sq->name); |
| 4485 |
esl_sq_SetAccession(dest_sq, src_sq->acc); |
| 4486 |
esl_sq_SetDesc (dest_sq, src_sq->desc); |
| 4487 |
|
| 4488 |
return; |
| 4489 |
} |
| 4490 |
|
| 4491 |
|
| 4492 |
|
| 4493 |
|
| 4494 |
|
| 4495 |
|
| 4496 |
|
| 4497 |
|
| 4498 |
|
| 4499 |
|
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
char * |
| 4504 |
pli_describe_pass(int pass_idx) |
| 4505 |
{ |
| 4506 |
switch (pass_idx) { |
| 4507 |
case PLI_PASS_CM_SUMMED: return "(standard and truncated passes)"; break; |
| 4508 |
case PLI_PASS_STD_ANY: return "(full sequences)"; break; |
| 4509 |
case PLI_PASS_5P_ONLY_FORCE: return "(5' terminal sequence regions)"; break; |
| 4510 |
case PLI_PASS_3P_ONLY_FORCE: return "(3' terminal sequence regions)"; break; |
| 4511 |
case PLI_PASS_5P_AND_3P_FORCE: return "(full sequences short enough to contain a 5' and 3' truncated hit)"; break; |
| 4512 |
case PLI_PASS_5P_AND_3P_ANY: return "(full sequences, allowing truncated hits)"; break; |
| 4513 |
case PLI_PASS_HMM_ONLY_ANY: return "(HMM only mode: full sequences, allowing truncated hits)"; break; |
| 4514 |
default: cm_Fail("bogus pipeline pass index %d\n", pass_idx); break; |
| 4515 |
} |
| 4516 |
return ""; |
| 4517 |
} |
| 4518 |
|
| 4519 |
|
| 4520 |
|
| 4521 |
|
| 4522 |
|
| 4523 |
|
| 4524 |
|
| 4525 |
|
| 4526 |
|
| 4527 |
|
| 4528 |
|
| 4529 |
|
| 4530 |
|
| 4531 |
|
| 4532 |
char * |
| 4533 |
pli_describe_hits_for_pass(int pass_idx) |
| 4534 |
{ |
| 4535 |
switch (pass_idx) { |
| 4536 |
case PLI_PASS_CM_SUMMED: return "CM hits reported:"; break; |
| 4537 |
case PLI_PASS_STD_ANY: return "non-truncated CM hits reported:"; break; |
| 4538 |
case PLI_PASS_5P_ONLY_FORCE: return "5' truncated CM hits reported:"; break; |
| 4539 |
case PLI_PASS_3P_ONLY_FORCE: return "3' truncated CM hits reported:"; break; |
| 4540 |
case PLI_PASS_5P_AND_3P_FORCE: return "5' and 3' truncated CM hits reported:"; break; |
| 4541 |
case PLI_PASS_5P_AND_3P_ANY: return "CM hits reported:"; break; |
| 4542 |
case PLI_PASS_HMM_ONLY_ANY: return "HMM hits reported:"; break; |
| 4543 |
default: cm_Fail("bogus pipeline pass index %d\n", pass_idx); break; |
| 4544 |
} |
| 4545 |
return ""; |
| 4546 |
} |
| 4547 |
|
| 4548 |
|
| 4549 |
|
| 4550 |
|
| 4551 |
|
| 4552 |
|
| 4553 |
|
| 4554 |
|
| 4555 |
|
| 4556 |
|
| 4557 |
|
| 4558 |
|
| 4559 |
float |
| 4560 |
pli_mxsize_limit_from_W(int W) |
| 4561 |
{ |
| 4562 |
float mxsize; |
| 4563 |
|
| 4564 |
mxsize = (float) W - (float) DEFAULT_HB_MXSIZE_MIN_W; |
| 4565 |
mxsize /= (float) DEFAULT_HB_MXSIZE_MAX_W - (float) DEFAULT_HB_MXSIZE_MIN_W; |
| 4566 |
mxsize *= (float) DEFAULT_HB_MXSIZE_MAX_MB - (float) DEFAULT_HB_MXSIZE_MIN_MB; |
| 4567 |
mxsize += (float) DEFAULT_HB_MXSIZE_MIN_MB; |
| 4568 |
|
| 4569 |
|
| 4570 |
|
| 4571 |
|
| 4572 |
|
| 4573 |
mxsize = ESL_MIN(mxsize, DEFAULT_HB_MXSIZE_MAX_MB); |
| 4574 |
mxsize = ESL_MAX(mxsize, DEFAULT_HB_MXSIZE_MIN_MB); |
| 4575 |
|
| 4576 |
|
| 4577 |
return mxsize; |
| 4578 |
} |
| 4579 |
|
| 4580 |
|
| 4581 |
|
| 4582 |
|
| 4583 |
|
| 4584 |
|
| 4585 |
|
| 4586 |
|
| 4587 |
|
| 4588 |
|
| 4589 |
|
| 4590 |
|
| 4591 |
|
| 4592 |
int |
| 4593 |
pli_check_one_or_zero_envelopes(int *nA) |
| 4594 |
{ |
| 4595 |
int p; |
| 4596 |
|
| 4597 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 4598 |
if(nA[p] != 0 && nA[p] != 1) return 0; |
| 4599 |
} |
| 4600 |
return 1; |
| 4601 |
} |
| 4602 |
|
| 4603 |
|
| 4604 |
|
| 4605 |
|
| 4606 |
|
| 4607 |
|
| 4608 |
|
| 4609 |
|
| 4610 |
|
| 4611 |
|
| 4612 |
|
| 4613 |
|
| 4614 |
|
| 4615 |
int |
| 4616 |
pli_get_pass_of_best_envelope(float **bAA, int *nA) |
| 4617 |
{ |
| 4618 |
int p; |
| 4619 |
int i; |
| 4620 |
int best_idx = -1; |
| 4621 |
float best_sc = 0.; |
| 4622 |
|
| 4623 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 4624 |
for(i = 0; i < nA[p]; i++) { |
| 4625 |
if(best_idx == -1 || bAA[p][i] > best_sc) { |
| 4626 |
best_idx = p; |
| 4627 |
best_sc = bAA[p][i]; |
| 4628 |
} |
| 4629 |
} |
| 4630 |
} |
| 4631 |
|
| 4632 |
return best_idx; |
| 4633 |
} |
| 4634 |
|
| 4635 |
|
| 4636 |
|
| 4637 |
|
| 4638 |
|
| 4639 |
|
| 4640 |
|
| 4641 |
|
| 4642 |
|
| 4643 |
|
| 4644 |
|
| 4645 |
|
| 4646 |
|
| 4647 |
|
| 4648 |
|
| 4649 |
int |
| 4650 |
pli_check_full_length_envelopes(int64_t **sAA, int64_t **eAA, int *nA, int64_t L) |
| 4651 |
{ |
| 4652 |
int p; |
| 4653 |
int i; |
| 4654 |
int at_least_one = 0; |
| 4655 |
|
| 4656 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 4657 |
for(i = 0; i < nA[p]; i++) { |
| 4658 |
at_least_one = 1; |
| 4659 |
if(sAA[p][i] != 1 || eAA[p][i] != L) { |
| 4660 |
return 0; |
| 4661 |
} |
| 4662 |
} |
| 4663 |
} |
| 4664 |
|
| 4665 |
return at_least_one; |
| 4666 |
} |
| 4667 |
|
| 4668 |
|
| 4669 |
|
| 4670 |
|
| 4671 |
|
| 4672 |
|
| 4673 |
|
| 4674 |
|
| 4675 |
|
| 4676 |
|
| 4677 |
|
| 4678 |
|
| 4679 |
|
| 4680 |
|
| 4681 |
|
| 4682 |
|
| 4683 |
|
| 4684 |
|
| 4685 |
|
| 4686 |
|
| 4687 |
|
| 4688 |
|
| 4689 |
int |
| 4690 |
pli_check_overlap_envelopes(int64_t **sAA, int64_t **eAA, int *nA, int best_pass_idx, int best_env_idx, int64_t start_offset, float min_fract, int *ret_val, char *errbuf) |
| 4691 |
{ |
| 4692 |
int status; |
| 4693 |
int p; |
| 4694 |
int i; |
| 4695 |
int imax; |
| 4696 |
int64_t best_start; |
| 4697 |
int64_t best_end; |
| 4698 |
int64_t best_len; |
| 4699 |
int64_t cur_start; |
| 4700 |
int64_t cur_end; |
| 4701 |
int64_t cur_len; |
| 4702 |
int64_t cur_olap = -1; |
| 4703 |
int violation = 0; |
| 4704 |
|
| 4705 |
best_start = sAA[best_pass_idx][best_env_idx]; |
| 4706 |
best_end = eAA[best_pass_idx][best_env_idx]; |
| 4707 |
if(best_pass_idx == PLI_PASS_3P_ONLY_FORCE) { |
| 4708 |
best_start += start_offset; |
| 4709 |
best_end += start_offset; |
| 4710 |
} |
| 4711 |
best_len = best_end - best_start + 1; |
| 4712 |
|
| 4713 |
for(p = PLI_PASS_STD_ANY; p < NPLI_PASSES; p++) { |
| 4714 |
imax = nA[p]; |
| 4715 |
for(i = 0; i < imax; i++) { |
| 4716 |
if(p != best_pass_idx || i != best_env_idx) { |
| 4717 |
cur_start = sAA[p][i]; |
| 4718 |
cur_end = eAA[p][i]; |
| 4719 |
if(p == PLI_PASS_3P_ONLY_FORCE) { |
| 4720 |
cur_start += start_offset; |
| 4721 |
cur_end += start_offset; |
| 4722 |
} |
| 4723 |
cur_len = cur_end - cur_start + 1; |
| 4724 |
if((status = cm_tophits_OverlapNres(cur_start, cur_end, best_start, best_end, &cur_olap, errbuf)) != eslOK) return status; |
| 4725 |
|
| 4726 |
if(cur_olap < (ESL_MIN(best_len, cur_len) * min_fract)) { |
| 4727 |
|
| 4728 |
violation = 1; |
| 4729 |
i = imax+1; |
| 4730 |
p = NPLI_PASSES+1; |
| 4731 |
} |
| 4732 |
} |
| 4733 |
} |
| 4734 |
} |
| 4735 |
|
| 4736 |
if(violation) { |
| 4737 |
*ret_val = 0; |
| 4738 |
} |
| 4739 |
else { |
| 4740 |
*ret_val = 1; |
| 4741 |
} |
| 4742 |
|
| 4743 |
return eslOK; |
| 4744 |
} |
| 4745 |
|
| 4746 |
#if 0 |
| 4747 |
|
| 4748 |
|
| 4749 |
|
| 4750 |
|
| 4751 |
|
| 4752 |
|
| 4753 |
|
| 4754 |
|
| 4755 |
|
| 4756 |
|
| 4757 |
|
| 4758 |
|
| 4759 |
|
| 4760 |
|
| 4761 |
|
| 4762 |
|
| 4763 |
|
| 4764 |
|
| 4765 |
|
| 4766 |
|
| 4767 |
|
| 4768 |
|
| 4769 |
|
| 4770 |
|
| 4771 |
|
| 4772 |
|
| 4773 |
|
| 4774 |
|
| 4775 |
|
| 4776 |
|
| 4777 |
|
| 4778 |
|
| 4779 |
|
| 4780 |
|
| 4781 |
|
| 4782 |
|
| 4783 |
|
| 4784 |
|
| 4785 |
|
| 4786 |
|
| 4787 |
|
| 4788 |
|
| 4789 |
|
| 4790 |
|
| 4791 |
|
| 4792 |
|
| 4793 |
|
| 4794 |
|
| 4795 |
|
| 4796 |
int |
| 4797 |
merge_windows_from_two_lists(int64_t *ws1, int64_t *we1, double *wp1, int *wl1, int nwin1, int64_t *ws2, int64_t *we2, double *wp2, int *wl2, int nwin2, int64_t **ret_mws, int64_t **ret_mwe, double **ret_mwp, int **ret_mwl, int *ret_nmwin) |
| 4798 |
{ |
| 4799 |
int status; |
| 4800 |
int64_t *mws = NULL; |
| 4801 |
int64_t *mwe = NULL; |
| 4802 |
double *mwp = NULL; |
| 4803 |
int *mwl = NULL; |
| 4804 |
int nmwin; |
| 4805 |
int mi, i1, i2; |
| 4806 |
int nalloc; |
| 4807 |
|
| 4808 |
|
| 4809 |
for(i1 = 0; i1 < nwin1-1; i1++) if(ws1[i1] >= ws1[i1+1]) return eslEINVAL; |
| 4810 |
for(i2 = 0; i2 < nwin2-1; i2++) if(ws2[i2] >= ws2[i2+1]) return eslEINVAL; |
| 4811 |
for(i1 = 0; i1 < nwin1; i1++) if(ws1[i1] > we1[i1]) return eslEINVAL; |
| 4812 |
for(i2 = 0; i2 < nwin2; i2++) if(ws2[i2] > we2[i2]) return eslEINVAL; |
| 4813 |
|
| 4814 |
nalloc = nwin1 + nwin2; |
| 4815 |
ESL_ALLOC(mws, sizeof(int64_t) * ESL_MAX(1, nalloc)); |
| 4816 |
ESL_ALLOC(mwe, sizeof(int64_t) * ESL_MAX(1, nalloc)); |
| 4817 |
ESL_ALLOC(mwp, sizeof(double) * ESL_MAX(1, nalloc)); |
| 4818 |
ESL_ALLOC(mwl, sizeof(int) * ESL_MAX(1, nalloc)); |
| 4819 |
|
| 4820 |
i1 = 0; |
| 4821 |
i2 = 0; |
| 4822 |
mi = 0; |
| 4823 |
while(i1 < nwin1 || i2 < nwin2) { |
| 4824 |
if((i1 < nwin1) && ((i2 == nwin2) || (ws1[i1] < ws2[i2]))) { |
| 4825 |
|
| 4826 |
|
| 4827 |
|
| 4828 |
|
| 4829 |
mws[mi] = ws1[i1]; |
| 4830 |
mwp[mi] = wp1[i1]; |
| 4831 |
mwl[mi] = wl1[i1]; |
| 4832 |
mwe[mi] = we1[i1]; |
| 4833 |
|
| 4834 |
while((i2 < nwin2) && (mwe[mi] >= ws2[i2])) { |
| 4835 |
mwe[mi] = ESL_MAX(mwe[mi], we2[i2]); |
| 4836 |
if(wp2[i2] < mwp[mi]) { |
| 4837 |
mwp[mi] = wp2[i2]; |
| 4838 |
mwl[mi] = wl2[i2]; |
| 4839 |
} |
| 4840 |
i2++; |
| 4841 |
} |
| 4842 |
i1++; |
| 4843 |
|
| 4844 |
|
| 4845 |
while((i1 < nwin1) && (mwe[mi] >= ws1[i1])) { |
| 4846 |
mwe[mi] = ESL_MAX(mwe[mi], we1[i1]); |
| 4847 |
if(wp1[i1] < mwp[mi]) { |
| 4848 |
mwp[mi] = wp1[i1]; |
| 4849 |
mwl[mi] = wl1[i1]; |
| 4850 |
} |
| 4851 |
i1++; |
| 4852 |
} |
| 4853 |
mi++; |
| 4854 |
} |
| 4855 |
else { |
| 4856 |
|
| 4857 |
|
| 4858 |
|
| 4859 |
|
| 4860 |
mws[mi] = ws2[i2]; |
| 4861 |
mwp[mi] = wp2[i2]; |
| 4862 |
mwl[mi] = wl2[i2]; |
| 4863 |
mwe[mi] = we2[i2]; |
| 4864 |
|
| 4865 |
while((i1 < nwin1) && (mwe[mi] >= ws1[i1])) { |
| 4866 |
mwe[mi] = ESL_MAX(mwe[mi], we1[i1]); |
| 4867 |
if(wp1[i1] < mwp[mi]) { |
| 4868 |
mwp[mi] = wp1[i1]; |
| 4869 |
mwl[mi] = wl1[i1]; |
| 4870 |
} |
| 4871 |
i1++; |
| 4872 |
} |
| 4873 |
i2++; |
| 4874 |
|
| 4875 |
|
| 4876 |
while((i2 < nwin2) && (mwe[mi] >= ws2[i2])) { |
| 4877 |
mwe[mi] = ESL_MAX(mwe[mi], we2[i2]); |
| 4878 |
if(wp2[i2] < mwp[mi]) { |
| 4879 |
mwp[mi] = wp2[i2]; |
| 4880 |
mwl[mi] = wl2[i2]; |
| 4881 |
} |
| 4882 |
i2++; |
| 4883 |
} |
| 4884 |
mi++; |
| 4885 |
} |
| 4886 |
} |
| 4887 |
nmwin = mi; |
| 4888 |
|
| 4889 |
|
| 4890 |
|
| 4891 |
|
| 4892 |
|
| 4893 |
|
| 4894 |
|
| 4895 |
|
| 4896 |
|
| 4897 |
|
| 4898 |
*ret_mws = mws; |
| 4899 |
*ret_mwe = mwe; |
| 4900 |
*ret_mwp = mwp; |
| 4901 |
*ret_mwl = mwl; |
| 4902 |
*ret_nmwin = nmwin; |
| 4903 |
|
| 4904 |
return eslOK; |
| 4905 |
|
| 4906 |
ERROR: |
| 4907 |
return status; |
| 4908 |
} |
| 4909 |
#endif |
| 4910 |
|