| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifndef eslSQIO_INCLUDED |
| 11 |
#define eslSQIO_INCLUDED |
| 12 |
#include <esl_config.h> |
| 13 |
|
| 14 |
#include <stdio.h> |
| 15 |
|
| 16 |
#include "easel.h" |
| 17 |
#include "esl_alphabet.h" |
| 18 |
#include "esl_msa.h" |
| 19 |
#include "esl_msafile.h" |
| 20 |
#include "esl_sq.h" |
| 21 |
#include "esl_sqio_ascii.h" |
| 22 |
#include "esl_sqio_ncbi.h" |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
typedef union { |
| 29 |
ESL_SQASCII_DATA ascii; |
| 30 |
ESL_SQNCBI_DATA ncbi; |
| 31 |
} ESL_SQDATA; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
typedef struct esl_sqio_s { |
| 38 |
char *filename; |
| 39 |
|
| 40 |
|
| 41 |
int do_digital; |
| 42 |
const ESL_ALPHABET *abc; |
| 43 |
|
| 44 |
|
| 45 |
int format; |
| 46 |
ESL_DSQ inmap[128]; |
| 47 |
|
| 48 |
|
| 49 |
int (*position) (struct esl_sqio_s *sqfp, off_t offset); |
| 50 |
void (*close) (struct esl_sqio_s *sqfp); |
| 51 |
|
| 52 |
int (*set_digital) (struct esl_sqio_s *sqfp, const ESL_ALPHABET *abc); |
| 53 |
int (*guess_alphabet) (struct esl_sqio_s *sqfp, int *ret_type); |
| 54 |
|
| 55 |
int (*read) (struct esl_sqio_s *sqfp, ESL_SQ *sq); |
| 56 |
int (*read_info) (struct esl_sqio_s *sqfp, ESL_SQ *sq); |
| 57 |
int (*read_seq) (struct esl_sqio_s *sqfp, ESL_SQ *sq); |
| 58 |
int (*read_window) (struct esl_sqio_s *sqfp, int C, int W, ESL_SQ *sq); |
| 59 |
int (*echo) (struct esl_sqio_s *sqfp, const ESL_SQ *sq, FILE *ofp); |
| 60 |
|
| 61 |
int (*read_block) (struct esl_sqio_s *sqfp, ESL_SQ_BLOCK *sqBlock, int max_residues, int max_sequences, int max_init_window, int long_target); |
| 62 |
|
| 63 |
int (*open_ssi) (struct esl_sqio_s *sqfp, const char *ssifile_hint); |
| 64 |
int (*pos_by_key) (struct esl_sqio_s *sqfp, const char *key); |
| 65 |
int (*pos_by_number) (struct esl_sqio_s *sqfp, int which); |
| 66 |
|
| 67 |
int (*fetch) (struct esl_sqio_s *sqfp, const char *key, ESL_SQ *sq); |
| 68 |
int (*fetch_info) (struct esl_sqio_s *sqfp, const char *key, ESL_SQ *sq); |
| 69 |
int (*fetch_subseq) (struct esl_sqio_s *sqfp, const char *source, int64_t start, int64_t end, ESL_SQ *sq); |
| 70 |
|
| 71 |
int (*is_rewindable) (const struct esl_sqio_s *sqfp); |
| 72 |
const char *(*get_error) (const struct esl_sqio_s *sqfp); |
| 73 |
|
| 74 |
ESL_SQDATA data; |
| 75 |
} ESL_SQFILE; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
typedef struct esl_sqcache_s { |
| 81 |
char *filename; |
| 82 |
int format; |
| 83 |
|
| 84 |
const ESL_ALPHABET *abc; |
| 85 |
|
| 86 |
uint32_t seq_count; |
| 87 |
uint64_t res_count; |
| 88 |
uint32_t max_seq; |
| 89 |
|
| 90 |
ESL_SQ *sq_list; |
| 91 |
|
| 92 |
void *residue_mem; |
| 93 |
void *header_mem; |
| 94 |
|
| 95 |
uint64_t res_size; |
| 96 |
uint64_t hdr_size; |
| 97 |
} ESL_SQCACHE; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
#define eslSQFILE_UNKNOWN 0 |
| 107 |
#define eslSQFILE_FASTA 1 // FASTA format |
| 108 |
#define eslSQFILE_EMBL 2 // EMBL DNA sequence |
| 109 |
#define eslSQFILE_GENBANK 3 // Genbank DNA sequence |
| 110 |
#define eslSQFILE_DDBJ 4 // DDBJ (currently identical to GenBank parser) |
| 111 |
#define eslSQFILE_UNIPROT 5 // UniProt (currently identical to EMBL parser) |
| 112 |
#define eslSQFILE_NCBI 6 // NCBI blast db, v4, single file |
| 113 |
#define eslSQFILE_DAEMON 7 // Farrar format, hmmpgmd queries: fasta + // terminator |
| 114 |
#define eslSQFILE_HMMPGMD 8 // Farrar hmmpgmd database format: fasta + # header |
| 115 |
#define eslSQFILE_FMINDEX 9 // Pressed FM-index format used in HMMER |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
#define eslREADBUFSIZE 4096 |
| 123 |
|
| 124 |
extern int esl_sqfile_Open(const char *seqfile, int fmt, const char *env, ESL_SQFILE **ret_sqfp); |
| 125 |
extern void esl_sqfile_Close(ESL_SQFILE *sqfp); |
| 126 |
|
| 127 |
extern int esl_sqfile_OpenDigital(const ESL_ALPHABET *abc, const char *filename, int format, const char *env, ESL_SQFILE **ret_sqfp); |
| 128 |
extern int esl_sqfile_SetDigital(ESL_SQFILE *sqfp, const ESL_ALPHABET *abc); |
| 129 |
extern int esl_sqfile_GuessAlphabet(ESL_SQFILE *sqfp, int *ret_type); |
| 130 |
|
| 131 |
extern int esl_sqio_Read (ESL_SQFILE *sqfp, ESL_SQ *sq); |
| 132 |
extern int esl_sqio_ReadInfo (ESL_SQFILE *sqfp, ESL_SQ *sq); |
| 133 |
extern int esl_sqio_ReadWindow (ESL_SQFILE *sqfp, int C, int W, ESL_SQ *sq); |
| 134 |
extern int esl_sqio_ReadSequence(ESL_SQFILE *sqfp, ESL_SQ *sq); |
| 135 |
extern int esl_sqio_ReadBlock (ESL_SQFILE *sqfp, ESL_SQ_BLOCK *sqBlock, int max_residues, int max_sequences, int max_init_window, int long_target); |
| 136 |
extern int esl_sqio_Parse (char *buffer, int size, ESL_SQ *s, int format); |
| 137 |
|
| 138 |
extern int esl_sqio_Write (FILE *fp, ESL_SQ *s, int format, int update); |
| 139 |
extern int esl_sqio_Echo (ESL_SQFILE *sqfp, const ESL_SQ *sq, FILE *ofp); |
| 140 |
|
| 141 |
const char *esl_sqfile_GetErrorBuf(const ESL_SQFILE *sqfp); |
| 142 |
extern int esl_sqfile_IsRewindable(const ESL_SQFILE *sqfp); |
| 143 |
extern int esl_sqio_IsAlignment(int fmt); |
| 144 |
extern int esl_sqio_EncodeFormat(char *fmtstring); |
| 145 |
extern char *esl_sqio_DecodeFormat(int fmt); |
| 146 |
extern int esl_sqfile_Position(ESL_SQFILE *sqfp, off_t offset); |
| 147 |
extern int esl_sqio_Ignore(ESL_SQFILE *sqfp, const char *ignoredchars); |
| 148 |
extern int esl_sqio_AcceptAs(ESL_SQFILE *sqfp, char *xchars, char readas); |
| 149 |
|
| 150 |
extern int esl_sqfile_OpenSSI (ESL_SQFILE *sqfp, const char *ssifile_hint); |
| 151 |
extern int esl_sqfile_PositionByKey (ESL_SQFILE *sqfp, const char *key); |
| 152 |
extern int esl_sqfile_PositionByNumber(ESL_SQFILE *sqfp, int which); |
| 153 |
|
| 154 |
extern int esl_sqio_Fetch (ESL_SQFILE *sqfp, const char *key, ESL_SQ *sq); |
| 155 |
extern int esl_sqio_FetchInfo (ESL_SQFILE *sqfp, const char *key, ESL_SQ *sq); |
| 156 |
extern int esl_sqio_FetchSubseq(ESL_SQFILE *sqfp, const char *source, int64_t start, int64_t end, ESL_SQ *sq); |
| 157 |
|
| 158 |
extern int esl_sqfile_Cache(const ESL_ALPHABET *abc, const char *seqfile, int fmt, const char *env, ESL_SQCACHE **ret_sqcache); |
| 159 |
extern void esl_sqfile_Free(ESL_SQCACHE *sqcache); |
| 160 |
|
| 161 |
#endif |
| 162 |
|