| 1 |
/* The MIT License |
| 2 |
|
| 3 |
Copyright (c) 2018- Dana-Farber Cancer Institute |
| 4 |
2009-2018 Broad Institute, Inc. |
| 5 |
2008-2009 Genome Research Ltd. (GRL) |
| 6 |
|
| 7 |
Permission is hereby granted, free of charge, to any person obtaining |
| 8 |
a copy of this software and associated documentation files (the |
| 9 |
"Software"), to deal in the Software without restriction, including |
| 10 |
without limitation the rights to use, copy, modify, merge, publish, |
| 11 |
distribute, sublicense, and/or sell copies of the Software, and to |
| 12 |
permit persons to whom the Software is furnished to do so, subject to |
| 13 |
the following conditions: |
| 14 |
|
| 15 |
The above copyright notice and this permission notice shall be |
| 16 |
included in all copies or substantial portions of the Software. |
| 17 |
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 |
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 |
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 |
SOFTWARE. |
| 26 |
*/ |
| 27 |
#ifndef BWA_H_ |
| 28 |
#define BWA_H_ |
| 29 |
|
| 30 |
#include <stdint.h> |
| 31 |
#include "bntseq.h" |
| 32 |
#include "bwt.h" |
| 33 |
|
| 34 |
#define BWA_IDX_BWT 0x1 |
| 35 |
#define BWA_IDX_BNS 0x2 |
| 36 |
#define BWA_IDX_PAC 0x4 |
| 37 |
#define BWA_IDX_ALL 0x7 |
| 38 |
|
| 39 |
#define BWA_CTL_SIZE 0x10000 |
| 40 |
|
| 41 |
#define BWTALGO_AUTO 0 |
| 42 |
#define BWTALGO_RB2 1 |
| 43 |
#define BWTALGO_BWTSW 2 |
| 44 |
#define BWTALGO_IS 3 |
| 45 |
|
| 46 |
#define BWA_DBG_QNAME 0x1 |
| 47 |
|
| 48 |
typedef struct { |
| 49 |
bwt_t *bwt; // FM-index |
| 50 |
bntseq_t *bns; // information on the reference sequences |
| 51 |
uint8_t *pac; // the actual 2-bit encoded reference sequences with 'N' converted to a random base |
| 52 |
|
| 53 |
int is_shm; |
| 54 |
int64_t l_mem; |
| 55 |
uint8_t *mem; |
| 56 |
} bwaidx_t; |
| 57 |
|
| 58 |
typedef struct { |
| 59 |
int l_seq, id; |
| 60 |
char *name, *comment, *seq, *qual, *sam; |
| 61 |
} bseq1_t; |
| 62 |
|
| 63 |
extern int bwa_verbose, bwa_dbg; |
| 64 |
extern char bwa_rg_id[256]; |
| 65 |
|
| 66 |
#ifdef __cplusplus |
| 67 |
extern "C" { |
| 68 |
#endif |
| 69 |
|
| 70 |
bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_); |
| 71 |
void bseq_classify(int n, bseq1_t *seqs, int m[2], bseq1_t *sep[2]); |
| 72 |
|
| 73 |
void bwa_fill_scmat(int a, int b, int8_t mat[25]); |
| 74 |
uint32_t *bwa_gen_cigar(const int8_t mat[25], int q, int r, int w_, int64_t l_pac, const uint8_t *pac, int l_query, uint8_t *query, int64_t rb, int64_t re, int *score, int *n_cigar, int *NM); |
| 75 |
uint32_t *bwa_gen_cigar2(const int8_t mat[25], int o_del, int e_del, int o_ins, int e_ins, int w_, int64_t l_pac, const uint8_t *pac, int l_query, uint8_t *query, int64_t rb, int64_t re, int *score, int *n_cigar, int *NM); |
| 76 |
|
| 77 |
int bwa_idx_build(const char *fa, const char *prefix, int algo_type, int block_size); |
| 78 |
|
| 79 |
char *bwa_idx_infer_prefix(const char *hint); |
| 80 |
bwt_t *bwa_idx_load_bwt(const char *hint); |
| 81 |
|
| 82 |
bwaidx_t *bwa_idx_load_from_shm(const char *hint); |
| 83 |
bwaidx_t *bwa_idx_load_from_disk(const char *hint, int which); |
| 84 |
bwaidx_t *bwa_idx_load(const char *hint, int which); |
| 85 |
void bwa_idx_destroy(bwaidx_t *idx); |
| 86 |
int bwa_idx2mem(bwaidx_t *idx); |
| 87 |
int bwa_mem2idx(int64_t l_mem, uint8_t *mem, bwaidx_t *idx); |
| 88 |
|
| 89 |
void bwa_print_sam_hdr(const bntseq_t *bns, const char *hdr_line); |
| 90 |
char *bwa_set_rg(const char *s); |
| 91 |
char *bwa_insert_header(const char *s, char *hdr); |
| 92 |
|
| 93 |
#ifdef __cplusplus |
| 94 |
} |
| 95 |
#endif |
| 96 |
|
| 97 |
#endif |