Debian Codegraph @

easel/esl_scorematrix.h

raw symbols SCIP
1 /* Routines for manipulating sequence alignment score matrices.
2 */
3 #ifndef eslSCOREMATRIX_INCLUDED
4 #define eslSCOREMATRIX_INCLUDED
5 #include <esl_config.h>
6
7 #include "esl_alphabet.h"
8 #include "esl_fileparser.h"
9 #include "esl_dmatrix.h"
10
11 /* ESL_SCOREMATRIX:
12 * allocation is in one array in s[0].
13 *
14 * i,j can range from 0..Kp-1, including all characters valid in the alphabet.
15 * Only values for 0..K-1 (canonical alphabet) are mandatory.
16 */
17 typedef struct {
18 int **s; /* s[i][j] is the score of aligning residue i,j; i,j range 0..Kp-1 */
19 int K; /* size of base alphabet (duplicate of S->abc_r->K) */
20 int Kp; /* full size of s[][], including degeneracies (duplicate of S->abc_r->Kp) */
21
22 /* bookkeeping for degenerate residues */
23 char *isval; /* array 0..Kp-1: which residues of alphabet have valid scores in S. */
24 const ESL_ALPHABET *abc_r; /* reference to the alphabet: includes K, Kp, and sym order */
25
26 /* bookkeeping that lets us output exactly the residue order we read in a matrix file */
27 int nc; /* number of residues with scores (inclusive of *, if present) */
28 char *outorder; /* NUL-terminated string 0..nc-1 giving order of residues in col/row labels */
29
30 char *name; /* optional: name of score matrix; or NULL */
31 char *path; /* optional: full path to file that score matrix was read from; or NULL */
32 } ESL_SCOREMATRIX;
33
34
35
36 /* 1. The ESL_SCOREMATRIX object. */
37 extern ESL_SCOREMATRIX *esl_scorematrix_Create(const ESL_ALPHABET *abc);
38 extern int esl_scorematrix_Copy(const ESL_SCOREMATRIX *src, ESL_SCOREMATRIX *dest);
39 extern ESL_SCOREMATRIX *esl_scorematrix_Clone(const ESL_SCOREMATRIX *S);
40 extern int esl_scorematrix_Compare(const ESL_SCOREMATRIX *S1, const ESL_SCOREMATRIX *S2);
41 extern int esl_scorematrix_CompareCanon(const ESL_SCOREMATRIX *S1, const ESL_SCOREMATRIX *S2);
42 extern int esl_scorematrix_Max(const ESL_SCOREMATRIX *S);
43 extern int esl_scorematrix_Min(const ESL_SCOREMATRIX *S);
44 extern int esl_scorematrix_IsSymmetric(const ESL_SCOREMATRIX *S);
45 extern int esl_scorematrix_ExpectedScore(ESL_SCOREMATRIX *S, double *fi, double *fj, double *ret_E);
46 extern int esl_scorematrix_RelEntropy(const ESL_SCOREMATRIX *S, const double *fi, const double *fj,
47 double lambda, double *ret_D);
48 extern int esl_scorematrix_JointToConditionalOnQuery(const ESL_ALPHABET *abc, ESL_DMATRIX *P);
49 extern void esl_scorematrix_Destroy(ESL_SCOREMATRIX *S);
50
51 /* 2. Some classic score matrices */
52 extern int esl_scorematrix_Set(const char *name, ESL_SCOREMATRIX *S);
53 extern int esl_scorematrix_SetIdentity(ESL_SCOREMATRIX *S);
54
55 /* 3. Deriving a score matrix probabilistically */
56 extern int esl_scorematrix_SetFromProbs(ESL_SCOREMATRIX *S, double lambda, const ESL_DMATRIX *P,
57 const double *fi, const double *fj);
58 extern int esl_scorematrix_SetWAG(ESL_SCOREMATRIX *S, double lambda, double t);
59
60 /* 4. Reading/writing score matrices. */
61 extern int esl_scorematrix_Read(ESL_FILEPARSER *efp, const ESL_ALPHABET *abc, ESL_SCOREMATRIX **ret_S);
62 extern int esl_scorematrix_Write(FILE *fp, const ESL_SCOREMATRIX *S);
63
64 /* 5. Implicit probabilistic basis, I: given bg. */
65 extern int esl_scorematrix_ProbifyGivenBG(const ESL_SCOREMATRIX *S, const double *fi, const double *fj,
66 double *opt_lambda, ESL_DMATRIX **opt_P);
67
68 /* 6. Implicit probabilistic basis, II: bg unknown. */
69 extern int esl_scorematrix_Probify(const ESL_SCOREMATRIX *S, ESL_DMATRIX **opt_P,
70 double **opt_fi, double **opt_fj, double *opt_lambda);
71
72 #endif /*eslSCOREMATRIX_INCLUDED*/
73
74
75
76