Debian Codegraph @

hmmer/src/hmmpgmd.h

raw symbols SCIP
1 #ifndef P7_HMMPGMD_INCLUDED
2 #define P7_HMMPGMD_INCLUDED
3
4
5 typedef struct {
6 uint32_t status; /* error status */
7 uint64_t msg_size; /* size of the next packet. if status not */
8 /* zero, the length is for the error string */
9 /* otherwise it is the length of the data */
10 /* to follow. */
11 } HMMD_SEARCH_STATUS;
12
13 typedef struct {
14 double elapsed; /* elapsed time, seconds */
15 double user; /* CPU time, seconds */
16 double sys; /* system time, seconds */
17
18 double Z; /* eff # targs searched (per-target E-val) */
19 double domZ; /* eff # signific targs (per-domain E-val) */
20 enum p7_zsetby_e Z_setby; /* how Z was set */
21 enum p7_zsetby_e domZ_setby; /* how domZ was set */
22
23 uint64_t nmodels; /* # of HMMs searched */
24 uint64_t nseqs; /* # of sequences searched */
25 uint64_t n_past_msv; /* # comparisons that pass MSVFilter() */
26 uint64_t n_past_bias; /* # comparisons that pass bias filter */
27 uint64_t n_past_vit; /* # comparisons that pass ViterbiFilter() */
28 uint64_t n_past_fwd; /* # comparisons that pass ForwardFilter() */
29
30 uint64_t nhits; /* number of hits in list now */
31 uint64_t nreported; /* number of hits that are reportable */
32 uint64_t nincluded; /* number of hits that are includable */
33 uint64_t *hit_offsets; /* either NULL or an array of nhits values that define the offset from the start of this
34 search's array of serialized hits to each hit in the array. I.e. hit_offsets[0] will always be 0
35 if the array exists, hit_offsets[1] will be the number of bytes between the start of the
36 array of serialized hits to the start of the second hit, and so on */
37 } HMMD_SEARCH_STATS;
38
39 #define HMMD_SEQUENCE 101
40 #define HMMD_HMM 102
41
42 /* commands between master and worker */
43 #define HMMD_CMD_SEARCH 10001
44 #define HMMD_CMD_SCAN 10002
45 #define HMMD_CMD_INIT 10003
46 #define HMMD_CMD_SHUTDOWN 10004
47
48 #define MAX_INIT_DESC 32
49
50 /* HMMD_CMD_SEARCH or HMMD_CMD_SCAN */
51 typedef struct {
52 uint32_t db_inx; /* database index to search */
53 uint32_t db_type; /* database type to search */
54 uint32_t inx; /* index to begin search */
55 uint32_t cnt; /* number of sequences to search */
56 uint32_t query_type; /* sequence / hmm */
57 uint32_t query_length; /* length of the query data */
58 uint32_t opts_length; /* length of the options string */
59 char data[]; /* search data */
60 } HMMD_SEARCH_CMD;
61
62 /* HMMD_CMD_INIT */
63 typedef struct {
64 char sid[MAX_INIT_DESC]; /* unique id for sequence database */
65 char hid[MAX_INIT_DESC]; /* unique id for hmm database */
66 uint32_t seqdb_off; /* offset to seq database name, 0 if none */
67 uint32_t hmmdb_off; /* offset to hmm database name, 0 if none */
68 uint32_t db_cnt; /* total number of sequence databases */
69 uint32_t seq_cnt; /* sequences in database */
70 uint32_t hmm_cnt; /* total number hmm databases */
71 uint32_t model_cnt; /* models in hmm database */
72 char data[]; /* string data */
73 } HMMD_INIT_CMD;
74
75 /* HMMD_CMD_RESET */
76 typedef struct {
77 char pad;
78 char ip_addr[]; /* ip address */
79 } HMMD_INIT_RESET;
80
81 /* HMMD_HEADER */
82 typedef struct {
83 uint32_t length; /* message length */
84 uint32_t command; /* message type */
85 uint32_t status; /* 0 - success */
86 } HMMD_HEADER;
87
88 typedef struct {
89 HMMD_HEADER hdr; /* length and type of message */
90 union {
91 HMMD_INIT_CMD init;
92 HMMD_SEARCH_CMD srch;
93 HMMD_INIT_RESET reset;
94 };
95 } HMMD_COMMAND;
96
97 #define HMMD_SEARCH_STATUS_SERIAL_SIZE sizeof(uint32_t) + sizeof(uint64_t)
98 #define HMMD_SEARCH_STATS_SERIAL_BASE (5 * sizeof(double)) + (9 * sizeof(uint64_t)) + 2
99 // The 2 is two enums at one byte/enum as we serialize them
100 #define MSG_SIZE(x) (sizeof(HMMD_HEADER) + ((HMMD_HEADER *)(x))->length)
101
102 size_t writen(int fd, const void *vptr, size_t n);
103 size_t readn(int fd, void *vptr, size_t n);
104
105 typedef struct queue_data_s {
106 uint32_t cmd_type; /* type of command to perform */
107 uint32_t query_type; /* type of the query */
108 P7_HMM *hmm; /* query HMM */
109 ESL_SQ *seq; /* query sequence */
110 ESL_ALPHABET *abc; /* digital alphabet */
111 ESL_GETOPTS *opts; /* search specific options */
112 HMMD_COMMAND *cmd; /* workers search command */
113
114 int sock; /* socket descriptor of client */
115 char ip_addr[64];
116
117 int dbx; /* database index to search */
118 int inx; /* sequence index to start search */
119 int cnt; /* number of sequences to search */
120
121 } QUEUE_DATA;
122
123
124 typedef struct {
125 int N; /* number of ranges */
126 uint32_t *starts; /* 0..N-1 start positions */
127 uint32_t *ends; /* 0..N-1 start positions */
128 } RANGE_LIST;
129
130 extern void free_QueueData(QUEUE_DATA *data);
131 extern int hmmpgmd_IsWithinRanges (int64_t sq_idx, RANGE_LIST *list );
132 extern int hmmpgmd_GetRanges (RANGE_LIST *list, char *rangestr);
133
134 extern int process_searchopts(int fd, char *cmdstr, ESL_GETOPTS **ret_opts);
135
136 extern void worker_process(ESL_GETOPTS *go);
137 extern void master_process(ESL_GETOPTS *go);
138
139 extern int p7_hmmd_search_stats_Serialize(const HMMD_SEARCH_STATS *obj, uint8_t **buf, uint32_t *n, uint32_t *nalloc);
140 extern int p7_hmmd_search_stats_Deserialize(const uint8_t *buf, uint32_t *pos, HMMD_SEARCH_STATS *ret_obj);
141
142 #define LOG_FATAL_MSG(str, err) { \
143 p7_syslog(LOG_CRIT,"[%s:%d] - %s error %d - %s\n", __FILE__, __LINE__, str, err, strerror(err)); \
144 exit(0); \
145 }
146
147 /* hmmd_search_status.c */
148 extern int hmmd_search_status_Serialize(const HMMD_SEARCH_STATUS *obj, uint8_t **buf, uint32_t *n, uint32_t *nalloc);
149 extern int hmmd_search_status_Deserialize(const uint8_t *buf, uint32_t *n, HMMD_SEARCH_STATUS *ret_obj);
150 extern int hmmd_search_status_TestSample(ESL_RAND64 *rng, HMMD_SEARCH_STATUS **ret_obj);
151 extern int hmmd_search_status_Compare(HMMD_SEARCH_STATUS *first, HMMD_SEARCH_STATUS *second);
152 #endif /*P7_HMMPGMD_INCLUDED*/