Пример #1
0
/* Function:  p7_hmmcache_Sizeof()
 * Synopsis:  Returns total size of a profile cache, in bytes.
 * 
 * Purpose:   Calculate and return the size of a profile cache,
 *            in bytes. 
 *            
 *            The cache contains both standard and vectorized
 *            profiles. Very roughly, for a total number of consensus
 *            positions M, we consume M*560 bytes; 276 in a standard
 *            profile, and 284 in a vectorized one. This is a lot, and
 *            a target of future optimization.
 */
size_t
p7_hmmcache_Sizeof(P7_HMMCACHE *cache)
{
  size_t n = sizeof(P7_HMMCACHE);
  int    i;

  n += sizeof(char) * (strlen(cache->name) + 1);
  n += esl_alphabet_Sizeof(cache->abc);
  n += sizeof(P7_OPROFILE *) * cache->lalloc;     /* cache->omlist */
  n += sizeof(P7_PROFILE *)  * cache->lalloc;     /* cache->gmlist */

  for (i = 0; i < cache->n; i++) 
    {
      n += p7_oprofile_Sizeof(cache->omlist[i]);
      n += p7_profile_Sizeof (cache->gmlist[i]);
    }
  return n;
}
Пример #2
0
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;
}
Пример #3
0
/* Function:  p7_oprofile_Sizeof()
 * Synopsis:  Return the allocated size of a <P7_OPROFILE>.
 * Incept:    SRE, Wed Mar  2 10:39:54 2011 [Janelia]
 *
 * Purpose:   Returns the allocated size of a <P7_OPROFILE>,
 *            in bytes.
 */
size_t 
p7_oprofile_Sizeof(P7_OPROFILE *om) 
{ 
  return p7_profile_Sizeof(om); 
}