hmmer-3.3/easel/esl_sqio_ncbi.c
/* sqncbi_ParseIndexFile()
 *
 * Parse an open index file verifying database type and version
 * if handled.  Read in the entries, i.e. name, number of sequences,
 * etc.  Keep track of the offsets where the header and sequence
 * tables begin.
 */
sqncbi_ParseIndexFile()
Parse an open index file verifying database type and version
if handled.  Read in the entries, i.e. name, number of sequences,
etc.  Keep track of the offsets where the header and sequence
tables begin.
sqncbi_ParseIndexFile () Parse an open index file verifying database type and version if handled . Read in the entries i . e . name number of sequences etc . Keep track of the offsets where the header and sequence tables begin .
static int
sqncbi_ParseIndexFile(ESL_SQNCBI_DATA *ncbi, int dbtype)
{
  int         len;
  uint32_t    info[4];
  int         status = eslOK;	
  if (fread(&info[0], sizeof(uint32_t), 3, ncbi->fppin) != 3) status = eslFAIL;
  if (htobe32(info[0]) != NCBI_VERSION_4)                     status = eslEFORMAT;
  if (htobe32(info[1]) != dbtype)                             status = eslEUNIMPLEMENTED;
  if (status != eslOK) goto ERROR;
  ncbi->version = htobe32(info[0]);
  ncbi->alphatype = (dbtype == NCBI_DNA_DB) ? eslDNA : eslAMINO;
  ncbi->index = 0;
  len = htobe32(info[2]);
  ESL_ALLOC(ncbi->title, sizeof(char) * (len + 1));
  if (fread(ncbi->title, sizeof(char), len, ncbi->fppin) != len) { status = eslFAIL; goto ERROR; }
  ncbi->title[len] = 0;
  if (fread(&info[0], sizeof(uint32_t), 1, ncbi->fppin) != 1) { status = eslFAIL; goto ERROR; }
  len = htobe32(info[0]);
  ESL_ALLOC(ncbi->timestamp, sizeof(char) * (len + 1));
  if (fread(ncbi->timestamp, sizeof(char), len, ncbi->fppin) != len) { status = eslFAIL; goto ERROR; }
  ncbi->timestamp[len] = 0;
  if (fread(&info[0], sizeof(uint32_t), 4, ncbi->fppin) != 4) { status = eslFAIL; goto ERROR; }
  ncbi->num_seq   = htobe32(info[0]);
  memcpy(&ncbi->total_res, info+1, sizeof(uint64_t)); 
  ncbi->max_seq   = htobe32(info[3]);
  ncbi->hdr_off = ftell(ncbi->fppin);
  ncbi->seq_off = ncbi->hdr_off + sizeof(uint32_t) * (ncbi->num_seq + 1);
  return eslOK;
 ERROR:
  return status;
}
static int sqncbi_ParseIndexFile ( ESL_SQNCBI_DATA * ncbi , int dbtype ) { int len ; uint32_t info [ 4 ] ; int status = eslOK ; if ( fread ( & info [ 0 ] , sizeof ( uint32_t ) , 3 , ncbi -> fppin ) != 3 ) status = eslFAIL ; if ( htobe32 ( info [ 0 ] ) != NCBI_VERSION_4 ) status = eslEFORMAT ; if ( htobe32 ( info [ 1 ] ) != dbtype ) status = eslEUNIMPLEMENTED ; if ( status != eslOK ) goto ERROR ; ncbi -> version = htobe32 ( info [ 0 ] ) ; ncbi -> alphatype = ( dbtype == NCBI_DNA_DB ) ? eslDNA : eslAMINO ; ncbi -> index = 0 ; len = htobe32 ( info [ 2 ] ) ; ESL_ALLOC ( ncbi -> title , sizeof ( char ) * ( len + 1 ) ) ; if ( fread ( ncbi -> title , sizeof ( char ) , len , ncbi -> fppin ) != len ) { status = eslFAIL ; goto ERROR ; } ncbi -> title [ len ] = 0 ; if ( fread ( & info [ 0 ] , sizeof ( uint32_t ) , 1 , ncbi -> fppin ) != 1 ) { status = eslFAIL ; goto ERROR ; } len = htobe32 ( info [ 0 ] ) ; ESL_ALLOC ( ncbi -> timestamp , sizeof ( char ) * ( len + 1 ) ) ; if ( fread ( ncbi -> timestamp , sizeof ( char ) , len , ncbi -> fppin ) != len ) { status = eslFAIL ; goto ERROR ; } ncbi -> timestamp [ len ] = 0 ; if ( fread ( & info [ 0 ] , sizeof ( uint32_t ) , 4 , ncbi -> fppin ) != 4 ) { status = eslFAIL ; goto ERROR ; } ncbi -> num_seq = htobe32 ( info [ 0 ] ) ; memcpy ( & ncbi -> total_res , info + 1 , sizeof ( uint64_t ) ) ; ncbi -> max_seq = htobe32 ( info [ 3 ] ) ; ncbi -> hdr_off = ftell ( ncbi -> fppin ) ; ncbi -> seq_off = ncbi -> hdr_off + sizeof ( uint32_t ) * ( ncbi -> num_seq + 1 ) ; return eslOK ; ERROR : return status ; }
sqncbi_ParseIndexFile()
 Parse an open index file verifying database type and version
 if handled.
sqncbi_ParseIndexFile () Parse an open index file verifying database type and version if handled .
/* return status from an ESL call */ /* read the database title */ /* read the database time stamp */ /* read in database stats */ /* save the offsets to the index tables */