| 1 |
|
| 2 |
|
| 3 |
#ifndef eslALPHABET_INCLUDED |
| 4 |
#define eslALPHABET_INCLUDED |
| 5 |
#include <esl_config.h> |
| 6 |
|
| 7 |
#include <ctype.h> |
| 8 |
#include "easel.h" |
| 9 |
#ifdef __cplusplus |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#define eslUNKNOWN 0 |
| 16 |
#define eslRNA 1 |
| 17 |
#define eslDNA 2 |
| 18 |
#define eslAMINO 3 |
| 19 |
#define eslCOINS 4 |
| 20 |
#define eslDICE 5 |
| 21 |
#define eslNONSTANDARD 6 |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
typedef struct { |
| 28 |
int type; |
| 29 |
int K; |
| 30 |
int Kp; |
| 31 |
char *sym; |
| 32 |
ESL_DSQ inmap[128]; |
| 33 |
char **degen; |
| 34 |
int *ndegen; |
| 35 |
ESL_DSQ *complement; |
| 36 |
} ESL_ALPHABET; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
extern ESL_ALPHABET *esl_alphabet_Create(int type); |
| 44 |
extern ESL_ALPHABET *esl_alphabet_CreateCustom(const char *alphabet, int K, int Kp); |
| 45 |
extern int esl_alphabet_SetEquiv(ESL_ALPHABET *a, char sym, char c); |
| 46 |
extern int esl_alphabet_SetCaseInsensitive(ESL_ALPHABET *a); |
| 47 |
extern int esl_alphabet_SetDegeneracy(ESL_ALPHABET *a, char c, char *ds); |
| 48 |
extern int esl_alphabet_SetIgnored(ESL_ALPHABET *a, const char *ignoredchars); |
| 49 |
extern size_t esl_alphabet_Sizeof(ESL_ALPHABET *a); |
| 50 |
extern void esl_alphabet_Destroy(ESL_ALPHABET *a); |
| 51 |
|
| 52 |
|
| 53 |
extern int esl_abc_CreateDsq(const ESL_ALPHABET *a, const char *seq, ESL_DSQ **ret_dsq); |
| 54 |
extern int esl_abc_Digitize (const ESL_ALPHABET *a, const char *seq, ESL_DSQ *dsq); |
| 55 |
extern int esl_abc_Textize (const ESL_ALPHABET *a, const ESL_DSQ *dsq, int64_t L, char *seq); |
| 56 |
extern int esl_abc_TextizeN (const ESL_ALPHABET *a, const ESL_DSQ *dptr, int64_t L, char *buf); |
| 57 |
extern int esl_abc_dsqcpy(const ESL_DSQ *dsq, int64_t L, ESL_DSQ *dcopy); |
| 58 |
extern int esl_abc_dsqdup(const ESL_DSQ *dsq, int64_t L, ESL_DSQ **ret_dup); |
| 59 |
extern int esl_abc_dsqcat (const ESL_DSQ *inmap, ESL_DSQ **dsq, int64_t *L, const char *s, esl_pos_t n); |
| 60 |
extern int esl_abc_dsqcat_noalloc(const ESL_DSQ *inmap, ESL_DSQ *dsq, int64_t *L, const char *s, esl_pos_t n); |
| 61 |
extern int64_t esl_abc_dsqlen(const ESL_DSQ *dsq); |
| 62 |
extern int64_t esl_abc_dsqrlen(const ESL_ALPHABET *a, const ESL_DSQ *dsq); |
| 63 |
extern int esl_abc_CDealign(const ESL_ALPHABET *abc, char *s, const ESL_DSQ *ref_ax, int64_t *opt_rlen); |
| 64 |
extern int esl_abc_XDealign(const ESL_ALPHABET *abc, ESL_DSQ *x, const ESL_DSQ *ref_ax, int64_t *opt_rlen); |
| 65 |
extern int esl_abc_ConvertDegen2X(const ESL_ALPHABET *abc, ESL_DSQ *dsq); |
| 66 |
extern int esl_abc_revcomp(const ESL_ALPHABET *abc, ESL_DSQ *dsq, int n); |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
extern int esl_abc_ValidateType(int type); |
| 71 |
extern int esl_abc_GuessAlphabet(const int64_t *ct, int *ret_type); |
| 72 |
extern double esl_abc_Match (const ESL_ALPHABET *a, ESL_DSQ x, ESL_DSQ y, double *p); |
| 73 |
extern int esl_abc_IAvgScore (const ESL_ALPHABET *a, ESL_DSQ x, const int *sc); |
| 74 |
extern float esl_abc_FAvgScore (const ESL_ALPHABET *a, ESL_DSQ x, const float *sc); |
| 75 |
extern double esl_abc_DAvgScore (const ESL_ALPHABET *a, ESL_DSQ x, const double *sc); |
| 76 |
extern int esl_abc_IExpectScore(const ESL_ALPHABET *a, ESL_DSQ x, const int *sc, const float *p); |
| 77 |
extern float esl_abc_FExpectScore(const ESL_ALPHABET *a, ESL_DSQ x, const float *sc, const float *p); |
| 78 |
extern double esl_abc_DExpectScore(const ESL_ALPHABET *a, ESL_DSQ x, const double *sc, const double *p); |
| 79 |
|
| 80 |
extern int esl_abc_IAvgScVec (const ESL_ALPHABET *a, int *sc); |
| 81 |
extern int esl_abc_FAvgScVec (const ESL_ALPHABET *a, float *sc); |
| 82 |
extern int esl_abc_DAvgScVec (const ESL_ALPHABET *a, double *sc); |
| 83 |
extern int esl_abc_IExpectScVec(const ESL_ALPHABET *a, int *sc, const float *p); |
| 84 |
extern int esl_abc_FExpectScVec(const ESL_ALPHABET *a, float *sc, const float *p); |
| 85 |
extern int esl_abc_DExpectScVec(const ESL_ALPHABET *a, double *sc, const double *p); |
| 86 |
extern int esl_abc_FCount (const ESL_ALPHABET *a, float *ct, ESL_DSQ x, float wt); |
| 87 |
extern int esl_abc_DCount (const ESL_ALPHABET *a, double *ct, ESL_DSQ x, double wt); |
| 88 |
extern int esl_abc_EncodeType (char *typestring); |
| 89 |
extern int esl_abc_EncodeTypeMem(char *type, int n); |
| 90 |
extern char *esl_abc_DecodeType (int type); |
| 91 |
extern int esl_abc_ValidateSeq(const ESL_ALPHABET *a, const char *seq, int64_t L, char *errbuf); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
#define esl_abc_DigitizeSymbol(a, c) ((a)->inmap[(int)c]) |
| 102 |
#define esl_abc_XIsValid(a, x) ((x) < (a)->Kp) |
| 103 |
#define esl_abc_XIsResidue(a, x) ((x) < (a)->K || ((x) > (a)->K && (x) < (a)->Kp-2)) |
| 104 |
#define esl_abc_XIsCanonical(a, x) ((x) < (a)->K) |
| 105 |
#define esl_abc_XIsGap(a, x) ((x) == (a)->K) |
| 106 |
#define esl_abc_XIsDegenerate(a, x) ((x) > (a)->K && (x) < (a)->Kp-2) |
| 107 |
#define esl_abc_XIsUnknown(a, x) ((x) == (a)->Kp-3) |
| 108 |
#define esl_abc_XIsNonresidue(a, x) ((x) == (a)->Kp-2) |
| 109 |
#define esl_abc_XIsMissing(a, x) ((x) == (a)->Kp-1) |
| 110 |
#define esl_abc_XGetGap(a) ((a)->K) |
| 111 |
#define esl_abc_XGetUnknown(a) ((a)->Kp-3) |
| 112 |
#define esl_abc_XGetNonresidue(a) ((a)->Kp-2) |
| 113 |
#define esl_abc_XGetMissing(a) ((a)->Kp-1) |
| 114 |
|
| 115 |
|
| 116 |
#define esl_abc_CIsValid(a, c) (isascii(c) && (a)->inmap[(int)c] < (a)->Kp) |
| 117 |
#define esl_abc_CIsResidue(a, c) ((a)->inmap[(int)c] < (a)->K || ((a)->inmap[(int)c] > (a)->K && (a)->inmap[(int)c] < (a)->Kp-2)) |
| 118 |
#define esl_abc_CIsCanonical(a, c) ((a)->inmap[(int)c] < (a)->K) |
| 119 |
#define esl_abc_CIsGap(a, c) ((a)->inmap[(int)c] == (a)->K) |
| 120 |
#define esl_abc_CIsDegenerate(a, c) ((a)->inmap[(int)c] > (a)->K && (a)->inmap[(int)c] < (a)->Kp-2) |
| 121 |
#define esl_abc_CIsUnknown(a, c) ((a)->inmap[(int)c] == (a)->Kp-3) |
| 122 |
#define esl_abc_CIsNonresidue(a, c) ((a)->inmap[(int)c] == (a)->Kp-2) |
| 123 |
#define esl_abc_CIsMissing(a, c) ((a)->inmap[(int)c] == (a)->Kp-1) |
| 124 |
#define esl_abc_CGetGap(a) ((a)->sym[(a)->K]) |
| 125 |
#define esl_abc_CGetUnknown(a) ((a)->sym[(a)->Kp-3]) |
| 126 |
#define esl_abc_CGetNonresidue(a) ((a)->sym[(a)->Kp-2]) |
| 127 |
#define esl_abc_CGetMissing(a) ((a)->sym[(a)->Kp-1]) |
| 128 |
#ifdef __cplusplus |
| 129 |
} |
| 130 |
#endif |
| 131 |
#endif |