Skip to content

Commit

Permalink
r283: prepare for fixing cross-ref aln
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Feb 26, 2013
1 parent 77b5b58 commit 61dd3bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
29 changes: 17 additions & 12 deletions bntseq.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -288,21 +288,26 @@ int bwa_fa2pac(int argc, char *argv[])
return 0; return 0;
} }


int bns_pos2rid(const bntseq_t *bns, int64_t pos_f)
{
int left, mid, right;
if (pos_f >= bns->l_pac) return -1;
left = 0; mid = 0; right = bns->n_seqs;
while (left < right) { // binary search
mid = (left + right) >> 1;
if (pos_f >= bns->anns[mid].offset) {
if (mid == bns->n_seqs - 1) break;
if (pos_f < bns->anns[mid+1].offset) break; // bracketed
left = mid + 1;
} else right = mid;
}
return mid;
}

int bns_cnt_ambi(const bntseq_t *bns, int64_t pos_f, int len, int *ref_id) int bns_cnt_ambi(const bntseq_t *bns, int64_t pos_f, int len, int *ref_id)
{ {
int left, mid, right, nn; int left, mid, right, nn;
if (ref_id) { if (ref_id) *ref_id = bns_pos2rid(bns, pos_f);
left = 0; mid = 0; right = bns->n_seqs;
while (left < right) {
mid = (left + right) >> 1;
if (pos_f >= bns->anns[mid].offset) {
if (mid == bns->n_seqs - 1) break;
if (pos_f < bns->anns[mid+1].offset) break; // bracketed
left = mid + 1;
} else right = mid;
}
*ref_id = mid;
}
left = 0; right = bns->n_holes; nn = 0; left = 0; right = bns->n_holes; nn = 0;
while (left < right) { while (left < right) {
mid = (left + right) >> 1; mid = (left + right) >> 1;
Expand Down
1 change: 1 addition & 0 deletions bntseq.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern "C" {
bntseq_t *bns_restore_core(const char *ann_filename, const char* amb_filename, const char* pac_filename); bntseq_t *bns_restore_core(const char *ann_filename, const char* amb_filename, const char* pac_filename);
void bns_destroy(bntseq_t *bns); void bns_destroy(bntseq_t *bns);
int64_t bns_fasta2bntseq(gzFile fp_fa, const char *prefix, int for_only); int64_t bns_fasta2bntseq(gzFile fp_fa, const char *prefix, int for_only);
int bns_pos2rid(const bntseq_t *bns, int64_t pos_f);
int bns_cnt_ambi(const bntseq_t *bns, int64_t pos_f, int len, int *ref_id); int bns_cnt_ambi(const bntseq_t *bns, int64_t pos_f, int len, int *ref_id);
uint8_t *bns_get_seq(int64_t l_pac, const uint8_t *pac, int64_t beg, int64_t end, int64_t *len); uint8_t *bns_get_seq(int64_t l_pac, const uint8_t *pac, int64_t beg, int64_t end, int64_t *len);


Expand Down
4 changes: 4 additions & 0 deletions bwa.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_)
return seqs; return seqs;
} }


/*****************
* CIGAR related *
*****************/

// Generate CIGAR when the alignment end points are known // Generate CIGAR when the alignment end points are known
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) 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)
{ {
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "utils.h" #include "utils.h"


#ifndef PACKAGE_VERSION #ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "0.6.2-r282-beta" #define PACKAGE_VERSION "0.6.2-r283-beta"
#endif #endif


static int usage() static int usage()
Expand Down

0 comments on commit 61dd3bf

Please sign in to comment.