-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbarracuda.h
218 lines (167 loc) · 5.6 KB
/
barracuda.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
* barracuda.h $Revision: 1.13 $
*
* Created on: 8 Jun 2012
* Author: yhbl2
*
* WBL 22 Feb 2016 bugfix for reads of more than 127bp
ensure alignment_meta_t.pos and init_info_t.start_pos do not overflow 7bits
* WBL 10 Feb 2016 increase MAX_SEQUENCE_LENGTH for cegx
* WBL 24 Jun 2015 copy_bwts_to_cuda_memory to use size_t through out
* WBL 28 Feb 2015 Remove deadcode for alternative sequences_array layout
* WBL 11 Feb 2015 For SVN, retain bwtkl_t
* WBL 16 Dec 2014 Add pack_length next_packed
* WBL 4 Dec 2014 surpress gcc warnings
*/
#ifndef BARRACUDA_H_
#define BARRACUDA_H_
#include <stdint.h>
#include "bwt.h"
#include "bwtaln.h"
// For multikernel design
#define MAX_PASS_LENGTH 32 //must be maximum of the next 2
#define MAX_SEEDING_PASS_LENGTH 32
#define MAX_REGULAR_PASS_LENGTH 19 // rule of thumb for best speed = (seq_len-MAX_SEEDING_PASS_LENGTH)/2
#define SPLIT_ENGAGE MAX_PASS_LENGTH //when splitting starts to happen
#define SEQUENCE_HOLDER_LENGTH MAX_PASS_LENGTH //set this to max(MAX_PASS_LENGTH, SPLIT_ENGAGE) - this minimises the memory usage of a kernel
#define MAX_SEED_LENGTH 50 // not tested beyond 50
#define SUFFIX_CLUMP_WIDTH 0 //0 to disable, 1 to enable (do not exceed 255)
#define MAX_SEQUENCE_LENGTH 150
#define MAX_ALN_LENGTH 100 //Max length for alignment kernel, cannot go beyond 225 (ptx error)
#define MAX_NO_OF_ALIGNMENTS 10
#define MAX_NO_PARTIAL_HITS 25 //must be the maximum of the next 2
#define MAX_NO_SEEDING_PARTIALS 25
#define MAX_NO_REGULAR_PARTIALS 10
//for barracuda_read_seqs. In both cases the return is in nominal bases. barracuda_read_seqs() assumes 2 bases per byte
static //removes warning: no previous prototype for and linker error multiple definition of `pack_length'
inline unsigned int pack_length(const int number_of_bases) {
return number_of_bases; //gave up on new layout for texture sequences_array
}
static
inline unsigned int next_packed(const int n_tot, const int n_seqs, const int first_length) {
return n_tot + 250; //gave up on new layout for texture sequences_array
}
#ifdef __cplusplus
extern "C" {
#endif
#define aln_score2(m,o,e,p) ((m)*(p).s_mm + (o)*(p).s_gapo + (e)*(p).s_gape)
////////////////////////////////////
// Begin BarraCUDA specific structs
////////////////////////////////////
typedef struct {
// The first 2 bytes is length, length = a[0]<<8|a[1]
// alphabet is pack using only 4 bits, so 1 char contain 2 alphabet.
unsigned char character[MAX_SEQUENCE_LENGTH/2];
} bwt_sequence_t;
typedef struct {
bwtint_t width[MAX_ALN_LENGTH];
char bid[MAX_ALN_LENGTH];
} bwt_sequence_width_t;
typedef struct {
bwtint_t lim_k;
bwtint_t lim_l;
unsigned char cur_n_mm, cur_n_gapo,cur_n_gape;
int best_diff;
int start_pos;
int score;
int sequence_id;
int best_cnt;
} init_info_t;
typedef struct {
unsigned char n_mm, n_gapo,n_gape;
bwtint_t k, l;
int score;
//int best_diff;
int best_cnt;
} barracuda_aln1_t;
//host-device transit structure
typedef struct
{
int no_of_alignments;
int best_score; //marks best score achieved for particular sequence in the forward run - not updated for backward atm
unsigned int sequence_id;
int best_cnt;
int pos;
char finished;
} alignment_meta_t;
typedef struct {
unsigned int widths[MAX_SEQUENCE_LENGTH+1];
unsigned char bids[MAX_SEQUENCE_LENGTH+1];
} widths_bids_t;
struct align_store_lst_t
{
barracuda_aln1_t val;
int sequence_id;
int start_pos;
char finished;
struct align_store_lst_t * next;
};
typedef struct align_store_lst_t align_store_lst;
//a linked list of linked lists containing sequences with matching (variable length) suffixes - used for clumping
struct suffix_bin_list_t {
struct suffix_seq_list_t * seq;
struct suffix_bin_list_t * next;
};
typedef struct suffix_bin_list_t suffix_bin_list;
struct suffix_seq_list_t {
unsigned int sequence_id;
struct suffix_seq_list_t * next;
};
typedef struct suffix_seq_list_t suffix_seq_list;
struct init_bin_list_t {
struct init_list_t * aln_list;
int score;
char processed;
struct init_bin_list_t * next;
};
typedef struct init_bin_list_t init_bin_list;
struct init_list_t {
init_info_t init;
struct init_list_t * next;
};
typedef struct init_list_t init_list;
typedef struct {
bwtint_t k;
bwtint_t l;
} bwtkl_t;
////////////////////////////////////
// End BarraCUDA specific structs
////////////////////////////////////
////////////////////////////////////
// Start BarraCUDA specific functions
////////////////////////////////////
int detect_cuda_device(void);
int bwa_deviceQuery(void);
void aln_quicksort2(bwt_aln1_t *aln, int m, int n);
double diff_in_seconds(struct timeval *finishtime, struct timeval * starttime);
//gap_opt_t *gap_init_bwaopt(gap_opt_t * opt);
//gap_opt_t *gap_init_opt();
size_t copy_bwts_to_cuda_memory(
const char * prefix,
uint32_t ** bwt,
const size_t mem_available,
bwtint_t* seq_len);
void barracuda_bwa_aln_core(const char *prefix,
const char *fn_fa,
gap_opt_t *opt);
int bwa_read_seq_one_half_byte (
bwa_seqio_t *bs,
unsigned char * half_byte_array,
unsigned int start_index,
unsigned short * length,
unsigned long long * clump_array,
unsigned char clump_len,
unsigned int sequence_id);
int bwa_read_seq_one (bwa_seqio_t *bs,
unsigned char * byte_array,
unsigned short * length);
void cuda_alignment_core(const char *prefix,
bwa_seqio_t *ks,
gap_opt_t *opt);
///////////////////////////////////////////////////////////////
// End CUDA ALN
///////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif /* BARRACUDA_H_ */