本文整理汇总了C++中p7_bg_Destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ p7_bg_Destroy函数的具体用法?C++ p7_bg_Destroy怎么用?C++ p7_bg_Destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p7_bg_Destroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: utest_ReadWrite
static void
utest_ReadWrite(ESL_RANDOMNESS *rng)
{
char msg[] = "bg Read/Write unit test failed";
char tmpfile[32] = "esltmpXXXXXX";
FILE *fp = NULL;
ESL_ALPHABET *abc = NULL; /* random alphabet choice eslRNA..eslDICE */
float *fq = NULL;
P7_BG *bg = NULL;
if ((abc = esl_alphabet_Create(esl_rnd_Roll(rng, 5) + 1)) == NULL) esl_fatal(msg);
if (( bg = p7_bg_Create(abc)) == NULL) esl_fatal(msg);
if (( fq = malloc(sizeof(float) * abc->K)) == NULL) esl_fatal(msg);
do {
if (esl_dirichlet_FSampleUniform(rng, abc->K, fq) != eslOK) esl_fatal(msg);
} while (esl_vec_FMin(fq, abc->K) < 0.001); /* small p's will get rounded off and fail FCompare() */
esl_vec_FCopy(fq, abc->K, bg->f);
if (esl_tmpfile_named(tmpfile, &fp) != eslOK) esl_fatal(msg);
if ( p7_bg_Write(fp, bg) != eslOK) esl_fatal(msg);
fclose(fp);
esl_vec_FSet(bg->f, bg->abc->K, 0.0);
if ( p7_bg_Read(tmpfile, bg, NULL) != eslOK) esl_fatal(msg);
if ( esl_vec_FCompare(fq, bg->f, bg->abc->K, 0.01) != eslOK) esl_fatal(msg);
p7_bg_Destroy(bg);
esl_alphabet_Destroy(abc);
free(fq);
remove(tmpfile);
}
开发者ID:EddyRivasLab,项目名称:hmmer,代码行数:31,代码来源:p7_bg.c
示例2: main
int
main(int argc, char **argv)
{
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage);
ESL_STOPWATCH *w = esl_stopwatch_Create();
char *hmmfile = esl_opt_GetArg(go, 1);
ESL_ALPHABET *abc = NULL;
P7_HMMFILE *hfp = NULL;
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
int i;
/* Read one HMM from <hmmfile> */
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");
p7_hmmfile_Close(hfp);
bg = p7_bg_Create(abc);
esl_stopwatch_Start(w);
for (i = 0; i < N; i++)
p7_bg_SetFilterByHMM(bg, hmm);
esl_stopwatch_Stop(w);
esl_stopwatch_Display(stdout, w, "# CPU time: ");
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_alphabet_Destroy(abc);
esl_stopwatch_Destroy(w);
esl_getopts_Destroy(go);
return 0;
}
开发者ID:Janelia-Farm-Xfam,项目名称:Bio-HMM-Logo,代码行数:34,代码来源:p7_bg.c
示例3: 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_forward (go, r, abc, bg, gm, nseq, L);
utest_generation (go, r, abc, gm, hmm, bg, nseq);
utest_enumeration(go, r, abc, 4); /* can't go much higher than 5; enumeration test is cpu-intensive. */
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;
}
开发者ID:Denis84,项目名称:EPA-WorkBench,代码行数:34,代码来源:generic_fwdback.c
示例4: p7_bg_Create
/* Function: p7_bg_Create()
* Synopsis: Create a <P7_BG> null model object.
*
* Purpose: Allocate a <P7_BG> object for digital alphabet <abc>,
* initializes it to appropriate default values, and
* returns a pointer to it.
*
* For protein models, default iid background frequencies
* are set (by <p7_AminoFrequencies()>) to average
* Swiss-Prot residue composition. For DNA, RNA and other
* alphabets, default frequencies are set to a uniform
* distribution.
*
* The model composition <bg->mcomp[]> is not initialized
* here; neither is the filter null model <bg->fhmm>. To
* use the filter null model, caller will want to
* initialize these fields by calling
* <p7_bg_SetFilter()>.
*
* Throws: <NULL> on allocation failure.
*
* Xref: STL11/125.
*/
P7_BG *
p7_bg_Create(const ESL_ALPHABET *abc)
{
P7_BG *bg = NULL;
int status;
ESL_ALLOC(bg, sizeof(P7_BG));
bg->f = NULL;
bg->fhmm = NULL;
ESL_ALLOC(bg->f, sizeof(float) * abc->K);
if ((bg->fhmm = esl_hmm_Create(abc, 2)) == NULL) goto ERROR;
if (abc->type == eslAMINO)
{
if (p7_AminoFrequencies(bg->f) != eslOK) goto ERROR;
}
else
esl_vec_FSet(bg->f, abc->K, 1. / (float) abc->K);
bg->p1 = 350./351.;
bg->omega = 1./256.;
bg->abc = abc;
return bg;
ERROR:
p7_bg_Destroy(bg);
return NULL;
}
开发者ID:EddyRivasLab,项目名称:hmmer,代码行数:52,代码来源:p7_bg.c
示例5: main
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);
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 *fwd = NULL;
P7_GMX *bck = NULL;
P7_GMX *pp = NULL;
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
ESL_DSQ *dsq = malloc(sizeof(ESL_DSQ) * (L+2));
int i;
float fsc, bsc;
double Mcs;
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");
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);
fwd = p7_gmx_Create(gm->M, L);
bck = p7_gmx_Create(gm->M, L);
pp = p7_gmx_Create(gm->M, L);
esl_rsq_xfIID(r, bg->f, abc->K, L, dsq);
p7_GForward (dsq, L, gm, fwd, &fsc);
p7_GBackward(dsq, L, gm, bck, &bsc);
esl_stopwatch_Start(w);
for (i = 0; i < N; i++)
p7_GDecoding(gm, fwd, bck, pp);
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(pp);
p7_gmx_Destroy(fwd);
p7_gmx_Destroy(bck);
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;
}
开发者ID:TuftsBCB,项目名称:SMURFBuild,代码行数:59,代码来源:generic_decoding.c
示例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;
}
开发者ID:ElofssonLab,项目名称:TOPCONS2,代码行数:58,代码来源:emit.c
示例7: 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;
}
开发者ID:ElofssonLab,项目名称:TOPCONS2,代码行数:61,代码来源:generic_viterbi.c
示例8: 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;
}
开发者ID:Janelia-Farm-Xfam,项目名称:Bio-HMM-Logo,代码行数:55,代码来源:mpi.c
示例9: 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_BG *bg = NULL;
int M = esl_opt_GetInteger(go, "-M");
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
/* First round of tests for DNA alphabets. */
if ((abc = esl_alphabet_Create(eslDNA)) == NULL) esl_fatal("failed to create alphabet");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
if (esl_opt_GetBoolean(go, "-v")) printf("ViterbiFilter() tests, DNA\n");
utest_viterbi_filter(r, abc, bg, M, L, N);
utest_viterbi_filter(r, abc, bg, 1, L, 10);
utest_viterbi_filter(r, abc, bg, M, 1, 10);
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
/* Second round of tests for amino alphabets. */
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
if (esl_opt_GetBoolean(go, "-v")) printf("ViterbiFilter() tests, protein\n");
utest_viterbi_filter(r, abc, bg, M, L, N);
utest_viterbi_filter(r, abc, bg, 1, L, 10);
utest_viterbi_filter(r, abc, bg, M, 1, 10);
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
esl_getopts_Destroy(go);
esl_randomness_Destroy(r);
return eslOK;
}
开发者ID:TuftsBCB,项目名称:SMURFBuild,代码行数:39,代码来源:vitfilter.c
示例10: 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;
}
开发者ID:dboudour2002,项目名称:musicHMMER,代码行数:51,代码来源:hmmemit.c
示例11: main
int
main(int argc, char **argv)
{
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 = NULL;
P7_BG *bg = NULL;
int M = esl_opt_GetInteger(go, "-M");
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
/* first round of tests for DNA alphabets. */
if ((abc = esl_alphabet_Create(eslDNA)) == NULL) esl_fatal("failed to create alphabet");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
utest_optacc(go, r, abc, bg, M, L, N); /* normal sized models */
utest_optacc(go, r, abc, bg, 1, L, 10); /* size 1 models */
utest_optacc(go, r, abc, bg, M, 1, 10); /* size 1 sequences */
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
/* Second round of tests for amino alphabets. */
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create alphabet");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to create null model");
utest_optacc(go, r, abc, bg, M, L, N);
utest_optacc(go, r, abc, bg, 1, L, 10);
utest_optacc(go, r, abc, bg, M, 1, 10);
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
esl_getopts_Destroy(go);
esl_randomness_Destroy(r);
return eslOK;
}
开发者ID:ElofssonLab,项目名称:TOPCONS2,代码行数:37,代码来源:optacc.c
示例12: destroy_hmmer_wrapper
void destroy_hmmer_wrapper() {
int index;
if(models != NULL) {
for(index = 0;index < num_models;index++) {
p7_oprofile_Destroy(models[index]);
p7_profile_Destroy(gmodels[index]);
}
free(models);
free(gmodels);
}
if(wrapper_results != NULL) {
for(index = 0;index < num_models;index++) {
destroy_result(wrapper_results[index]);
}
free(wrapper_results);
}
if(bg != NULL) {
p7_bg_Destroy(bg);
}
if(hmm_fp != NULL) {
p7_hmmfile_Close(hmm_fp);
}
if(oxf) {
p7_omx_Destroy(oxf);
}
if(oxb) {
p7_omx_Destroy(oxb);
}
if(gxf) {
p7_gmx_Destroy(gxf);
}
if(gxb) {
p7_gmx_Destroy(gxb);
}
if(abc) {
esl_alphabet_Destroy(abc);
}
if(tr) {
p7_trace_Destroy(tr);
}
}
开发者ID:rdpstaff,项目名称:AlignmentTools,代码行数:47,代码来源:hmmer_wrapper.c
示例13: 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;
}
开发者ID:Denis84,项目名称:EPA-WorkBench,代码行数:45,代码来源:stotrace.c
示例14: main
int
main(int argc, char **argv)
{
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_HMM *hmm = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
P7_GMX *fwd = NULL;
P7_GMX *bck = NULL;
ESL_DSQ *dsq = NULL;
int M = esl_opt_GetInteger(go, "-M");
int L = esl_opt_GetInteger(go, "-L");
/* Sample a random HMM */
p7_hmm_Sample(r, M, abc, &hmm);
/* Configure a profile from the sampled 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);
/* Other initial allocations */
dsq = malloc(sizeof(ESL_DSQ) * (L+2));
fwd = p7_gmx_Create(gm->M, L);
bck = p7_gmx_Create(gm->M, L);
p7_FLogsumInit();
utest_correct_normalization(r, gm, bg, dsq, L, fwd, bck);
free(dsq);
p7_gmx_Destroy(fwd);
p7_gmx_Destroy(bck);
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;
}
开发者ID:Janelia-Farm-Xfam,项目名称:Bio-HMM-Logo,代码行数:43,代码来源:p7_null3.c
示例15: 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;
}
开发者ID:Denis84,项目名称:EPA-WorkBench,代码行数:43,代码来源:p7_oprofile.c
示例16: 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_ALPHABET *abc = NULL;
P7_HMMFILE *hfp = NULL;
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
P7_PROFILE *gm = NULL;
float ftol = 1e-4; /* floating-point tolerance for checking parameters against expected probs or summing to 1 */
char errbuf[eslERRBUFSIZE];
/* Read in one HMM; sets alphabet to the HMM's alphabet */
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");
p7_hmmfile_Close(hfp);
/* Set up a null model */
bg = p7_bg_Create(abc);
/* Allocate and configure a profile from HMM and null model */
gm = p7_profile_Create(hmm->M, abc);
p7_profile_Config(gm, hmm, bg);
p7_profile_SetLength(gm, 400); /* 400 is arbitrary here; this is whatever your target seq length L is */
printf("profile memory consumed: %" PRId64 " bytes\n", (int64_t) p7_profile_Sizeof(gm));
/* Debugging tools allow dumping, validating the object */
if (p7_profile_Validate(gm, errbuf, ftol) != eslOK) p7_Fail("profile validation failed\n %s\n", errbuf);
if (esl_opt_GetBoolean(go, "--vv"))
p7_profile_Dump(stdout, gm);
p7_profile_Destroy(gm);
p7_bg_Destroy(bg);
p7_hmm_Destroy(hmm);
esl_alphabet_Destroy(abc);
esl_getopts_Destroy(go);
return 0;
}
开发者ID:stationarysalesman,项目名称:testjig,代码行数:41,代码来源:p7_profile.c
示例17: 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 = esl_alphabet_Create(eslAMINO);
P7_BG *bg = p7_bg_Create(abc);
int M = esl_opt_GetInteger(go, "-M");
int L = esl_opt_GetInteger(go, "-L");
int N = esl_opt_GetInteger(go, "-N");
float tol = esl_opt_GetReal (go, "-t");
p7_FLogsumInit();
utest_decoding(r, abc, bg, M, L, N, tol);
esl_getopts_Destroy(go);
esl_randomness_Destroy(r);
esl_alphabet_Destroy(abc);
p7_bg_Destroy(bg);
return eslOK;
}
开发者ID:Denis84,项目名称:EPA-WorkBench,代码行数:22,代码来源:decoding.c
示例18: p7_bg_CreateUniform
/* Function: p7_bg_CreateUniform()
* Synopsis: Creates background model with uniform freqs.
* Incept: SRE, Sat Jun 30 10:25:27 2007 [Janelia]
*
* Purpose: Creates a background model for alphabet <abc>
* with uniform residue frequencies.
*/
P7_BG *
p7_bg_CreateUniform(const ESL_ALPHABET *abc)
{
P7_BG *bg = NULL;
int status;
ESL_ALLOC(bg, sizeof(P7_BG));
bg->f = NULL;
bg->fhmm = NULL;
ESL_ALLOC(bg->f, sizeof(float) * abc->K);
if ((bg->fhmm = esl_hmm_Create(abc, 2)) == NULL) goto ERROR;
esl_vec_FSet(bg->f, abc->K, 1. / (float) abc->K);
bg->p1 = 350./351.;
bg->omega = 1./256.;
bg->abc = (ESL_ALPHABET *) abc; /* safe: we're just keeping a reference */
return bg;
ERROR:
p7_bg_Destroy(bg);
return NULL;
}
开发者ID:TuftsBCB,项目名称:SMURFBuild,代码行数:30,代码来源:p7_bg.c
示例19: p7_bg_Clone
/* Function: p7_bg_Clone()
* Synopsis: Create a duplicate of an existing <P7_BG> object.
*
* Purpose: Creates a duplicate of the existing <P7_BG> object <bg>.
*
* Returns: ptr to the duplicate <P7_BG> object.
*
* Throws: <NULL> on allocation failure.
*/
P7_BG *
p7_bg_Clone(const P7_BG *bg)
{
P7_BG *dup = NULL;
int status;
ESL_ALLOC(dup, sizeof(P7_BG));
dup->f = NULL;
dup->fhmm = NULL;
dup->abc = bg->abc; /* by reference only */
ESL_ALLOC(dup->f, sizeof(float) * bg->abc->K);
memcpy(dup->f, bg->f, sizeof(float) * bg->abc->K);
if ((dup->fhmm = esl_hmm_Clone(bg->fhmm)) == NULL) goto ERROR;
dup->p1 = bg->p1;
dup->omega = bg->omega;
return dup;
ERROR:
p7_bg_Destroy(dup);
return NULL;
}
开发者ID:dboudour2002,项目名称:musicHMMER,代码行数:32,代码来源:p7_bg.c
示例20: main
int
main(int argc, char **argv)
{
ESL_ALPHABET *abc = NULL;
ESL_RANDOMNESS *r = NULL;
P7_HMM *hmm = NULL;
P7_BG *bg = NULL;
int M = 10000;
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("failed to create amino alphabet");
if ((r = esl_randomness_CreateFast(0)) == NULL) esl_fatal("failed to create randomness");
if (p7_hmm_Sample(r, M, abc, &hmm) != eslOK) esl_fatal("failed to sample random HMM");
if ((bg = p7_bg_Create(abc)) == NULL) esl_fatal("failed to created null model");
utest_Config(hmm, bg);
utest_occupancy(hmm);
p7_hmm_Destroy(hmm);
p7_bg_Destroy(bg);
esl_alphabet_Destroy(abc);
esl_randomness_Destroy(r);
return eslOK;
}
开发者ID:dboudour2002,项目名称:musicHMMER,代码行数:23,代码来源:modelconfig.c
注:本文中的p7_bg_Destroy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论