Debian Codegraph @

bwa-apache2/ksw.h

raw
1 #ifndef __AC_KSW_H
2 #define __AC_KSW_H
3
4 #include <stdint.h>
5
6 #define KSW_XBYTE 0x10000
7 #define KSW_XSTOP 0x20000
8 #define KSW_XSUBO 0x40000
9 #define KSW_XSTART 0x80000
10
11 struct _kswq_t;
12 typedef struct _kswq_t kswq_t;
13
14 typedef struct {
15 int score; // best score
16 int te, qe; // target end and query end
17 int score2, te2; // second best score and ending position on the target
18 int tb, qb; // target start and query start
19 } kswr_t;
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /**
26 * Aligning two sequences
27 *
28 * @param qlen length of the query sequence (typically <tlen)
29 * @param query query sequence with 0 <= query[i] < m
30 * @param tlen length of the target sequence
31 * @param target target sequence
32 * @param m number of residue types
33 * @param mat m*m scoring matrix in one-dimension array
34 * @param gapo gap open penalty; a gap of length l cost "-(gapo+l*gape)"
35 * @param gape gap extension penalty
36 * @param xtra extra information (see below)
37 * @param qry query profile (see below)
38 *
39 * @return alignment information in a struct; unset values to -1
40 *
41 * When xtra==0, ksw_align() uses a signed two-byte integer to store a
42 * score and only finds the best score and the end positions. The 2nd best
43 * score or the start positions are not attempted. The default behavior can
44 * be tuned by setting KSW_X* flags:
45 *
46 * KSW_XBYTE: use an unsigned byte to store a score. If overflow occurs,
47 * kswr_t::score will be set to 255
48 *
49 * KSW_XSUBO: track the 2nd best score and the ending position on the
50 * target if the 2nd best is higher than (xtra&0xffff)
51 *
52 * KSW_XSTOP: stop if the maximum score is above (xtra&0xffff)
53 *
54 * KSW_XSTART: find the start positions
55 *
56 * When *qry==NULL, ksw_align() will compute and allocate the query profile
57 * and when the function returns, *qry will point to the profile, which can
58 * be deallocated simply by free(). If one query is aligned against multiple
59 * target sequences, *qry should be set to NULL during the first call and
60 * freed after the last call. Note that qry can equal 0. In this case, the
61 * query profile will be deallocated in ksw_align().
62 */
63 kswr_t ksw_align(int qlen, uint8_t *query, int tlen, uint8_t *target, int m, const int8_t *mat, int gapo, int gape, int xtra, kswq_t **qry);
64 kswr_t ksw_align2(int qlen, uint8_t *query, int tlen, uint8_t *target, int m, const int8_t *mat, int o_del, int e_del, int o_ins, int e_ins, int xtra, kswq_t **qry);
65
66 /**
67 * Banded global alignment
68 *
69 * @param qlen query length
70 * @param query query sequence with 0 <= query[i] < m
71 * @param tlen target length
72 * @param target target sequence with 0 <= target[i] < m
73 * @param m number of residue types
74 * @param mat m*m scoring mattrix in one-dimension array
75 * @param gapo gap open penalty; a gap of length l cost "-(gapo+l*gape)"
76 * @param gape gap extension penalty
77 * @param w band width
78 * @param n_cigar (out) number of CIGAR elements
79 * @param cigar (out) BAM-encoded CIGAR; caller need to deallocate with free()
80 *
81 * @return score of the alignment
82 */
83 int ksw_global(int qlen, const uint8_t *query, int tlen, const uint8_t *target, int m, const int8_t *mat, int gapo, int gape, int w, int *n_cigar, uint32_t **cigar);
84 int ksw_global2(int qlen, const uint8_t *query, int tlen, const uint8_t *target, int m, const int8_t *mat, int o_del, int e_del, int o_ins, int e_ins, int w, int *n_cigar, uint32_t **cigar);
85
86 /**
87 * Extend alignment
88 *
89 * The routine aligns $query and $target, assuming their upstream sequences,
90 * which are not provided, have been aligned with score $h0. In return,
91 * region [0,*qle) on the query and [0,*tle) on the target sequences are
92 * aligned together. If *gscore>=0, *gscore keeps the best score such that
93 * the entire query sequence is aligned; *gtle keeps the position on the
94 * target where *gscore is achieved. Returning *gscore and *gtle helps the
95 * caller to decide whether an end-to-end hit or a partial hit is preferred.
96 *
97 * The first 9 parameters are identical to those in ksw_global()
98 *
99 * @param h0 alignment score of upstream sequences
100 * @param _qle (out) length of the query in the alignment
101 * @param _tle (out) length of the target in the alignment
102 * @param _gtle (out) length of the target if query is fully aligned
103 * @param _gscore (out) score of the best end-to-end alignment; negative if not found
104 *
105 * @return best semi-local alignment score
106 */
107 int ksw_extend(int qlen, const uint8_t *query, int tlen, const uint8_t *target, int m, const int8_t *mat, int gapo, int gape, int w, int end_bonus, int zdrop, int h0, int *qle, int *tle, int *gtle, int *gscore, int *max_off);
108 int ksw_extend2(int qlen, const uint8_t *query, int tlen, const uint8_t *target, int m, const int8_t *mat, int o_del, int e_del, int o_ins, int e_ins, int w, int end_bonus, int zdrop, int h0, int *qle, int *tle, int *gtle, int *gscore, int *max_off);
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif