hmmer-3.3/easel/esl_sq.c
/* Function:  esl_sq_GuessAlphabet()
 * Synopsis:  Guess alphabet type of a single sequence.
 *
 * Purpose:   Guess the alphabet type of biosequence <sq>, and store the
 *            guess in <*ret_type>.
 *            
 *            All 26 letters are valid in the amino alphabet (even <O>
 *            and <J> now), so the DNA alphabet is necessarily a subset.
 *            Therefore most protein sequences can be identified
 *            unambiguously (because they use letters that only occur
 *            in amino acid sequence), but DNA sequences cannot be.
 *            
 *            The sequence must contain more than 10 residues, or it
 *            is called <eslUNKNOWN>.
 *
 *            For details on the rules used to classify a residue
 *            composition, see <esl_abc_GuessAlphabet()>. The rules
 *            are good but not perfect. We err on the conservative
 *            side, calling <eslUNKNOWN> rather than making
 *            classification errors. However, errors are possible; an
 *            example is a protein sequence <ACGTACGTACGT...>
 *            ("ala-cys-gly-thr..."), which will be called <eslDNA>,
 *            because it contains all and only DNA residues.
 *
 *            The routine is tested on large sequence databases to
 *            make sure there are zero false positive classifications
 *            on known sequences. See <esl_abc_GuessAlphabet()> for
 *            details of these tests, and crossreferences.
 *
 * Returns:   <eslOK> on success, and <*ret_type> is set to
 *            <eslAMINO>, <eslRNA>, or <eslDNA>.
 *
 *            Returns <eslENOALPHABET> if unable to determine the
 *            alphabet type; in this case, <*ret_type> is set to 
 *            <eslUNKNOWN>.
 *
 * Xref:      See notes on esl_alphabet.c::esl_abc_GuessAlphabet()
 */
esl_sq_GuessAlphabet()
Synopsis:  Guess alphabet type of a single sequence.

Guess the alphabet type of biosequence , and store the
guess in <*ret_type>.

All 26 letters are valid in the amino alphabet (even 
and  now), so the DNA alphabet is necessarily a subset.
Therefore most protein sequences can be identified
unambiguously (because they use letters that only occur
in amino acid sequence), but DNA sequences cannot be.

The sequence must contain more than 10 residues, or it
is called .

For details on the rules used to classify a residue
composition, see . The rules
are good but not perfect. We err on the conservative
side, calling  rather than making
classification errors. However, errors are possible; an
example is a protein sequence 
("ala-cys-gly-thr..."), which will be called ,
because it contains all and only DNA residues.

The routine is tested on large sequence databases to
make sure there are zero false positive classifications
on known sequences. See  for
details of these tests, and crossreferences.

 on success, and <*ret_type> is set to
, , or .

Returns  if unable to determine the
alphabet type; in this case, <*ret_type> is set to
.


esl_sq_GuessAlphabet () Synopsis : Guess alphabet type of a single sequence . Guess the alphabet type of biosequence and store the guess in < * ret_type > . All 26 letters are valid in the amino alphabet ( even and now ) so the DNA alphabet is necessarily a subset . Therefore most protein sequences can be identified unambiguously ( because they use letters that only occur in amino acid sequence ) but DNA sequences cannot be . The sequence must contain more than 10 residues or it is called . For details on the rules used to classify a residue composition see . The rules are good but not perfect . We err on the conservative side calling rather than making classification errors . However errors are possible ; an example is a protein sequence ( " ala - cys - gly - thr ... " ) which will be called because it contains all and only DNA residues . The routine is tested on large sequence databases to make sure there are zero false positive classifications on known sequences . See for details of these tests and crossreferences . on success and < * ret_type > is set to or . Returns if unable to determine the alphabet type ; in this case < * ret_type > is set to .
int
esl_sq_GuessAlphabet(ESL_SQ *sq, int *ret_type)
{
  int64_t ct[26];
  int     x;
  int64_t i;
  int64_t n = 0;
  for (x = 0; x < 26; x++) ct[x] = 0;
  for (i = 0; i < sq->n; i++) {
    x = toupper(sq->seq[i]) - 'A';
    if (x < 0 || x > 26) continue;
    ct[x]++;
    n++;
    if (n > 10000) break;	
  }
  return esl_abc_GuessAlphabet(ct, ret_type);
}
int esl_sq_GuessAlphabet ( ESL_SQ * sq , int * ret_type ) { int64_t ct [ 26 ] ; int x ; int64_t i ; int64_t n = 0 ; for ( x = 0 ; x < 26 ; x ++ ) ct [ x ] = 0 ; for ( i = 0 ; i < sq -> n ; i ++ ) { x = toupper ( sq -> seq [ i ] ) - ' ' ; if ( x < 0 || x > 26 ) continue ; ct [ x ] ++ ; n ++ ; if ( n > 10000 ) break ; } return esl_abc_GuessAlphabet ( ct , ret_type ) ; }
Function:  esl_sq_GuessAlphabet()
 Synopsis:  Guess alphabet type of a single sequence.
Function : esl_sq_GuessAlphabet () Synopsis : Guess alphabet type of a single sequence .
/* we oughta know by now! */