third_party_software/hmmer-3.0-linux-intel-x86_64/easel/miniapps/esl-alimanip.c
/* Function: read_seq_name_file
 * Date:     EPN, Thu Jun  5 13:21:36 2008
 * 
 * Read a file listing sequence names to remove or keep.
 * Store sequences in *ret_seqlist and return it.
 * Each white-space delimited token is considered a 
 * different sequence name. No checking is done in this 
 * function, but rather in subsequent functions. 
 * 
 * Returns eslOK on success.
 */


Read a file listing sequence names to remove or keep.
Store sequences in *ret_seqlist and return it.
Each white-space delimited token is considered a
different sequence name. No checking is done in this
function, but rather in subsequent functions.

Returns eslOK on success.
Read a file listing sequence names to remove or keep . Store sequences in * ret_seqlist and return it . Each white - space delimited token is considered a different sequence name . No checking is done in this function but rather in subsequent functions . Returns eslOK on success .
int
read_seq_name_file(char *filename, char *errbuf, char ***ret_seqlist, int *ret_seqlist_n)
{
  int             status;
  ESL_FILEPARSER *efp;
  char           *tok;
  int             toklen;
  int nalloc     = 10;
  int chunksize  = 10;
  char **seqlist = NULL;
  int n = 0;
  int i;
  void *tmp;
  ESL_ALLOC(seqlist, sizeof(char *) * nalloc);
  if (esl_fileparser_Open(filename, NULL,  &efp) != eslOK) ESL_FAIL(eslEINVAL, errbuf, "failed to open %s in read_seq_name_file\n", filename);
  while((status = esl_fileparser_GetToken(efp, &tok, &toklen)) != eslEOF) {
    if(n == nalloc) { nalloc += chunksize; ESL_RALLOC(seqlist, tmp, sizeof(char *) * nalloc); }
    if((status = esl_strdup(tok, -1, &(seqlist[n++]))) != eslOK) ESL_FAIL(status, errbuf, "error in esl_strdup.");
  }
  esl_fileparser_Close(efp);
  *ret_seqlist = seqlist;
  *ret_seqlist_n = n;
  return eslOK;
 ERROR:
  if(seqlist != NULL) {
    for(i = 0; i < n; i++) free(seqlist[i]); 
    free(seqlist);
  }
  return status;
}
int read_seq_name_file ( char * filename , char * errbuf , char * * * ret_seqlist , int * ret_seqlist_n ) { int status ; ESL_FILEPARSER * efp ; char * tok ; int toklen ; int nalloc = 10 ; int chunksize = 10 ; char * * seqlist = NULL ; int n = 0 ; int i ; void * tmp ; ESL_ALLOC ( seqlist , sizeof ( char * ) * nalloc ) ; if ( esl_fileparser_Open ( filename , NULL , & efp ) != eslOK ) ESL_FAIL ( eslEINVAL , errbuf , " \n " , filename ) ; while ( ( status = esl_fileparser_GetToken ( efp , & tok , & toklen ) ) != eslEOF ) { if ( n == nalloc ) { nalloc += chunksize ; ESL_RALLOC ( seqlist , tmp , sizeof ( char * ) * nalloc ) ; } if ( ( status = esl_strdup ( tok , -1 , & ( seqlist [ n ++ ] ) ) ) != eslOK ) ESL_FAIL ( status , errbuf , " " ) ; } esl_fileparser_Close ( efp ) ; * ret_seqlist = seqlist ; * ret_seqlist_n = n ; return eslOK ; ERROR : if ( seqlist != NULL ) { for ( i = 0 ; i < n ; i ++ ) free ( seqlist [ i ] ) ; free ( seqlist ) ; } return status ; }
Function: read_seq_name_file
 Date:     EPN, Thu Jun  5 13:21:36 2008
Function : read_seq_name_file Date : EPN Thu Jun 5 13 : 21 : 36 2008