本文整理汇总了C++中p7_ProfileConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ p7_ProfileConfig函数的具体用法?C++ p7_ProfileConfig怎么用?C++ p7_ProfileConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p7_ProfileConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 0, argc, argv, banner, usage);
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
ESL_ALPHABET *abc = NULL;
P7_HMM *hmm = NULL;
P7_PROFILE *gm = NULL;
P7_BG *bg = NULL;
int M = 100;
int L = 200;
int nseq = 20;
char errbuf[eslERRBUFSIZE];
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet");
if (p7_hmm_Sample(r, M, abc, &hmm) != eslOK) esl_fatal("failed to sample an HMM");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
if ((gm = p7_profile_Create(hmm->M, abc)) == NULL) esl_fatal("failed to create profile");
if (p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL) != eslOK) esl_fatal("failed to config profile");
if (p7_hmm_Validate (hmm, errbuf, 0.0001) != eslOK) esl_fatal("whoops, HMM is bad!: %s", errbuf);
if (p7_profile_Validate(gm, errbuf, 0.0001) != eslOK) esl_fatal("whoops, profile is bad!: %s", errbuf);
utest_basic (go);
utest_viterbi(go, r, abc, bg, gm, nseq, L);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_alphabet_Destroy(abc);
esl_randomness_Destroy(r);
esl_getopts_Destroy(go);
return 0;
}
示例2: p7_oprofile_Sample
/* Function: p7_oprofile_Sample()
* Synopsis: Sample a random profile.
* Incept: MSF Tue Nov 3, 2009 [Janelia]
*
* Purpose: Sample a random profile of <M> nodes for alphabet <abc>,
* using <r> as the source of random numbers. Parameterize
* it for generation of target sequences of mean length
* <L>. Calculate its log-odds scores using background
* model <bg>.
*
* Args: r - random number generator
* abc - emission alphabet
* bg - background frequency model
* M - size of sampled profile, in nodes
* L - configured target seq mean length
* opt_hmm - optRETURN: sampled HMM
* opt_gm - optRETURN: sampled normal profile
* opt_om - RETURN: optimized profile
*
* Returns: <eslOK> on success.
*
* Throws: (no abnormal error conditions)
*/
int
p7_oprofile_Sample(ESL_RANDOMNESS *r, const ESL_ALPHABET *abc, const P7_BG *bg, int M, int L,
P7_HMM **opt_hmm, P7_PROFILE **opt_gm, P7_OPROFILE **ret_om)
{
P7_HMM *hmm = NULL;
P7_PROFILE *gm = NULL;
P7_OPROFILE *om = NULL;
int status;
if ((gm = p7_profile_Create (M, abc)) == NULL) { status = eslEMEM; goto ERROR; }
if ((om = p7_oprofile_Create(M, abc)) == NULL) { status = eslEMEM; goto ERROR; }
if ((status = p7_hmm_Sample(r, M, abc, &hmm)) != eslOK) goto ERROR;
if ((status = p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL)) != eslOK) goto ERROR;
if ((status = p7_oprofile_Convert(gm, om)) != eslOK) goto ERROR;
if ((status = p7_oprofile_ReconfigLength(om, L)) != eslOK) goto ERROR;
if (opt_hmm != NULL) *opt_hmm = hmm; else p7_hmm_Destroy(hmm);
if (opt_gm != NULL) *opt_gm = gm; else p7_profile_Destroy(gm);
*ret_om = om;
return eslOK;
ERROR:
if (opt_hmm != NULL) *opt_hmm = NULL;
if (opt_gm != NULL) *opt_gm = NULL;
*ret_om = NULL;
return status;
}
示例3: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
char *hmmfile = esl_opt_GetArg(go, 1);
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_GMX *gx1 = NULL;
P7_GMX *gx2 = NULL;
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
ESL_DSQ *dsq = malloc(sizeof(ESL_DSQ) * (L+2));
float null2[p7_MAXCODE];
int i;
float fsc, bsc;
double Mcs;
if (p7_hmmfile_OpenE(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile);
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM");
bg = p7_bg_Create(abc);
p7_bg_SetLength(bg, L);
gm = p7_profile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL);
gx1 = p7_gmx_Create(gm->M, L);
gx2 = p7_gmx_Create(gm->M, L);
esl_rsq_xfIID(r, bg->f, abc->K, L, dsq);
p7_GForward (dsq, L, gm, gx1, &fsc);
p7_GBackward(dsq, L, gm, gx2, &bsc);
p7_GDecoding(gm, gx1, gx2, gx2);
esl_stopwatch_Start(w);
for (i = 0; i < N; i++)
p7_GNull2_ByExpectation(gm, gx2, null2);
esl_stopwatch_Stop(w);
Mcs = (double) N * (double) L * (double) gm->M * 1e-6 / w->user;
esl_stopwatch_Display(stdout, w, "# CPU time: ");
printf("# M = %d\n", gm->M);
printf("# %.1f Mc/s\n", Mcs);
free(dsq);
p7_gmx_Destroy(gx1);
p7_gmx_Destroy(gx2);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
p7_hmmfile_Close(hfp);
esl_alphabet_Destroy(abc);
esl_stopwatch_Destroy(w);
esl_randomness_Destroy(r);
esl_getopts_Destroy(go);
return 0;
}
示例4: main
int
main(int argc, char **argv)
{
char *msg = "p7_gmx unit test driver failed";
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 0, argc, argv, banner, usage);
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO);
P7_BG *bg = p7_bg_Create(abc);
P7_HMM *hmm = NULL;
P7_PROFILE *gm = NULL;
int M = esl_opt_GetInteger(go, "-M");
int L = esl_opt_GetInteger(go, "-L");
float tol = esl_opt_GetReal (go, "-t");
p7_FLogsumInit();
if (p7_hmm_Sample(r, M, abc, &hmm) != eslOK) esl_fatal(msg);
if ((gm = p7_profile_Create(hmm->M, abc)) == NULL) esl_fatal(msg);
if (p7_bg_SetLength(bg, L) != eslOK) esl_fatal(msg);
if (p7_ProfileConfig(hmm, bg, gm, L, p7_UNILOCAL) != eslOK) esl_fatal(msg);
utest_GrowTo();
utest_Compare(r, gm, bg, L, tol);
esl_getopts_Destroy(go);
esl_randomness_Destroy(r);
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
p7_profile_Destroy(gm);
return eslOK;
}
示例5: utest_basic
/* The "basic" utest is a minimal driver for making a small DNA profile and a small DNA sequence,
* then running Viterbi and Forward. It's useful for dumping DP matrices and profiles for debugging.
*/
static void
utest_basic(ESL_GETOPTS *go)
{
char *query= "# STOCKHOLM 1.0\n\nseq1 GAATTC\nseq2 GAATTC\n//\n";
int fmt = eslMSAFILE_STOCKHOLM;
char *targ = "GAATTC";
ESL_ALPHABET *abc = NULL;
ESL_MSA *msa = NULL;
P7_HMM *hmm = NULL;
P7_PROFILE *gm = NULL;
P7_BG *bg = NULL;
P7_PRIOR *pri = NULL;
ESL_DSQ *dsq = NULL;
P7_GMX *gx = NULL;
P7_TRACE *tr = NULL;
int L = strlen(targ);
float vsc, vsc2, fsc;
if ((abc = esl_alphabet_Create(eslDNA)) == NULL) esl_fatal("failed to create alphabet");
if ((pri = p7_prior_CreateNucleic()) == NULL) esl_fatal("failed to create prior");
if ((msa = esl_msa_CreateFromString(query, fmt)) == NULL) esl_fatal("failed to create MSA");
if (esl_msa_Digitize(abc, msa, NULL) != eslOK) esl_fatal("failed to digitize MSA");
if (p7_Fastmodelmaker(msa, 0.5, NULL, &hmm, NULL) != eslOK) esl_fatal("failed to create GAATTC model");
if (p7_ParameterEstimation(hmm, pri) != eslOK) esl_fatal("failed to parameterize GAATTC model");
if (p7_hmm_SetConsensus(hmm, NULL) != eslOK) esl_fatal("failed to make consensus");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create DNA null model");
if ((gm = p7_profile_Create(hmm->M, abc)) == NULL) esl_fatal("failed to create GAATTC profile");
if (p7_ProfileConfig(hmm, bg, gm, L, p7_UNILOCAL)!= eslOK) esl_fatal("failed to config profile");
if (p7_profile_Validate(gm, NULL, 0.0001) != eslOK) esl_fatal("whoops, profile is bad!");
if (esl_abc_CreateDsq(abc, targ, &dsq) != eslOK) esl_fatal("failed to create GAATTC digital sequence");
if ((gx = p7_gmx_Create(gm->M, L)) == NULL) esl_fatal("failed to create DP matrix");
if ((tr = p7_trace_Create()) == NULL) esl_fatal("trace creation failed");
p7_GViterbi (dsq, L, gm, gx, &vsc);
if (esl_opt_GetBoolean(go, "-v")) printf("Viterbi score: %.4f\n", vsc);
if (esl_opt_GetBoolean(go, "-v")) p7_gmx_Dump(stdout, gx, p7_DEFAULT);
p7_GTrace (dsq, L, gm, gx, tr);
p7_trace_Score(tr, dsq, gm, &vsc2);
if (esl_opt_GetBoolean(go, "-v")) p7_trace_Dump(stdout, tr, gm, dsq);
if (esl_FCompare(vsc, vsc2, 1e-5) != eslOK) esl_fatal("trace score and Viterbi score don't agree.");
p7_GForward (dsq, L, gm, gx, &fsc);
if (esl_opt_GetBoolean(go, "-v")) printf("Forward score: %.4f\n", fsc);
if (esl_opt_GetBoolean(go, "-v")) p7_gmx_Dump(stdout, gx, p7_DEFAULT);
p7_trace_Destroy(tr);
p7_gmx_Destroy(gx);
free(dsq);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_msa_Destroy(msa);
p7_prior_Destroy(pri);
esl_alphabet_Destroy(abc);
return;
}
示例6: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
ESL_RANDOMNESS *rng = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
char *hmmfile = esl_opt_GetArg(go, 1);
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
ESL_ALPHABET *abc = NULL;
P7_HMMFILE *hfp = NULL;
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
P7_TRACE *tr = p7_trace_Create();
ESL_SQ *sq = NULL;
char errbuf[eslERRBUFSIZE];
int i;
int status;
status = p7_hmmfile_OpenE(hmmfile, NULL, &hfp, errbuf);
if (status == eslENOTFOUND) p7_Fail("File existence/permissions problem in trying to open HMM file %s.\n%s\n", hmmfile, errbuf);
else if (status == eslEFORMAT) p7_Fail("File format problem in trying to open HMM file %s.\n%s\n", hmmfile, errbuf);
else if (status != eslOK) p7_Fail("Unexpected error %d in opening HMM file %s.\n%s\n", status, hmmfile, errbuf);
status = p7_hmmfile_Read(hfp, &abc, &hmm);
if (status == eslEFORMAT) p7_Fail("Bad file format in HMM file %s:\n%s\n", hfp->fname, hfp->errbuf);
else if (status == eslEINCOMPAT) p7_Fail("HMM in %s is not in the expected %s alphabet\n", hfp->fname, esl_abc_DecodeType(abc->type));
else if (status == eslEOF) p7_Fail("Empty HMM file %s? No HMM data found.\n", hfp->fname);
else if (status != eslOK) p7_Fail("Unexpected error in reading HMMs from %s\n", hfp->fname);
p7_hmmfile_Close(hfp);
bg = p7_bg_Create(abc); p7_bg_SetLength(bg, L);
gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL);
sq = esl_sq_CreateDigital(abc);
for (i = 0; i < N; i++)
{
p7_ProfileEmit(rng, hmm, gm, bg, sq, tr);
esl_sq_FormatName(sq, "%s-sample%d", hmm->name, i);
esl_sqio_Write(stdout, sq, eslSQFILE_FASTA, FALSE);
if (p7_trace_Validate(tr, abc, sq->dsq, errbuf) != eslOK) esl_fatal(errbuf);
esl_sq_Reuse(sq);
p7_trace_Reuse(tr);
}
esl_sq_Destroy(sq);
p7_trace_Destroy(tr);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_alphabet_Destroy(abc);
esl_randomness_Destroy(rng);
esl_getopts_Destroy(go);
return 0;
}
示例7: utest_oprofileSendRecv
static void
utest_oprofileSendRecv(int my_rank, int nproc)
{
ESL_RANDOMNESS *r = esl_randomness_CreateFast(42);
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO);
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
P7_OPROFILE *om = NULL;
P7_OPROFILE *om2 = NULL;
int M = 200;
int L = 400;
char *wbuf = NULL;
int wn = 0;
int i;
char errbuf[eslERRBUFSIZE];
p7_hmm_Sample(r, M, abc, &hmm); /* master and worker's sampled profiles are identical */
bg = p7_bg_Create(abc);
gm = p7_profile_Create(hmm->M, abc);
om = p7_oprofile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL);
p7_oprofile_Convert(gm, om);
p7_bg_SetLength (bg, L);
if (my_rank == 0)
{
for (i = 1; i < nproc; i++)
{
ESL_DPRINTF1(("Master: receiving test profile\n"));
p7_oprofile_MPIRecv(MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &wbuf, &wn, &abc, &om2);
ESL_DPRINTF1(("Master: test profile received\n"));
if (p7_oprofile_Compare(om, om2, 0.001, errbuf) != eslOK)
p7_Die("Received profile not identical to what was sent\n%s", errbuf);
p7_oprofile_Destroy(om2);
}
}
else
{
ESL_DPRINTF1(("Worker %d: sending test profile\n", my_rank));
p7_oprofile_MPISend(om, 0, 0, MPI_COMM_WORLD, &wbuf, &wn);
ESL_DPRINTF1(("Worker %d: test profile sent\n", my_rank));
}
free(wbuf);
p7_profile_Destroy(gm);
p7_oprofile_Destroy(om);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_alphabet_Destroy(abc);
esl_randomness_Destroy(r);
return;
}
示例8: utest_Config
/* The Config test simply makes sure a random profile passes
* a Validate() check.
*/
static void
utest_Config(P7_HMM *hmm, P7_BG *bg)
{
char *msg = "modelconfig.c::p7_ProfileConfig() unit test failed";
P7_PROFILE *gm = NULL;
if ((gm = p7_profile_Create(hmm->M, hmm->abc)) == NULL) esl_fatal(msg);
if (p7_ProfileConfig(hmm, bg, gm, 350, p7_LOCAL) != eslOK) esl_fatal(msg);
if (p7_profile_Validate(gm, NULL, 0.0001) != eslOK) esl_fatal(msg);
p7_profile_Destroy(gm);
return;
}
示例9: emit_sequences
static void
emit_sequences(ESL_GETOPTS *go, FILE *ofp, int outfmt, ESL_RANDOMNESS *r, P7_HMM *hmm)
{
ESL_SQ *sq = NULL;
P7_TRACE *tr = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
int do_profile = esl_opt_GetBoolean(go, "-p");
int N = esl_opt_GetInteger(go, "-N");
int L = esl_opt_GetInteger(go, "-L");
int mode = p7_LOCAL;
int nseq;
int status;
if (esl_opt_GetBoolean(go, "--local")) mode = p7_LOCAL;
else if (esl_opt_GetBoolean(go, "--unilocal")) mode = p7_UNILOCAL;
else if (esl_opt_GetBoolean(go, "--glocal")) mode = p7_GLOCAL;
else if (esl_opt_GetBoolean(go, "--uniglocal")) mode = p7_UNIGLOCAL;
if ((sq = esl_sq_CreateDigital(hmm->abc)) == NULL) esl_fatal("failed to allocate sequence");
if ((tr = p7_trace_Create()) == NULL) esl_fatal("failed to allocate trace");
if ((bg = p7_bg_Create(hmm->abc)) == NULL) esl_fatal("failed to create null model");
if ((gm = p7_profile_Create(hmm->M, hmm->abc)) == NULL) esl_fatal("failed to create profile");
if (p7_ProfileConfig(hmm, bg, gm, L, mode) != eslOK) esl_fatal("failed to configure profile");
if (p7_bg_SetLength(bg, L) != eslOK) esl_fatal("failed to reconfig null model length");
if (p7_hmm_Validate (hmm, NULL, 0.0001) != eslOK) esl_fatal("whoops, HMM is bad!");
if (p7_profile_Validate(gm, NULL, 0.0001) != eslOK) esl_fatal("whoops, profile is bad!");
for (nseq = 1; nseq <= N; nseq++)
{
if (do_profile) status = p7_ProfileEmit(r, hmm, gm, bg, sq, tr);
else status = p7_CoreEmit (r, hmm, sq, tr);
if (status) esl_fatal("Failed to emit sequence\n");
status = esl_sq_FormatName(sq, "%s-sample%d", hmm->name, nseq);
if (status) esl_fatal("Failed to set sequence name\n");
status = esl_sqio_Write(ofp, sq, outfmt, FALSE);
if (status != eslOK) esl_fatal("Failed to write sequence\n");
p7_trace_Reuse(tr);
esl_sq_Reuse(sq);
}
esl_sq_Destroy(sq);
p7_trace_Destroy(tr);
p7_bg_Destroy(bg);
p7_profile_Destroy(gm);
return;
}
示例10: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 0, argc, argv, banner, usage);
ESL_RANDOMNESS *r = esl_randomness_CreateFast(esl_opt_GetInteger(go, "-s"));
ESL_ALPHABET *abc = NULL;
P7_HMM *hmm = NULL;
P7_PROFILE *gm = NULL;
P7_OPROFILE *om = NULL;
P7_BG *bg = NULL;
ESL_DSQ *dsq = NULL;
ESL_SQ *sq = NULL;
int M = 6;
int L = 10;
int ntrace = 1000;
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet");
if (p7_hmm_Sample(r, M, abc, &hmm) != eslOK) esl_fatal("failed to sample an HMM");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
if ((gm = p7_profile_Create(hmm->M, abc)) == NULL) esl_fatal("failed to create profile");
if (p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL) != eslOK) esl_fatal("failed to config profile");
if ((om = p7_oprofile_Create(gm->M, abc)) == NULL) esl_fatal("failed to create optimized profile");
if (p7_oprofile_Convert(gm, om) != eslOK) esl_fatal("failed to convert profile");
/* Test with randomly generated (iid) sequence */
if ((dsq = malloc(sizeof(ESL_DSQ) *(L+2))) == NULL) esl_fatal("malloc failed");
if (esl_rsq_xfIID(r, bg->f, abc->K, L, dsq) != eslOK) esl_fatal("seq generation failed");
utest_stotrace(go, r, abc, gm, om, dsq, L, ntrace);
/* Test with seq sampled from profile */
if ((sq = esl_sq_CreateDigital(abc)) == NULL) esl_fatal("sequence allocation failed");
if (p7_ProfileEmit(r, hmm, gm, bg, sq, NULL) != eslOK) esl_fatal("profile emission failed");
utest_stotrace(go, r, abc, gm, om, sq->dsq, sq->n, ntrace);
esl_sq_Destroy(sq);
free(dsq);
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_getopts_Destroy(go);
return 0;
}
示例11: main
int
main(int argc, char **argv)
{
char *hmmfile = argv[1];
ESL_ALPHABET *abc = NULL;
P7_HMMFILE *hfp = NULL;
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
P7_OPROFILE *om1 = NULL;
P7_OPROFILE *om2 = NULL;
int status;
char errmsg[512];
status = p7_hmmfile_Open(hmmfile, NULL, &hfp);
if (status == eslENOTFOUND) esl_fatal("Failed to open HMM file %s for reading.\n", hmmfile);
else if (status == eslEFORMAT) esl_fatal("File %s does not appear to be in a recognized HMM format.\n", hmmfile);
else if (status != eslOK) esl_fatal("Unexpected error %d in opening HMM file %s.\n", status, hmmfile);
status = p7_hmmfile_Read(hfp, &abc, &hmm);
if (status == eslEFORMAT) esl_fatal("Bad file format in HMM file %s:\n%s\n", hfp->fname, hfp->errbuf);
else if (status == eslEINCOMPAT) esl_fatal("HMM in %s is not in the expected %s alphabet\n", hfp->fname, esl_abc_DecodeType(abc->type));
else if (status == eslEOF) esl_fatal("Empty HMM file %s? No HMM data found.\n", hfp->fname);
else if (status != eslOK) esl_fatal("Unexpected error in reading HMMs from %s\n", hfp->fname);
bg = p7_bg_Create(abc);
gm = p7_profile_Create(hmm->M, abc);
om1 = p7_oprofile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, 400, p7_LOCAL);
p7_oprofile_Convert(gm, om1);
om2 = p7_oprofile_Copy(om1);
if (p7_oprofile_Compare(om1, om2, 0.001f, errmsg) != eslOK) esl_fatal("Compare failed %s\n", errmsg);
p7_oprofile_Destroy(om1);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
p7_hmmfile_Close(hfp);
esl_alphabet_Destroy(abc);
return eslOK;
}
示例12: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 2, argc, argv, banner, usage);
char *hmmfile = esl_opt_GetArg(go, 1);
char *seqfile = esl_opt_GetArg(go, 2);
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_GMX *gx = NULL;
P7_OMX *fwd = NULL;
P7_OMX *bck = NULL;
ESL_SQ *sq = NULL;
ESL_SQFILE *sqfp = NULL;
int format = eslSQFILE_UNKNOWN;
float fraw, braw, nullsc, fsc;
float gfraw, gbraw, gfsc;
double P, gP;
int status;
/* Read in one HMM */
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");
/* Open sequence file for reading */
sq = esl_sq_CreateDigital(abc);
status = esl_sqfile_Open(seqfile, format, NULL, &sqfp);
if (status == eslENOTFOUND) p7_Fail("No such file.");
else if (status == eslEFORMAT) p7_Fail("Format unrecognized.");
else if (status == eslEINVAL) p7_Fail("Can't autodetect stdin or .gz.");
else if (status != eslOK) p7_Fail("Open failed, code %d.", status);
/* create default null model, then create and optimize profile */
bg = p7_bg_Create(abc);
p7_bg_SetLength(bg, sq->n);
gm = p7_profile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, sq->n, p7_UNILOCAL);
om = p7_oprofile_Create(gm->M, abc);
p7_oprofile_Convert(gm, om);
/* p7_oprofile_Dump(stdout, om); */
/* allocate DP matrices for O(M+L) parsers */
fwd = p7_omx_Create(gm->M, 0, sq->n);
bck = p7_omx_Create(gm->M, 0, sq->n);
gx = p7_gmx_Create(gm->M, sq->n);
/* allocate DP matrices for O(ML) fills */
/* fwd = p7_omx_Create(gm->M, sq->n, sq->n); */
/* bck = p7_omx_Create(gm->M, sq->n, sq->n); */
/* p7_omx_SetDumpMode(stdout, fwd, TRUE); */ /* makes the fast DP algorithms dump their matrices */
/* p7_omx_SetDumpMode(stdout, bck, TRUE); */
while ((status = esl_sqio_Read(sqfp, sq)) == eslOK)
{
p7_oprofile_ReconfigLength(om, sq->n);
p7_ReconfigLength(gm, sq->n);
p7_bg_SetLength(bg, sq->n);
p7_omx_GrowTo(fwd, om->M, 0, sq->n);
p7_omx_GrowTo(bck, om->M, 0, sq->n);
p7_gmx_GrowTo(gx, gm->M, sq->n);
p7_bg_NullOne (bg, sq->dsq, sq->n, &nullsc);
p7_ForwardParser (sq->dsq, sq->n, om, fwd, &fraw);
p7_BackwardParser(sq->dsq, sq->n, om, fwd, bck, &braw);
/* p7_Forward (sq->dsq, sq->n, om, fwd, &fsc); printf("forward: %.2f nats\n", fsc); */
/* p7_Backward(sq->dsq, sq->n, om, fwd, bck, &bsc); printf("backward: %.2f nats\n", bsc); */
/* Comparison to other F/B implementations */
p7_GForward (sq->dsq, sq->n, gm, gx, &gfraw);
p7_GBackward (sq->dsq, sq->n, gm, gx, &gbraw);
/* p7_gmx_Dump(stdout, gx); */
fsc = (fraw-nullsc) / eslCONST_LOG2;
gfsc = (gfraw-nullsc) / eslCONST_LOG2;
P = esl_exp_surv(fsc, om->evparam[p7_FTAU], om->evparam[p7_FLAMBDA]);
gP = esl_exp_surv(gfsc, gm->evparam[p7_FTAU], gm->evparam[p7_FLAMBDA]);
if (esl_opt_GetBoolean(go, "-1"))
{
printf("%-30s\t%-20s\t%9.2g\t%6.1f\t%9.2g\t%6.1f\n", sq->name, hmm->name, P, fsc, gP, gfsc);
}
else if (esl_opt_GetBoolean(go, "-P"))
{ /* output suitable for direct use in profmark benchmark postprocessors: */
printf("%g\t%.2f\t%s\t%s\n", P, fsc, sq->name, hmm->name);
}
else
{
printf("target sequence: %s\n", sq->name);
printf("fwd filter raw score: %.2f nats\n", fraw);
printf("bck filter raw score: %.2f nats\n", braw);
printf("null score: %.2f nats\n", nullsc);
printf("per-seq score: %.2f bits\n", fsc);
//.........这里部分代码省略.........
示例13: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
char *hmmfile = esl_opt_GetArg(go, 1);
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_OMX *ox1 = NULL;
P7_OMX *ox2 = NULL;
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
ESL_DSQ *dsq = malloc(sizeof(ESL_DSQ) * (L+2));
float null2[p7_MAXCODE];
int i,j,d,pos;
int nsamples = 200;
float fsc, bsc;
double Mcs;
if (p7_hmmfile_OpenE(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile);
if (p7_hmmfile_Read(hfp, &abc, &hmm) != eslOK) p7_Fail("Failed to read HMM");
bg = p7_bg_Create(abc); p7_bg_SetLength(bg, L);
gm = p7_profile_Create(hmm->M, abc); p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL);
om = p7_oprofile_Create(gm->M, abc); p7_oprofile_Convert(gm, om);
p7_oprofile_ReconfigLength(om, L);
ox1 = p7_omx_Create(gm->M, L, L);
ox2 = p7_omx_Create(gm->M, L, L);
esl_rsq_xfIID(r, bg->f, abc->K, L, dsq);
p7_Forward (dsq, L, om, ox1, &fsc);
if (esl_opt_GetBoolean(go, "-t"))
{
P7_TRACE *tr = p7_trace_Create();
float *n2sc = malloc(sizeof(float) * (L+1));
esl_stopwatch_Start(w);
for (i = 0; i < N; i++)
{ /* This is approximately what p7_domaindef.c::region_trace_ensemble() is doing: */
for (j = 0; j < nsamples; j++)
{
p7_StochasticTrace(r, dsq, L, om, ox1, tr);
p7_trace_Index(tr);
pos = 1;
for (d = 0; d < tr->ndom; d++)
{
p7_Null2_ByTrace(om, tr, tr->tfrom[d], tr->tto[d], ox2, null2);
for (; pos <= tr->sqfrom[d]; pos++) n2sc[pos] += 1.0;
for (; pos < tr->sqto[d]; pos++) n2sc[pos] += null2[dsq[pos]];
}
for (; pos <= L; pos++) n2sc[pos] += 1.0;
p7_trace_Reuse(tr);
}
for (pos = 1; pos <= L; pos++)
n2sc[pos] = logf(n2sc[pos] / nsamples);
}
esl_stopwatch_Stop(w);
free(n2sc);
p7_trace_Destroy(tr);
}
else
{
p7_Backward(dsq, L, om, ox1, ox2, &bsc);
p7_Decoding(om, ox1, ox2, ox2);
esl_stopwatch_Start(w);
for (i = 0; i < N; i++)
p7_Null2_ByExpectation(om, ox2, null2);
esl_stopwatch_Stop(w);
}
Mcs = (double) N * (double) L * (double) gm->M * 1e-6 / (double) w->user;
esl_stopwatch_Display(stdout, w, "# CPU time: ");
printf("# M = %d\n", gm->M);
printf("# %.1f Mc/s\n", Mcs);
free(dsq);
p7_omx_Destroy(ox1);
p7_omx_Destroy(ox2);
p7_oprofile_Destroy(om);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
p7_hmmfile_Close(hfp);
esl_alphabet_Destroy(abc);
esl_stopwatch_Destroy(w);
esl_randomness_Destroy(r);
esl_getopts_Destroy(go);
return 0;
}
示例14: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 2, argc, argv, banner, usage);
char *hmmfile = esl_opt_GetArg(go, 1);
char *seqfile = esl_opt_GetArg(go, 2);
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_OMX *ox = NULL;
P7_GMX *gx = NULL;
ESL_SQ *sq = NULL;
ESL_SQFILE *sqfp = NULL;
int format = eslSQFILE_UNKNOWN;
float vfraw, nullsc, vfscore;
float graw, gscore;
double P, gP;
int status;
/* Read in one HMM */
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");
/* Read in one sequence */
sq = esl_sq_CreateDigital(abc);
status = esl_sqfile_Open(seqfile, format, NULL, &sqfp);
if (status == eslENOTFOUND) p7_Fail("No such file.");
else if (status == eslEFORMAT) p7_Fail("Format unrecognized.");
else if (status == eslEINVAL) p7_Fail("Can't autodetect stdin or .gz.");
else if (status != eslOK) p7_Fail("Open failed, code %d.", status);
/* create default null model, then create and optimize profile */
bg = p7_bg_Create(abc);
p7_bg_SetLength(bg, sq->n);
gm = p7_profile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, sq->n, p7_LOCAL);
om = p7_oprofile_Create(gm->M, abc);
p7_oprofile_Convert(gm, om);
/* allocate DP matrices, both a generic and an optimized one */
ox = p7_omx_Create(gm->M, 0, sq->n);
gx = p7_gmx_Create(gm->M, sq->n);
/* Useful to place and compile in for debugging:
p7_oprofile_Dump(stdout, om); dumps the optimized profile
p7_omx_SetDumpMode(ox, TRUE); makes the fast DP algorithms dump their matrices
p7_gmx_Dump(stdout, gx); dumps a generic DP matrix
*/
while ((status = esl_sqio_Read(sqfp, sq)) == eslOK)
{
p7_oprofile_ReconfigLength(om, sq->n);
p7_ReconfigLength(gm, sq->n);
p7_bg_SetLength(bg, sq->n);
p7_omx_GrowTo(ox, om->M, 0, sq->n);
p7_gmx_GrowTo(gx, gm->M, sq->n);
p7_ViterbiFilter (sq->dsq, sq->n, om, ox, &vfraw);
p7_bg_NullOne (bg, sq->dsq, sq->n, &nullsc);
vfscore = (vfraw - nullsc) / eslCONST_LOG2;
P = esl_gumbel_surv(vfscore, om->evparam[p7_VMU], om->evparam[p7_VLAMBDA]);
p7_GViterbi (sq->dsq, sq->n, gm, gx, &graw);
gscore = (graw - nullsc) / eslCONST_LOG2;
gP = esl_gumbel_surv(gscore, gm->evparam[p7_VMU], gm->evparam[p7_VLAMBDA]);
if (esl_opt_GetBoolean(go, "-1"))
{
printf("%-30s\t%-20s\t%9.2g\t%7.2f\t%9.2g\t%7.2f\n", sq->name, hmm->name, P, vfscore, gP, gscore);
}
else if (esl_opt_GetBoolean(go, "-P"))
{ /* output suitable for direct use in profmark benchmark postprocessors: */
printf("%g\t%.2f\t%s\t%s\n", P, vfscore, sq->name, hmm->name);
}
else
{
printf("target sequence: %s\n", sq->name);
printf("vit filter raw score: %.2f nats\n", vfraw);
printf("null score: %.2f nats\n", nullsc);
printf("per-seq score: %.2f bits\n", vfscore);
printf("P-value: %g\n", P);
printf("GViterbi raw score: %.2f nats\n", graw);
printf("GViterbi seq score: %.2f bits\n", gscore);
printf("GViterbi P-value: %g\n", gP);
}
esl_sq_Reuse(sq);
}
/* cleanup */
esl_sq_Destroy(sq);
esl_sqfile_Close(sqfp);
p7_omx_Destroy(ox);
p7_gmx_Destroy(gx);
p7_oprofile_Destroy(om);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
//.........这里部分代码省略.........
示例15: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
char *hmmfile = esl_opt_GetArg(go, 1);
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;
double lambda = 0.0;
double mmu = 0.0;
double vmu = 0.0;
double ftau = 0.0;
int Z = esl_opt_GetInteger(go, "-Z");
int EmL = esl_opt_GetInteger(go, "--EmL");
int EmN = esl_opt_GetInteger(go, "--EmN");
int EvL = esl_opt_GetInteger(go, "--EvL");
int EvN = esl_opt_GetInteger(go, "--EvN");
int EfL = esl_opt_GetInteger(go, "--EfL");
int EfN = esl_opt_GetInteger(go, "--EfN");
int Eft = esl_opt_GetReal (go, "--Eft");
int iteration;
int do_msv, do_vit, do_fwd;
int status;
if (esl_opt_GetBoolean(go, "--msvonly") == TRUE) { do_msv = TRUE; do_vit = FALSE; do_fwd = FALSE; }
else if (esl_opt_GetBoolean(go, "--vitonly") == TRUE) { do_msv = FALSE; do_vit = TRUE; do_fwd = FALSE; }
else if (esl_opt_GetBoolean(go, "--fwdonly") == TRUE) { do_msv = FALSE; do_vit = FALSE; do_fwd = TRUE; }
else { do_msv = TRUE; do_vit = TRUE; do_fwd = TRUE; }
if (p7_hmmfile_OpenE(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile);
while ((status = p7_hmmfile_Read(hfp, &abc, &hmm)) != eslEOF)
{
if (bg == NULL) bg = p7_bg_Create(abc);
gm = p7_profile_Create(hmm->M, abc);
p7_ProfileConfig(hmm, bg, gm, EvL, p7_LOCAL); /* the EvL doesn't matter */
om = p7_oprofile_Create(hmm->M, abc);
p7_oprofile_Convert(gm, om);
if (esl_opt_IsOn(go, "--lambda")) lambda = esl_opt_GetReal(go, "--lambda");
else p7_Lambda(hmm, bg, &lambda);
for (iteration = 0; iteration < Z; iteration++)
{
if (do_msv) p7_MSVMu (r, om, bg, EmL, EmN, lambda, &mmu);
if (do_vit) p7_ViterbiMu (r, om, bg, EvL, EvN, lambda, &vmu);
if (do_fwd) p7_Tau (r, om, bg, EfL, EfN, lambda, Eft, &ftau);
printf("%s %.4f %.4f %.4f %.4f\n", hmm->name, lambda, mmu, vmu, ftau);
}
p7_hmm_Destroy(hmm);
p7_profile_Destroy(gm);
p7_oprofile_Destroy(om);
}
p7_hmmfile_Close(hfp);
p7_bg_Destroy(bg);
esl_alphabet_Destroy(abc);
esl_randomness_Destroy(r);
esl_getopts_Destroy(go);
return eslOK;
}