Debian Codegraph @

easel/esl_sqio_ascii.h

raw symbols SCIP
1 /* Unaligned ascii sequence file i/o.
2 */
3 #ifndef eslSQIO_ASCII_INCLUDED
4 #define eslSQIO_ASCII_INCLUDED
5 #include <esl_config.h>
6
7 #include <stdio.h>
8 #ifdef HAVE_SYS_TYPES_H
9 #include <sys/types.h>
10 #endif
11
12 #include "esl_msa.h"
13 #include "esl_msafile.h"
14 #include "esl_sq.h"
15 #include "esl_sqio.h"
16
17 /* set the max residue count to 1 meg when reading a block */
18 #define MAX_RESIDUE_COUNT (1024 * 1024)
19
20 /* forward declaration */
21 struct esl_sqio_s;
22
23 /* ESL_SQASCII:
24 * An open sequence file for reading.
25 */
26 typedef struct esl_sqascii_s {
27
28 FILE *fp; /* Open file ptr */
29 char errbuf[eslERRBUFSIZE];/* parse error mesg. Size must match msa.h */
30
31 int do_gzip; /* TRUE if we're reading from gzip -dc pipe */
32 int do_stdin; /* TRUE if we're reading from stdin */
33 int do_buffer; /* TRUE if we're reading from a buffer */
34
35 /* all input first gets buffered in memory; this gives us enough
36 * recall to use Guess*() functions even in nonrewindable streams
37 */
38 char *mem; /* buffered input */
39 int allocm; /* <mem> size, multiples of eslREADBUFSIZE */
40 int mn; /* number of chars in <mem> (up to allocm) */
41 int mpos; /* pos of next <buf> to load from <mem> */
42 off_t moff; /* disk offset to start of <mem> */
43 int is_recording; /* TRUE if we need to keep buffering more */
44
45 /* input is either character-based [fread()] or line-based (esl_fgets())*/
46 char *buf; /* buffer for fread() or fgets() input */
47 off_t boff; /* disk offset to start of buffer */
48 int balloc; /* allocated size of buf */
49 int nc; /* #chars in buf (usually full, less at EOF)*/
50 int bpos; /* current position in the buffer (0..nc-1) */
51 int64_t L; /* #residues seen so far in current seq */
52 int64_t linenumber; /* What line of the file (1..N; -1=unknown)*/
53 off_t bookmark_offset; /* bookmark fwd position before reversing...*/
54 int64_t bookmark_linenum; /* in both linenumber and disk offset */
55
56 /* Format-specific configuration */
57 int is_linebased; /* TRUE for fgets() parsers; FALSE for fread() */
58 int eof_is_ok; /* TRUE if record can end on EOF */
59 int (*parse_header)(struct esl_sqio_s *, ESL_SQ *sq);
60 int (*skip_header) (struct esl_sqio_s *, ESL_SQ *sq);
61 int (*parse_end) (struct esl_sqio_s *, ESL_SQ *sq);
62
63 /* MSA files can be read as sequential seq files. */
64 ESL_MSAFILE *afp; /* open ESL_MSAFILE for reading */
65 ESL_MSA *msa; /* preloaded alignment to draw seqs from */
66 int idx; /* index of next seq to return, 0..nseq-1 */
67
68 /* SSI indexes allow fast random access of records in a seq file */
69 char *ssifile; /* path to expected SSI index file */
70 int rpl; /* residues per line in file; -1=unset 0=inval*/
71 int bpl; /* bytes per line in file; -1=unset, 0=inval */
72 int currpl; /* residues on current line (-1=unknown) */
73 int curbpl; /* bytes on current line (-1=unknown) */
74 int prvrpl; /* residues on previous line */
75 int prvbpl; /* bytes on previous line */
76 ESL_SSI *ssi; /* open ESL_SSI index, or NULL if none */
77 } ESL_SQASCII_DATA;
78
79
80 extern int esl_sqascii_Open(char *seqfile, int format, struct esl_sqio_s *sqfp);
81 extern int esl_sqascii_WriteFasta(FILE *fp, ESL_SQ *s, int update);
82 extern int esl_sqascii_Parse(char *buf, int size, ESL_SQ *s, int format);
83
84 #endif /*eslSQIO_ASCII_INCLUDED*/