Debian Codegraph @

hmmer/easel/esl_gencode.h

raw symbols SCIP
1 /* Genetic code tables for translation, whether canonical or non.
2 */
3 #ifndef eslGENCODE_INCLUDED
4 #define eslGENCODE_INCLUDED
5 #include <esl_config.h>
6
7 #include "easel.h"
8 #include "esl_alphabet.h"
9 #include "esl_fileparser.h"
10 #include "esl_sq.h"
11 #include "esl_sqio.h"
12 #include "esl_getopts.h"
13
14 typedef struct {
15 int transl_table; // NCBI transl_table number, or -1. Only set for a standard NCBI table, with _Set(); _Read() from file doesn't set this.
16 char desc[128]; // Description, or "". ... ditto
17
18 ESL_DSQ basic[64]; // Basic code table. aacode[0..63; pos1^16 + pos2^4 + pos3] = residue code for amino acid, 0..19 or the Nonresidue code. No degeneracies.
19 int8_t is_initiator[64]; // TRUE for allowed initiator codons; FALSE if not
20
21 const ESL_ALPHABET *nt_abc; // A reference to nucleic alphabet that caller is maintaining elsewhere
22 const ESL_ALPHABET *aa_abc; // A reference to amino alphabet that caller is maintaining
23 } ESL_GENCODE;
24
25 /* struct esl_gencode_workstate_s
26 * keeps state in DNA sequence <sq>, allowing us to process a sequence
27 * either in a single gulp (using ReadSeq) or in overlapping windows
28 * (using ReadWindow).
29 *
30 * also contains one-time configuration information for translation
31 */
32 typedef struct esl_gencode_workstate_s {
33 /* stateful info (which may get updated with each new seq, strand, and/or window): */
34 ESL_SQ *psq[3]; // Growing ORFs in each frame
35 int8_t in_orf[3]; // TRUE|FALSE: TRUE if we're growing an ORF in this frame
36 int apos; // 1..L: current nucleotide we're on (starting a codon) in <sq>
37 int frame; // 0..2: which frame <apos> is in
38 int codon; // 0..63: Digitized codon for apos,apos+1,apos+2
39 int inval; // 0..3: how many apos increments we need to get past an ambiguous nucleotide
40 int is_revcomp; // TRUE|FALSE: TRUE if we're doing reverse complement strand
41 int orfcount; // >=0: How many ORFs we've processed so far
42
43 ESL_SQ_BLOCK *orf_block; // block of sequences to which to write ORFs
44
45 /* one-time configuration information (from options) */
46 int do_watson; // TRUE|FALSE: TRUE if we translate the top strand
47 int do_crick; // TRUE|FALSE: TRUE if we translate the reverse complement strand
48 int using_initiators; // TRUE|FALSE : TRUE if -m or -M, only valid initiators can start an ORF, and initiator codon always translates to Met
49 int minlen; // >=0: minimum orf length that process_orf will deal with
50 FILE *outfp; // default stdout: where to write output ORF data
51 int outformat; // default eslSQFILE_FASTA: sqfile format to write ORFs in
52 } ESL_GENCODE_WORKSTATE;
53
54 /* Create/Destroy workstate */
55 extern void esl_gencode_WorkstateDestroy(ESL_GENCODE_WORKSTATE *wrk);
56 extern ESL_GENCODE_WORKSTATE * esl_gencode_WorkstateCreate(ESL_GETOPTS *go, ESL_GENCODE *gcode);
57
58
59 /* the ESL_GENCODE genetic code object */
60 extern ESL_GENCODE *esl_gencode_Create(const ESL_ALPHABET *nt_abc, const ESL_ALPHABET *aa_abc);
61 extern void esl_gencode_Destroy (ESL_GENCODE *gcode);
62 extern int esl_gencode_Set (ESL_GENCODE *gcode, int ncbi_transl_table);
63 extern int esl_gencode_SetInitiatorAny (ESL_GENCODE *gcode);
64 extern int esl_gencode_SetInitiatorOnlyAUG(ESL_GENCODE *gcode);
65
66 /* reading and writing genetic codes in NCBI format */
67 extern int esl_gencode_Read(ESL_FILEPARSER *efp, const ESL_ALPHABET *nucleic_abc, const ESL_ALPHABET *amino_abc, ESL_GENCODE **ret_gcode);
68 extern int esl_gencode_Write(FILE *ofp, const ESL_GENCODE *gcode, int add_comment);
69
70 /* DNA->protein digital translation, allowing ambiguity chars */
71 extern int esl_gencode_GetTranslation(const ESL_GENCODE *gcode, ESL_DSQ *dsqp);
72 extern int esl_gencode_IsInitiator (const ESL_GENCODE *gcode, ESL_DSQ *dsqp);
73
74 /* Debugging/development utilities */
75 extern char *esl_gencode_DecodeDigicodon(const ESL_GENCODE *gcode, int digicodon, char *codon);
76 extern int esl_gencode_DumpAltCodeTable(FILE *ofp);
77 extern int esl_gencode_Compare(const ESL_GENCODE *gc1, const ESL_GENCODE *gc2, int metadata_too);
78
79 /* Functions for processing ORFs */
80 extern int esl_gencode_ProcessOrf(ESL_GENCODE_WORKSTATE *wrk, ESL_SQ *sq);
81 extern void esl_gencode_ProcessStart(ESL_GENCODE *gcode, ESL_GENCODE_WORKSTATE *wrk, ESL_SQ *sq);
82 extern int esl_gencode_ProcessPiece(ESL_GENCODE *gcode, ESL_GENCODE_WORKSTATE *wrk, ESL_SQ *sq);
83 extern int esl_gencode_ProcessEnd(ESL_GENCODE_WORKSTATE *wrk, ESL_SQ *sq);
84
85
86 #endif /*eslGENCODE_INCLUDED*/