hmmer-3.3/easel/esl_sqio_ncbi.c
/* sqncbi_DbOpen()
 *
 * Try to open the database files.  On successful opening of
 * the files, index, header and sequence, the index file is
 * parsed for validity.
 */
sqncbi_DbOpen()
Try to open the database files.  On successful opening of
the files, index, header and sequence, the index file is
parsed for validity.
sqncbi_DbOpen () Try to open the database files . On successful opening of the files index header and sequence the index file is parsed for validity .
static int
sqncbi_DbOpen(ESL_SQNCBI_DATA *ncbi, char *filename, int dbtype)
{
  int         status = eslOK;	
  int         len;
  char       *name = NULL;
  len = strlen(filename);
  ESL_ALLOC(name, sizeof(char) * (len+5));
  strcpy(name, filename);
  strcpy(name+len, ".Xin");
  name[len+1] = (dbtype == NCBI_DNA_DB) ? 'n' : 'p';
  if ((ncbi->fppin = fopen(name, "rb")) == NULL) {
    status = eslENOTFOUND; 
    goto ERROR;
  }
  strcpy(name+len, ".Xhr");
  name[len+1] = (dbtype == NCBI_DNA_DB) ? 'n' : 'p';
  if ((ncbi->fpphr = fopen(name, "rb")) == NULL) {
    status = eslENOTFOUND; 
    goto ERROR;
  }
  strcpy(name+len, ".Xsq");
  name[len+1] = (dbtype == NCBI_DNA_DB) ? 'n' : 'p';
  if ((ncbi->fppsq = fopen(name, "rb")) == NULL) {
    status = eslENOTFOUND; 
    goto ERROR;
  }
  if ((status = sqncbi_ParseIndexFile(ncbi, dbtype)) != eslOK) goto ERROR;
  if (name != NULL) free(name);
  return eslOK;
 ERROR:
  reset_db(ncbi);
  if (name != NULL) free(name);
  return status;
}
static int sqncbi_DbOpen ( ESL_SQNCBI_DATA * ncbi , char * filename , int dbtype ) { int status = eslOK ; int len ; char * name = NULL ; len = strlen ( filename ) ; ESL_ALLOC ( name , sizeof ( char ) * ( len + 5 ) ) ; strcpy ( name , filename ) ; strcpy ( name + len , " " ) ; name [ len + 1 ] = ( dbtype == NCBI_DNA_DB ) ? ' ' : ' ' ; if ( ( ncbi -> fppin = fopen ( name , " " ) ) == NULL ) { status = eslENOTFOUND ; goto ERROR ; } strcpy ( name + len , " " ) ; name [ len + 1 ] = ( dbtype == NCBI_DNA_DB ) ? ' ' : ' ' ; if ( ( ncbi -> fpphr = fopen ( name , " " ) ) == NULL ) { status = eslENOTFOUND ; goto ERROR ; } strcpy ( name + len , " " ) ; name [ len + 1 ] = ( dbtype == NCBI_DNA_DB ) ? ' ' : ' ' ; if ( ( ncbi -> fppsq = fopen ( name , " " ) ) == NULL ) { status = eslENOTFOUND ; goto ERROR ; } if ( ( status = sqncbi_ParseIndexFile ( ncbi , dbtype ) ) != eslOK ) goto ERROR ; if ( name != NULL ) free ( name ) ; return eslOK ; ERROR : reset_db ( ncbi ) ; if ( name != NULL ) free ( name ) ; return status ; }
sqncbi_DbOpen()
 Try to open the database files.
sqncbi_DbOpen () Try to open the database files .
/* return status from an ESL call */ /* Check for basic database first */ /* parse the header make sure we are looking at a version 4 db. */