Permalink
Browse files

r283: prepare for fixing cross-ref aln

  • Loading branch information...
1 parent 77b5b58 commit 61dd3bf13a1d571f938ac2698999c5f34445f11f @lh3 committed Feb 26, 2013
Showing with 23 additions and 13 deletions.
  1. +17 −12 bntseq.c
  2. +1 −0 bntseq.h
  3. +4 −0 bwa.c
  4. +1 −1 main.c
View
@@ -288,21 +288,26 @@ int bwa_fa2pac(int argc, char *argv[])
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 left, mid, right, nn;
- if (ref_id) {
- 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;
- }
+ if (ref_id) *ref_id = bns_pos2rid(bns, pos_f);
left = 0; right = bns->n_holes; nn = 0;
while (left < right) {
mid = (left + right) >> 1;
View
@@ -72,6 +72,7 @@ extern "C" {
bntseq_t *bns_restore_core(const char *ann_filename, const char* amb_filename, const char* pac_filename);
void bns_destroy(bntseq_t *bns);
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);
uint8_t *bns_get_seq(int64_t l_pac, const uint8_t *pac, int64_t beg, int64_t end, int64_t *len);
View
4 bwa.c
@@ -64,6 +64,10 @@ bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_)
return seqs;
}
+/*****************
+ * CIGAR related *
+ *****************/
+
// 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)
{
View
2 main.c
@@ -4,7 +4,7 @@
#include "utils.h"
#ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.6.2-r282-beta"
+#define PACKAGE_VERSION "0.6.2-r283-beta"
#endif
static int usage()

0 comments on commit 61dd3bf

Please sign in to comment.