| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <p7_config.h> |
| 8 |
|
| 9 |
#include <stdlib.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include <string.h> |
| 12 |
|
| 13 |
#include "hmmer.h" |
| 14 |
#include "hmmpgmd.h" |
| 15 |
|
| 16 |
#include "esl_sqio.h" |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
int |
| 75 |
hmmpgmd2msa(void *data, P7_HMM *hmm, ESL_SQ *qsq, int *incl, int incl_size, int *excl, int excl_size, int excl_all, ESL_MSA **ret_msa) |
| 76 |
{ |
| 77 |
HMMD_SEARCH_STATS *stats = NULL; |
| 78 |
P7_TRACE *qtr = NULL; |
| 79 |
P7_TOPHITS *th = NULL; |
| 80 |
ESL_MSA *msa = NULL; |
| 81 |
char *p = (char*)data; |
| 82 |
int extra_sqcnt = 0; |
| 83 |
uint32_t n = 0; |
| 84 |
int i; |
| 85 |
int c; |
| 86 |
int status; |
| 87 |
|
| 88 |
|
| 89 |
th = p7_tophits_Create(); |
| 90 |
ESL_ALLOC(stats, sizeof(HMMD_SEARCH_STATS)); |
| 91 |
stats->hit_offsets = NULL; |
| 92 |
|
| 93 |
if (qsq != NULL) { |
| 94 |
if (qsq->n != hmm->M) { |
| 95 |
status = eslFAIL; |
| 96 |
goto ERROR; |
| 97 |
} |
| 98 |
|
| 99 |
if ((qtr = p7_trace_Create()) == NULL) {status = eslFAIL; goto ERROR; } |
| 100 |
if ((status = p7_trace_Append(qtr, p7T_B, 0, 0)) != eslOK) goto ERROR; |
| 101 |
for (i = 1; i <= qsq->n; i++) |
| 102 |
if ((status = p7_trace_Append(qtr, p7T_M, i, i)) != eslOK) goto ERROR; |
| 103 |
if ((status = p7_trace_Append(qtr, p7T_E, 0, 0)) != eslOK) goto ERROR; |
| 104 |
qtr->M = qsq->n; |
| 105 |
qtr->L = qsq->n; |
| 106 |
extra_sqcnt = 1; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
if(p7_hmmd_search_stats_Deserialize((uint8_t *) p, &n, stats) != eslOK){ |
| 111 |
status = eslFAIL; |
| 112 |
goto ERROR; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
if ( ( stats->Z_setby != p7_ZSETBY_NTARGETS && stats->Z_setby != p7_ZSETBY_OPTION && stats->Z_setby != p7_ZSETBY_FILEINFO ) |
| 117 |
|| ( stats->domZ_setby != p7_ZSETBY_NTARGETS && stats->domZ_setby != p7_ZSETBY_OPTION && stats->domZ_setby != p7_ZSETBY_FILEINFO ) |
| 118 |
|| stats->nhits > 10000000 |
| 119 |
|| stats->elapsed > 1000000 |
| 120 |
) { |
| 121 |
status = eslFAIL; |
| 122 |
goto ERROR; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
while(stats->nhits > th->Nalloc){ |
| 127 |
p7_tophits_Grow(th); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
for (i = 0; i < stats->nhits; ++i) { |
| 132 |
|
| 133 |
th->unsrt[i].name = NULL; |
| 134 |
th->unsrt[i].acc = NULL; |
| 135 |
th->unsrt[i].desc = NULL; |
| 136 |
th->unsrt[i].dcl = NULL; |
| 137 |
|
| 138 |
if(p7_hit_Deserialize((uint8_t *) p, &n, &(th->unsrt[i])) != eslOK){ |
| 139 |
printf("Unable to deserialize hit %d\n", i); |
| 140 |
exit(0); |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
for (i=0; i<stats->nhits; i++) { |
| 145 |
th->hit[i] = &(th->unsrt[i]); |
| 146 |
if ( th->hit[i]->ndom > 10000 |
| 147 |
|| th->hit[i]->flags > p7_IS_INCLUDED + p7_IS_REPORTED + p7_IS_NEW + p7_IS_DROPPED + p7_IS_DUPLICATE |
| 148 |
) { |
| 149 |
status = eslFAIL; |
| 150 |
goto ERROR; |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
th->N = stats->nhits; |
| 156 |
th->nreported = 0; |
| 157 |
th->nincluded = 0; |
| 158 |
th->is_sorted_by_sortkey = 0; |
| 159 |
th->is_sorted_by_seqidx = 0; |
| 160 |
|
| 161 |
|
| 162 |
if(excl_all){ |
| 163 |
for (i = 0; i < th->N; i++) { |
| 164 |
|
| 165 |
if(th->hit[i]->flags & p7_IS_INCLUDED){ |
| 166 |
th->hit[i]->flags = p7_IS_DROPPED; |
| 167 |
th->hit[i]->nincluded = 0; |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
for (i = 0; i < th->N; i++) { |
| 173 |
|
| 174 |
if(th->hit[i]->flags & p7_IS_INCLUDED){ |
| 175 |
if(excl_size > 0){ |
| 176 |
for( c = 0; c < excl_size; c++){ |
| 177 |
if(excl[c] == (long)(th->hit[i]->name) ){ |
| 178 |
th->hit[i]->flags = p7_IS_DROPPED; |
| 179 |
th->hit[i]->nincluded = 0; |
| 180 |
break; |
| 181 |
} |
| 182 |
} |
| 183 |
} |
| 184 |
}else{ |
| 185 |
if(incl_size > 0){ |
| 186 |
for( c = 0; c < incl_size; c++){ |
| 187 |
if(incl[c] == (long)th->hit[i]->name ){ |
| 188 |
th->hit[i]->flags = p7_IS_INCLUDED; |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
if ( (status = p7_tophits_Alignment(th, hmm->abc, &qsq, &qtr, extra_sqcnt, p7_ALL_CONSENSUS_COLS, &msa)) != eslOK) goto ERROR; |
| 198 |
esl_msa_SetName (msa, hmm->name, -1); |
| 199 |
esl_msa_SetAccession(msa, hmm->acc, -1); |
| 200 |
esl_msa_SetDesc (msa, hmm->desc, -1); |
| 201 |
esl_msa_FormatAuthor(msa, "hmmpgmd (HMMER %s)", HMMER_VERSION); |
| 202 |
|
| 203 |
if (qtr != NULL) free(qtr); |
| 204 |
p7_tophits_Destroy(th); |
| 205 |
|
| 206 |
free(stats); |
| 207 |
*ret_msa = msa; |
| 208 |
return eslOK; |
| 209 |
|
| 210 |
ERROR: |
| 211 |
if (qtr != NULL) free(qtr); |
| 212 |
p7_tophits_Destroy(th); |
| 213 |
if(stats != NULL) free(stats); |
| 214 |
return status; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
int hmmpgmd2stats_old(void *data, P7_HMM *hmm, float** statsOut) |
| 247 |
{ |
| 248 |
int i, j, k; |
| 249 |
int status; |
| 250 |
|
| 251 |
|
| 252 |
P7_TRACE *qtr = NULL; |
| 253 |
|
| 254 |
|
| 255 |
HMMD_SEARCH_STATS *stats = NULL; |
| 256 |
P7_HIT *hits = NULL; |
| 257 |
|
| 258 |
P7_TOPHITS th; |
| 259 |
P7_DOMAIN *dom; |
| 260 |
P7_ALIDISPLAY *ad, *ad2; |
| 261 |
|
| 262 |
int *cover, *id, *similar; |
| 263 |
int readPos, writePos; |
| 264 |
|
| 265 |
char *p = (char*)data; |
| 266 |
|
| 267 |
th.N = 0; |
| 268 |
th.unsrt = NULL; |
| 269 |
th.hit = NULL; |
| 270 |
|
| 271 |
|
| 272 |
ESL_ALLOC( *statsOut, sizeof(float) * hmm->M * 3); |
| 273 |
|
| 274 |
|
| 275 |
ESL_ALLOC( cover, sizeof(int) * hmm->M); |
| 276 |
ESL_ALLOC( id, sizeof(int) * hmm->M); |
| 277 |
ESL_ALLOC( similar, sizeof(int) * hmm->M); |
| 278 |
for(k = 0; k < hmm->M; k++) |
| 279 |
{ |
| 280 |
cover[k] = 0; |
| 281 |
id[k] = 0; |
| 282 |
similar[k] = 0; |
| 283 |
|
| 284 |
(*statsOut)[k ] = 0; |
| 285 |
(*statsOut)[k+hmm->M ] = 0; |
| 286 |
(*statsOut)[k+hmm->M*2] = 0; |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
stats = (HMMD_SEARCH_STATS*)p; |
| 291 |
|
| 292 |
|
| 293 |
if ( ( stats->Z_setby != p7_ZSETBY_NTARGETS && stats->Z_setby != p7_ZSETBY_OPTION && stats->Z_setby != p7_ZSETBY_FILEINFO ) |
| 294 |
|| ( stats->domZ_setby != p7_ZSETBY_NTARGETS && stats->domZ_setby != p7_ZSETBY_OPTION && stats->domZ_setby != p7_ZSETBY_FILEINFO ) |
| 295 |
|| stats->nhits > 10000000 |
| 296 |
|| stats->elapsed > 1000000 |
| 297 |
) { |
| 298 |
status = eslFAIL; |
| 299 |
goto ERROR; |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
p += sizeof(HMMD_SEARCH_STATS); |
| 304 |
hits = (P7_HIT*)p; |
| 305 |
p += sizeof(P7_HIT) * stats->nhits; |
| 306 |
|
| 307 |
|
| 308 |
ESL_ALLOC( th.unsrt, sizeof(P7_HIT) * stats->nhits); |
| 309 |
memcpy( th.unsrt, hits, sizeof(P7_HIT) * stats->nhits); |
| 310 |
ESL_ALLOC( th.hit, sizeof(P7_HIT*) * stats->nhits); |
| 311 |
for (i=0; i<stats->nhits; i++) { |
| 312 |
th.hit[i] = &(th.unsrt[i]); |
| 313 |
if ( th.hit[i]->ndom > 10000 |
| 314 |
|| th.hit[i]->flags > p7_IS_INCLUDED + p7_IS_REPORTED + p7_IS_NEW + p7_IS_DROPPED + p7_IS_DUPLICATE |
| 315 |
) { |
| 316 |
status = eslFAIL; |
| 317 |
goto ERROR; |
| 318 |
} |
| 319 |
} |
| 320 |
|
| 321 |
th.N = stats->nhits; |
| 322 |
th.nreported = 0; |
| 323 |
th.nincluded = 0; |
| 324 |
th.is_sorted_by_sortkey = 0; |
| 325 |
th.is_sorted_by_seqidx = 0; |
| 326 |
|
| 327 |
for (i = 0; i < th.N; i++) |
| 328 |
{ |
| 329 |
ESL_ALLOC( th.hit[i]->dcl, sizeof(P7_DOMAIN) * th.hit[i]->ndom); |
| 330 |
|
| 331 |
if(th.hit[i]->flags & p7_IS_INCLUDED) th.nincluded++; |
| 332 |
|
| 333 |
|
| 334 |
for (j=0; j < th.hit[i]->ndom; j++) |
| 335 |
{ |
| 336 |
dom = (P7_DOMAIN*)p; |
| 337 |
th.hit[i]->dcl[j].is_included = dom->is_included; |
| 338 |
p += sizeof(P7_DOMAIN); |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
for (j=0; j < th.hit[i]->ndom; j++) |
| 343 |
{ |
| 344 |
ad = (P7_ALIDISPLAY*)p; |
| 345 |
ESL_ALLOC(th.hit[i]->dcl[j].ad, sizeof(P7_ALIDISPLAY)); |
| 346 |
ad2 = th.hit[i]->dcl[j].ad; |
| 347 |
|
| 348 |
ad2->memsize = ad->memsize; |
| 349 |
ad2->rfline = ad->rfline; |
| 350 |
ad2->mmline = ad->mmline; |
| 351 |
|
| 352 |
ad2->csline = ad->csline ; |
| 353 |
ad2->model = ad->model ; |
| 354 |
ad2->mline = ad->mline ; |
| 355 |
ad2->aseq = ad->aseq ; |
| 356 |
ad2->ppline = ad->ppline; |
| 357 |
ad2->N = ad->N; |
| 358 |
|
| 359 |
ad2->hmmname = ad->hmmname; |
| 360 |
ad2->hmmacc = ad->hmmacc ; |
| 361 |
ad2->hmmdesc = ad->hmmdesc; |
| 362 |
ad2->hmmfrom = ad->hmmfrom; |
| 363 |
ad2->hmmto = ad->hmmto; |
| 364 |
ad2->M = ad->M; |
| 365 |
|
| 366 |
ad2->sqname = ad->sqname; |
| 367 |
ad2->sqacc = ad->sqacc ; |
| 368 |
ad2->sqdesc = ad->sqdesc; |
| 369 |
ad2->sqfrom = ad->sqfrom; |
| 370 |
ad2->sqto = ad->sqto; |
| 371 |
ad2->L = ad->L; |
| 372 |
|
| 373 |
p += sizeof(P7_ALIDISPLAY); |
| 374 |
|
| 375 |
ESL_ALLOC(ad2->mem, ad2->memsize); |
| 376 |
|
| 377 |
memcpy(ad2->mem, p, ad->memsize); |
| 378 |
|
| 379 |
p += ad2->memsize; |
| 380 |
|
| 381 |
p7_alidisplay_Deserialize_old(ad2); |
| 382 |
|
| 383 |
if(th.hit[i]->flags & p7_IS_INCLUDED && th.hit[i]->dcl[j].is_included) |
| 384 |
{ |
| 385 |
writePos = ad2->hmmfrom-1; |
| 386 |
readPos = 0; |
| 387 |
while(readPos < ad2->N) |
| 388 |
{ |
| 389 |
|
| 390 |
if(isupper(ad2->aseq[readPos]) || ad2->aseq[readPos] == '-') |
| 391 |
{ |
| 392 |
cover[writePos]++; |
| 393 |
|
| 394 |
|
| 395 |
if(isalpha(ad2->mline[readPos])) |
| 396 |
{ |
| 397 |
id[writePos]++; |
| 398 |
similar[writePos]++; |
| 399 |
} |
| 400 |
|
| 401 |
else if(ad2->mline[readPos] == '+') |
| 402 |
{ |
| 403 |
similar[writePos]++; |
| 404 |
} |
| 405 |
writePos++; |
| 406 |
} |
| 407 |
readPos++; |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
for(k = 0; k < hmm->M; k++) |
| 414 |
{ |
| 415 |
if(cover[k]) (*statsOut)[k]+=1.0; |
| 416 |
|
| 417 |
if(id[k]) (*statsOut)[k+hmm->M]+=(id[k]/cover[k]); |
| 418 |
id[k] = 0; |
| 419 |
|
| 420 |
if(similar[k]) (*statsOut)[k+hmm->M*2]+=(similar[k]/cover[k]); |
| 421 |
similar[k] = 0; |
| 422 |
|
| 423 |
cover[k] = 0; |
| 424 |
} |
| 425 |
|
| 426 |
} |
| 427 |
|
| 428 |
for(i = 0; i < hmm->M*3; i++) |
| 429 |
{ |
| 430 |
(*statsOut)[i] = (*statsOut)[i]/(th.nincluded); |
| 431 |
} |
| 432 |
|
| 433 |
for(i = hmm->M; i < hmm->M*3; i++) |
| 434 |
{ |
| 435 |
if((*statsOut)[i%hmm->M]) |
| 436 |
{ |
| 437 |
(*statsOut)[i] = (*statsOut)[i]/(*statsOut)[i%hmm->M]; |
| 438 |
} |
| 439 |
else |
| 440 |
{ |
| 441 |
(*statsOut)[i] = 0.0; |
| 442 |
} |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
if (qtr != NULL) free(qtr); |
| 448 |
qtr = NULL; |
| 449 |
|
| 450 |
for (i = 0; i < th.N; i++) { |
| 451 |
for (j=0; j < th.hit[i]->ndom; j++) |
| 452 |
if(th.hit[i]->dcl[j].ad) |
| 453 |
{ |
| 454 |
p7_alidisplay_Destroy(th.hit[i]->dcl[j].ad); |
| 455 |
th.hit[i]->dcl[j].ad = NULL; |
| 456 |
} |
| 457 |
|
| 458 |
if (th.hit[i]->dcl != NULL) free (th.hit[i]->dcl); |
| 459 |
th.hit[i]->dcl = NULL; |
| 460 |
} |
| 461 |
if (th.unsrt != NULL) free (th.unsrt); |
| 462 |
th.unsrt = NULL; |
| 463 |
if (th.hit != NULL) free (th.hit); |
| 464 |
th.hit = NULL; |
| 465 |
|
| 466 |
return eslOK; |
| 467 |
|
| 468 |
ERROR: |
| 469 |
|
| 470 |
if (qtr != NULL) free(qtr); |
| 471 |
qtr = NULL; |
| 472 |
|
| 473 |
for (i = 0; i < th.N; i++) { |
| 474 |
for (j=0; j < th.hit[i]->ndom; j++) |
| 475 |
if(th.hit[i]->dcl[j].ad) |
| 476 |
{ |
| 477 |
p7_alidisplay_Destroy(th.hit[i]->dcl[j].ad); |
| 478 |
th.hit[i]->dcl[j].ad = NULL; |
| 479 |
} |
| 480 |
|
| 481 |
if (th.hit[i]->dcl != NULL) free (th.hit[i]->dcl); |
| 482 |
th.hit[i]->dcl = NULL; |
| 483 |
} |
| 484 |
if (th.unsrt != NULL) free (th.unsrt); |
| 485 |
th.unsrt = NULL; |
| 486 |
if (th.hit != NULL) free (th.hit); |
| 487 |
th.hit = NULL; |
| 488 |
|
| 489 |
|
| 490 |
return status; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
#ifdef p7HMMPGMD2MSA_TESTDRIVE |
| 502 |
#define NUM_TEST_SEQUENCES 20 |
| 503 |
|
| 504 |
void hmmpgmd2msa_utest(int ntrials, char *hmmfile){ |
| 505 |
char msg[] = "hmmpgmd2msa_utest failed"; |
| 506 |
ESL_RANDOMNESS *rng = esl_randomness_Create(0); |
| 507 |
P7_HMM *hmm; |
| 508 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 509 |
P7_OPROFILE *oprofile; |
| 510 |
P7_TOPHITS *hitlist; |
| 511 |
P7_HMMFILE *hfp = NULL; |
| 512 |
P7_BG *bg = p7_bg_Create(abc); |
| 513 |
ESL_MSA *msa, *deser_msa; |
| 514 |
ESL_SQ * sequences[NUM_TEST_SEQUENCES]; |
| 515 |
uint8_t **buf, *buf_data; |
| 516 |
HMMD_SEARCH_STATS stats; |
| 517 |
uint32_t n = 0; |
| 518 |
uint32_t nalloc = 0; |
| 519 |
int i, j, k; |
| 520 |
|
| 521 |
buf_data = NULL; |
| 522 |
buf = &(buf_data); |
| 523 |
|
| 524 |
|
| 525 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 526 |
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); |
| 527 |
p7_hmmfile_Close(hfp); |
| 528 |
|
| 529 |
P7_PROFILE *profile = p7_profile_Create(hmm->M, abc); |
| 530 |
oprofile = p7_oprofile_Create(hmm->M, abc); |
| 531 |
|
| 532 |
if(p7_ProfileConfig(hmm, bg, profile, 400, p7_LOCAL) != eslOK){ |
| 533 |
p7_Fail(msg); |
| 534 |
} |
| 535 |
if(p7_oprofile_Convert(profile, oprofile) != eslOK){ |
| 536 |
p7_Fail(msg); |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
P7_PIPELINE *pli=p7_pipeline_Create(NULL, hmm->M, 400, FALSE, p7_SEARCH_SEQS); |
| 541 |
p7_pli_NewModel(pli, oprofile, bg); |
| 542 |
|
| 543 |
for(j = 0; j < ntrials; j++){ |
| 544 |
|
| 545 |
|
| 546 |
for(i = 0; i < NUM_TEST_SEQUENCES; i++){ |
| 547 |
sequences[i] = esl_sq_CreateDigital(abc); |
| 548 |
p7_ProfileEmit(rng, hmm, profile, bg, sequences[i], NULL); |
| 549 |
} |
| 550 |
|
| 551 |
hitlist = p7_tophits_Create(); |
| 552 |
|
| 553 |
|
| 554 |
for(i = 0; i < NUM_TEST_SEQUENCES; i++){ |
| 555 |
p7_pli_NewSeq(pli, sequences[i]); |
| 556 |
p7_bg_SetLength(bg, sequences[i]->n); |
| 557 |
p7_oprofile_ReconfigLength(oprofile, sequences[i]->n); |
| 558 |
|
| 559 |
p7_Pipeline(pli, oprofile, bg, sequences[i], NULL, hitlist); |
| 560 |
p7_pipeline_Reuse(pli); |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
p7_tophits_SortBySortkey(hitlist); |
| 566 |
p7_tophits_Threshold(hitlist, pli); |
| 567 |
if (p7_tophits_Alignment(hitlist, abc, NULL, NULL, 0, p7_ALL_CONSENSUS_COLS, &msa) != eslOK){ |
| 568 |
p7_Fail(msg); |
| 569 |
} |
| 570 |
|
| 571 |
esl_msa_SetName (msa, hmm->name, -1); |
| 572 |
esl_msa_SetAccession(msa, hmm->acc, -1); |
| 573 |
esl_msa_SetDesc (msa, hmm->desc, -1); |
| 574 |
esl_msa_FormatAuthor(msa, "hmmpgmd (HMMER %s)", HMMER_VERSION); |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
stats.elapsed = esl_random(rng); |
| 579 |
stats.user = esl_random(rng); |
| 580 |
stats.sys = esl_random(rng); |
| 581 |
stats.Z = pli->Z; |
| 582 |
stats.domZ = pli->domZ; |
| 583 |
stats.Z_setby = pli->Z_setby; |
| 584 |
stats.domZ_setby = pli->domZ_setby; |
| 585 |
stats.nmodels = pli->nmodels; |
| 586 |
stats.nseqs = pli->nseqs; |
| 587 |
stats.n_past_msv = pli->n_past_msv; |
| 588 |
stats.n_past_bias = pli->n_past_bias; |
| 589 |
stats.n_past_vit = pli->n_past_vit; |
| 590 |
stats.n_past_fwd = pli->n_past_fwd; |
| 591 |
stats.nhits = hitlist->N; |
| 592 |
stats.nreported = hitlist->nreported; |
| 593 |
stats.nincluded = hitlist->nreported; |
| 594 |
stats.hit_offsets = NULL; |
| 595 |
|
| 596 |
if(p7_hmmd_search_stats_Serialize(&stats, buf, &n, &nalloc) !=eslOK){ |
| 597 |
p7_Fail(msg); |
| 598 |
} |
| 599 |
|
| 600 |
for(k = 0; k < hitlist->N; k++){ |
| 601 |
if(p7_hit_Serialize(hitlist->hit[k], buf, &n, &nalloc) !=eslOK){ |
| 602 |
p7_Fail(msg); |
| 603 |
} |
| 604 |
} |
| 605 |
|
| 606 |
if(hmmpgmd2msa(buf_data, hmm, NULL, NULL, 0, NULL, 0, 0, &deser_msa) != eslOK){ |
| 607 |
p7_Fail(msg); |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
if(esl_msa_Compare (msa, deser_msa) != eslOK){ |
| 612 |
p7_Fail(msg); |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
p7_tophits_Destroy(hitlist); |
| 617 |
for(k = 0; k < NUM_TEST_SEQUENCES; k++){ |
| 618 |
esl_sq_Destroy(sequences[k]); |
| 619 |
sequences[k] = NULL; |
| 620 |
} |
| 621 |
esl_msa_Destroy(msa); |
| 622 |
esl_msa_Destroy(deser_msa); |
| 623 |
n = 0; |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
p7_pipeline_Destroy(pli); |
| 630 |
p7_profile_Destroy(profile); |
| 631 |
p7_oprofile_Destroy(oprofile); |
| 632 |
p7_hmm_Destroy(hmm); |
| 633 |
p7_bg_Destroy(bg); |
| 634 |
esl_alphabet_Destroy(abc); |
| 635 |
esl_randomness_Destroy(rng); |
| 636 |
free(buf_data); |
| 637 |
} |
| 638 |
|
| 639 |
|
| 640 |
int |
| 641 |
main(int argc, char **argv) { |
| 642 |
if(argc != 2){ |
| 643 |
printf("Usage: hmmpgmd2msa_utest <hmmfile>\n"); |
| 644 |
return eslFAIL; |
| 645 |
} |
| 646 |
hmmpgmd2msa_utest(10, argv[1]); |
| 647 |
return eslOK; |
| 648 |
} |
| 649 |
#endif |
| 650 |
|
| 651 |
|
| 652 |
|