third_party_software/hmmer-3.0-linux-intel-x86_64/easel/miniapps/esl-alimanip.c
/* read_sqfile
 *                   
 * Read all seqs in a sequence file and return them. Originally
 * written for --trim option.
 */


Read all seqs in a sequence file and return them. Originally
written for --trim option.
Read all seqs in a sequence file and return them . Originally written for -- trim option .
static int read_sqfile(ESL_SQFILE *sqfp, const ESL_ALPHABET *abc, int nseq, ESL_SQ ***ret_sq)
{
  int status;
  ESL_SQ **sq; 
  int i;
  ESL_ALLOC(sq, sizeof(ESL_SQ *) * (nseq + 1)); 
  i = 0;
  sq[i] = esl_sq_CreateDigital(abc);
  while ((status = esl_sqio_Read(sqfp, sq[i])) == eslOK) { 
    i++;
    if(i > nseq) esl_fatal("With --trim, sequence file must have same number seqs as in <msafile>\n"); 
    sq[i] = esl_sq_CreateDigital(abc);
  }
  if (i != nseq) esl_fatal("With --trim, sequence file must have same number seqs as in <msafile>\n"); 
  esl_sq_Destroy(sq[i]); 
  if      (status == eslEFORMAT) esl_fatal("Parse failed (sequence file %s):\n%s\n",
					   sqfp->filename, esl_sqfile_GetErrorBuf(sqfp));
  else if (status != eslEOF)     esl_fatal("Unexpected error %d reading sequence file %s",
					    status, sqfp->filename);
  esl_sqfile_Close(sqfp);
  *ret_sq = sq;
  return eslOK;
 ERROR:
  esl_fatal("Memory allocation error.");
  return status; 
}
static int read_sqfile ( ESL_SQFILE * sqfp , const ESL_ALPHABET * abc , int nseq , ESL_SQ * * * ret_sq ) { int status ; ESL_SQ * * sq ; int i ; ESL_ALLOC ( sq , sizeof ( ESL_SQ * ) * ( nseq + 1 ) ) ; i = 0 ; sq [ i ] = esl_sq_CreateDigital ( abc ) ; while ( ( status = esl_sqio_Read ( sqfp , sq [ i ] ) ) == eslOK ) { i ++ ; if ( i > nseq ) esl_fatal ( " \n " ) ; sq [ i ] = esl_sq_CreateDigital ( abc ) ; } if ( i != nseq ) esl_fatal ( " \n " ) ; esl_sq_Destroy ( sq [ i ] ) ; if ( status == eslEFORMAT ) esl_fatal ( " \n \n " , sqfp -> filename , esl_sqfile_GetErrorBuf ( sqfp ) ) ; else if ( status != eslEOF ) esl_fatal ( " " , status , sqfp -> filename ) ; esl_sqfile_Close ( sqfp ) ; * ret_sq = sq ; return eslOK ; ERROR : esl_fatal ( " " ) ; return status ; }
read_sqfile
read_sqfile
/* get seqs from sqfile */ /* +1 for the last guy we allocate but don't use */ /* status should be eslEOF on normal end; if it isn't, deal w/ error */ /* destroy final allocated but unused seq */ /* NEVERREACHED */