hmmer-3.3/easel/esl_sqio_ncbi.c
/* Function:  sqncbi_Read()
 * Synopsis:  Read the next sequence from a file.
 * Incept:    MSF, Mon Dec 10, 2009 [Janelia]
 *
 * Purpose:   Reads the next sequence from open sequence file <sqfp> into 
 *            <sq>. Caller provides an allocated and initialized <s>, which
 *            will be internally reallocated if its space is insufficient.
 *
 * Returns:   <eslOK> on success; the new sequence is stored in <s>.
 * 
 *            Returns <eslEOF> when there is no sequence left in the
 *            file (including first attempt to read an empty file).
 * 
 *            Returns <eslEFORMAT> if there's a problem with the format,
 *            such as an illegal character; the line number that the parse
 *            error occurs on is in <sqfp->linenumber>, and an informative
 *            error message is placed in <sqfp->errbuf>. 
 *
 * Throws:    <eslEMEM> on allocation failure;
 *            <eslEINCONCEIVABLE> on internal error.
 */
sqncbi_Read()
Synopsis:  Read the next sequence from a file.
Incept:    MSF, Mon Dec 10, 2009 [Janelia]

Reads the next sequence from open sequence file  into
. Caller provides an allocated and initialized , which
will be internally reallocated if its space is insufficient.

 on success; the new sequence is stored in .

Returns  when there is no sequence left in the
file (including first attempt to read an empty file).

Returns  if there's a problem with the format,
such as an illegal character; the line number that the parse
error occurs on is in linenumber>, and an informative
error message is placed in errbuf>.

 on allocation failure;
 on internal error.
sqncbi_Read () Synopsis : Read the next sequence from a file . Incept : MSF Mon Dec 10 2009 [ Janelia ] Reads the next sequence from open sequence file into . Caller provides an allocated and initialized which will be internally reallocated if its space is insufficient . on success ; the new sequence is stored in . Returns when there is no sequence left in the file ( including first attempt to read an empty file ) . Returns if there ' s a problem with the format such as an illegal character ; the line number that the parse error occurs on is in linenumber > and an informative error message is placed in errbuf > . on allocation failure ; on internal error .
static int
sqncbi_Read(ESL_SQFILE *sqfp, ESL_SQ *sq)
{
  int  status;
  ESL_SQNCBI_DATA *ncbi = &sqfp->data.ncbi;
  if (ncbi->index >= ncbi->num_seq) return eslEOF;
  if ((status = pos_sequence(ncbi, ncbi->index)) != eslOK) return status;
  sq->idx  = ncbi->index;
  sq->roff = ncbi->roff;
  sq->doff = ncbi->doff;
  sq->hoff = ncbi->hoff;
  sq->eoff = ncbi->eoff;
  if (ncbi->alphatype == eslAMINO) 
    status = read_amino(sqfp, sq);
  else                             
    status = read_dna(sqfp, sq);
  if (status != eslOK) return status;
  if ((status = parse_header(ncbi, sq)) != eslOK) return status;
  (ncbi->index)++;
  return eslOK;
}
static int sqncbi_Read ( ESL_SQFILE * sqfp , ESL_SQ * sq ) { int status ; ESL_SQNCBI_DATA * ncbi = & sqfp -> data . ncbi ; if ( ncbi -> index >= ncbi -> num_seq ) return eslEOF ; if ( ( status = pos_sequence ( ncbi , ncbi -> index ) ) != eslOK ) return status ; sq -> idx = ncbi -> index ; sq -> roff = ncbi -> roff ; sq -> doff = ncbi -> doff ; sq -> hoff = ncbi -> hoff ; sq -> eoff = ncbi -> eoff ; if ( ncbi -> alphatype == eslAMINO ) status = read_amino ( sqfp , sq ) ; else status = read_dna ( sqfp , sq ) ; if ( status != eslOK ) return status ; if ( ( status = parse_header ( ncbi , sq ) ) != eslOK ) return status ; ( ncbi -> index ) ++ ; return eslOK ; }
Function:  sqncbi_Read()
 Synopsis:  Read the next sequence from a file.
Function : sqncbi_Read () Synopsis : Read the next sequence from a file .
//int  index; //index = ncbi->index + 1; /* Disk offset bookkeeping */ /* read and parse the ncbi header */