hmmer-3.3/easel/esl_msafile_stockholm.c
/* stockholm_get_seqidx()
 * 
 * Find the index of a given sequence <name>,<n> in a growing <msa>
 * with associated parse data <pdat>. If caller has a good guess (for
 * instance, the sequences are coming in a previously seen order in a
 * block of seqs or annotation), the caller can pass this information
 * in <guess>, or -1 if it has no guess.
 * 
 * If the name does not already exist in the MSA, then it
 * is assumed to be a new sequence name that we need to store.
 * seqidx is set to pdat->nseq, the MSA is Expand()'ed if necessary
 * to make room, the name is stored in msa->sqname[pdat->nseq],
 * and pdat->nseq is incremented.
 *
 * Returns:  <eslOK> on success, and the seqidx is 
 *           passed back via <ret_idx>. If <name> is new
 *           in the <msa>, the <name> is stored and the <msa> 
 *           may be internally reallocated if needed.
 *           
 * Throws: <eslEMEM> on allocation failure
 *         <eslEINVAL> if we try to add a name to a non-growable MSA.
 *         <eslEINCONCEIVABLE> on internal coding errors
 */


Find the index of a given sequence , in a growing 
with associated parse data . If caller has a good guess (for
instance, the sequences are coming in a previously seen order in a
block of seqs or annotation), the caller can pass this information
in , or -1 if it has no guess.

If the name does not already exist in the MSA, then it
is assumed to be a new sequence name that we need to store.
seqidx is set to pdat->nseq, the MSA is Expand()'ed if necessary
to make room, the name is stored in msa->sqname[pdat->nseq],
and pdat->nseq is incremented.

 on success, and the seqidx is
passed back via . If  is new
in the , the  is stored and the 
may be internally reallocated if needed.

 on allocation failure
 if we try to add a name to a non-growable MSA.
 on internal coding errors
Find the index of a given sequence in a growing with associated parse data . If caller has a good guess ( for instance the sequences are coming in a previously seen order in a block of seqs or annotation ) the caller can pass this information in or - 1 if it has no guess . If the name does not already exist in the MSA then it is assumed to be a new sequence name that we need to store . seqidx is set to pdat - > nseq the MSA is Expand () ' ed if necessary to make room the name is stored in msa - > sqname [ pdat - > nseq ] and pdat - > nseq is incremented . on success and the seqidx is passed back via . If is new in the the is stored and the may be internally reallocated if needed . on allocation failure if we try to add a name to a non - growable MSA . on internal coding errors
static int
stockholm_get_seqidx(ESL_MSA *msa, ESL_STOCKHOLM_PARSEDATA *pd, char *name, esl_pos_t n, int *ret_idx)
{
  int seqidx;
  int status;
  status = esl_keyhash_Store(msa->index, name, n, &seqidx);
  if (status == eslEDUP) { *ret_idx = seqidx; return eslOK; }
  if (status != eslOK)   goto ERROR;
  if (seqidx >= msa->sqalloc) {
    if ( (status = esl_msa_Expand(msa))                    != eslOK) goto ERROR;
    if ( (status = stockholm_parsedata_ExpandSeq(pd, msa)) != eslOK) goto ERROR;
  }  
  if ( (status = esl_msa_SetSeqName(msa, seqidx, name, n)) != eslOK) goto ERROR;
  pd->nseq++;
  msa->nseq = pd->nseq;		
  *ret_idx = seqidx;
  return eslOK;
 ERROR:
  *ret_idx = -1;
  return status;
}
static int stockholm_get_seqidx ( ESL_MSA * msa , ESL_STOCKHOLM_PARSEDATA * pd , char * name , esl_pos_t n , int * ret_idx ) { int seqidx ; int status ; status = esl_keyhash_Store ( msa -> index , name , n , & seqidx ) ; if ( status == eslEDUP ) { * ret_idx = seqidx ; return eslOK ; } if ( status != eslOK ) goto ERROR ; if ( seqidx >= msa -> sqalloc ) { if ( ( status = esl_msa_Expand ( msa ) ) != eslOK ) goto ERROR ; if ( ( status = stockholm_parsedata_ExpandSeq ( pd , msa ) ) != eslOK ) goto ERROR ; } if ( ( status = esl_msa_SetSeqName ( msa , seqidx , name , n ) ) != eslOK ) goto ERROR ; pd -> nseq ++ ; msa -> nseq = pd -> nseq ; * ret_idx = seqidx ; return eslOK ; ERROR : * ret_idx = -1 ; return status ; }
stockholm_get_seqidx()
stockholm_get_seqidx ()
/* if we get here, this is a new name we're adding */ /* pd->nseq and msa->nseq must stay in lockstep */