int main(int argc, char **argv) { ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 1, argc, argv, banner, usage); char *hmmfile = esl_opt_GetArg(go, 1); int N = esl_opt_GetInteger(go, "-N"); ESL_STOPWATCH *w = esl_stopwatch_Create(); ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s")); ESL_ALPHABET *abc = NULL; P7_HMMFILE *hfp = NULL; P7_HMM *hmm = NULL; P7_BG *bg = NULL; P7_PROFILE *gm = NULL; P7_OPROFILE *om = NULL; P7_TRACE *tr = NULL; ESL_SQ *sq = NULL; P7_ALIDISPLAY *ad = NULL; int i,z; if (p7_hmmfile_Open(hmmfile, NULL, &hfp) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM"); p7_hmmfile_Close(hfp); bg = p7_bg_Create(abc); p7_bg_SetLength(bg, 0); gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, 0, p7_UNIGLOCAL); /* that sets N,C,J to generate nothing */ om = p7_oprofile_Create(gm->M, abc); p7_oprofile_Convert(gm, om); if (esl_opt_GetBoolean(go, "-p")) tr = p7_trace_CreateWithPP(); else tr = p7_trace_Create(); sq = esl_sq_CreateDigital(abc); esl_stopwatch_Start(w); for (i = 0; i < N; i++) { p7_ProfileEmit(r, hmm, gm, bg, sq, tr); esl_sq_SetName(sq, "random"); if (! esl_opt_GetBoolean(go, "-b")) { if (esl_opt_GetBoolean(go, "-p")) for (z = 0; z < tr->N; z++) if (tr->i[z] > 0) tr->pp[z] = esl_random(r); ad = p7_alidisplay_Create(tr, 0, om, sq); p7_alidisplay_Print(stdout, ad, 40, 80, FALSE); p7_alidisplay_Destroy(ad); } p7_trace_Reuse(tr); esl_sq_Reuse(sq); } esl_stopwatch_Stop(w); esl_stopwatch_Display(stdout, w, "# CPU time: "); esl_sq_Destroy(sq); p7_trace_Destroy(tr); p7_oprofile_Destroy(om); p7_profile_Destroy(gm); p7_bg_Destroy(bg); p7_hmm_Destroy(hmm); esl_alphabet_Destroy(abc); esl_randomness_Destroy(r); esl_stopwatch_Destroy(w); esl_getopts_Destroy(go); return 0; }
/* Function: p7_tophits_Domains() * Synopsis: Standard output format for top domain hits and alignments. * * Purpose: For each reportable target sequence, output a tabular summary * of reportable domains found in it, followed by alignments of * each domain. * * Similar to <p7_tophits_Targets()>; see additional notes there. * * Returns: <eslOK> on success. * * Throws: <eslEWRITE> if a write to <ofp> fails; for example, if * the disk fills up. */ int p7_tophits_Domains(FILE *ofp, P7_TOPHITS *th, P7_PIPELINE *pli, int textw) { int h, d; int nd; int namew, descw; char *showname; int status; if (pli->long_targets) { if (fprintf(ofp, "Annotation for each hit %s:\n", pli->show_alignments ? " (and alignments)" : "") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { if (fprintf(ofp, "Domain annotation for each %s%s:\n", pli->mode == p7_SEARCH_SEQS ? "sequence" : "model", pli->show_alignments ? " (and alignments)" : "") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } for (h = 0; h < th->N; h++) if (th->hit[h]->flags & p7_IS_REPORTED) { if (pli->show_accessions && th->hit[h]->acc != NULL && th->hit[h]->acc[0] != '\0') { showname = th->hit[h]->acc; namew = strlen(th->hit[h]->acc); } else { showname = th->hit[h]->name; namew = strlen(th->hit[h]->name); } if (textw > 0) { descw = ESL_MAX(32, textw - namew - 5); if (fprintf(ofp, ">> %s %-.*s\n", showname, descw, (th->hit[h]->desc == NULL ? "" : th->hit[h]->desc)) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { if (fprintf(ofp, ">> %s %s\n", showname, (th->hit[h]->desc == NULL ? "" : th->hit[h]->desc)) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } if (th->hit[h]->nreported == 0) { if (fprintf(ofp," [No individual domains that satisfy reporting thresholds (although complete target did)]\n\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); continue; } if (pli->long_targets) { /* The dna hit table is 119 char wide: score bias Evalue hmmfrom hmm to alifrom ali to envfrom env to hqfrom hq to sq len acc ------ ----- --------- ------- ------- --------- --------- --------- --------- --------- --------- --------- ---- ! 82.7 104.4 4.9e-22 782 998 .. 241981174 241980968 .. 241981174 241980966 .. 241981174 241980968 234234233 0.78 */ if (fprintf(ofp, " %6s %5s %9s %9s %9s %2s %9s %9s %2s %9s %9s %9s %2s %4s\n", "score", "bias", " Evalue", "hmmfrom", "hmm to", " ", " alifrom ", " ali to ", " ", " envfrom ", " env to ", " sq len ", " ", "acc") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); if (fprintf(ofp, " %6s %5s %9s %9s %9s %2s %9s %9s %2s %9s %9s %9s %2s %4s\n", "------", "-----", "---------", "-------", "-------", " ", "---------", "---------", " ", "---------", "---------", "---------", " ", "----") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { /* The domain table is 101 char wide: # score bias Evalue hmmfrom hmmto alifrom ali to envfrom env to acc --- ------ ----- --------- ------- ------- ------- ------- ------- ------- ---- 1 ? 123.4 23.1 6.8e-9 3 1230 .. 1 492 [] 2 490 .] 0.90 123 ! 1234.5 123.4 123456789 1234567 1234567 .. 1234567 1234567 [] 1234567 1234568 .] 0.12 */ if (fprintf(ofp, " %3s %6s %5s %9s %9s %7s %7s %2s %7s %7s %2s %7s %7s %2s %4s\n", "#", "score", "bias", "c-Evalue", "i-Evalue", "hmmfrom", "hmm to", " ", "alifrom", "ali to", " ", "envfrom", "env to", " ", "acc") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); if (fprintf(ofp, " %3s %6s %5s %9s %9s %7s %7s %2s %7s %7s %2s %7s %7s %2s %4s\n", "---", "------", "-----", "---------", "---------", "-------", "-------", " ", "-------", "-------", " ", "-------", "-------", " ", "----") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } nd = 0; for (d = 0; d < th->hit[h]->ndom; d++) if (th->hit[h]->dcl[d].is_reported) { nd++; if (pli->long_targets) { if (fprintf(ofp, " %c %6.1f %5.1f %9.2g %9d %9d %c%c %9" PRId64 " %9" PRId64 " %c%c %9d %9d %c%c %9" PRId64 " %4.2f\n", //nd, th->hit[h]->dcl[d].is_included ? '!' : '?', th->hit[h]->dcl[d].bitscore, th->hit[h]->dcl[d].dombias * eslCONST_LOG2R, /* convert NATS to BITS at last moment */ exp(th->hit[h]->dcl[d].lnP), th->hit[h]->dcl[d].ad->hmmfrom, th->hit[h]->dcl[d].ad->hmmto, (th->hit[h]->dcl[d].ad->hmmfrom == 1) ? '[' : '.', (th->hit[h]->dcl[d].ad->hmmto == th->hit[h]->dcl[d].ad->M) ? ']' : '.', th->hit[h]->dcl[d].ad->sqfrom, th->hit[h]->dcl[d].ad->sqto, (th->hit[h]->dcl[d].ad->sqfrom == 1) ? '[' : '.', (th->hit[h]->dcl[d].ad->sqto == th->hit[h]->dcl[d].ad->L) ? ']' : '.', th->hit[h]->dcl[d].iae, th->hit[h]->dcl[d].ibe, (th->hit[h]->dcl[d].iae == 1) ? '[' : '.', (th->hit[h]->dcl[d].ibe == th->hit[h]->dcl[d].ad->L) ? ']' : '.', th->hit[h]->dcl[d].ad->L, (th->hit[h]->dcl[d].oasc / (1.0 + fabs((float) (th->hit[h]->dcl[d].ibe - th->hit[h]->dcl[d].iae))))) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { if (fprintf(ofp, " %3d %c %6.1f %5.1f %9.2g %9.2g %7d %7d %c%c %7" PRId64 " %7" PRId64 " %c%c %7d %7d %c%c %4.2f\n", nd, th->hit[h]->dcl[d].is_included ? '!' : '?', th->hit[h]->dcl[d].bitscore, th->hit[h]->dcl[d].dombias * eslCONST_LOG2R, /* convert NATS to BITS at last moment */ exp(th->hit[h]->dcl[d].lnP) * pli->domZ, exp(th->hit[h]->dcl[d].lnP) * pli->Z, th->hit[h]->dcl[d].ad->hmmfrom, th->hit[h]->dcl[d].ad->hmmto, (th->hit[h]->dcl[d].ad->hmmfrom == 1) ? '[' : '.', (th->hit[h]->dcl[d].ad->hmmto == th->hit[h]->dcl[d].ad->M) ? ']' : '.', th->hit[h]->dcl[d].ad->sqfrom, th->hit[h]->dcl[d].ad->sqto, (th->hit[h]->dcl[d].ad->sqfrom == 1) ? '[' : '.', (th->hit[h]->dcl[d].ad->sqto == th->hit[h]->dcl[d].ad->L) ? ']' : '.', th->hit[h]->dcl[d].iae, th->hit[h]->dcl[d].ibe, (th->hit[h]->dcl[d].iae == 1) ? '[' : '.', (th->hit[h]->dcl[d].ibe == th->hit[h]->dcl[d].ad->L) ? ']' : '.', (th->hit[h]->dcl[d].oasc / (1.0 + fabs((float) (th->hit[h]->dcl[d].ibe - th->hit[h]->dcl[d].iae))))) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } } if (pli->show_alignments) { if (pli->long_targets) { if (fprintf(ofp, "\n Alignment:\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { if (fprintf(ofp, "\n Alignments for each domain:\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); nd = 0; } for (d = 0; d < th->hit[h]->ndom; d++) if (th->hit[h]->dcl[d].is_reported) { nd++; if (!pli->long_targets) { if (fprintf(ofp, " == domain %d", nd ) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } if (fprintf(ofp, " score: %.1f bits", th->hit[h]->dcl[d].bitscore) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); if (!pli->long_targets) { if (fprintf(ofp, "; conditional E-value: %.2g\n", exp(th->hit[h]->dcl[d].lnP) * pli->domZ) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } else { if (fprintf(ofp, "\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } if ((status = p7_alidisplay_Print(ofp, th->hit[h]->dcl[d].ad, 40, textw, pli->show_accessions)) != eslOK) return status; if (fprintf(ofp, "\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } } else { if (fprintf(ofp, "\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } } if (th->nreported == 0) { if (fprintf(ofp, "\n [No targets detected that satisfy reporting thresholds]\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "domain hit list: write failed"); } return eslOK; }