From ee59a131094ec3d0576bd72ed6421fc15b655397 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sun, 24 Feb 2013 12:17:29 -0500 Subject: [PATCH] simplified bwamem.h Hide mem_seed_t and mem_chain_t. Don't expose unnecessary routines. --- bwamem.c | 17 +++++++++++++---- bwamem.h | 44 ++++++++------------------------------------ bwamem_pair.c | 9 +++++++++ 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/bwamem.c b/bwamem.c index 7daa5d2..b6741d2 100644 --- a/bwamem.c +++ b/bwamem.c @@ -155,6 +155,19 @@ const bwtintv_v *smem_next(smem_i *itr, int split_len, int split_width) * Chaining while finding SMEMs * ********************************/ +typedef struct { + int64_t rbeg; + int32_t qbeg, len; +} mem_seed_t; + +typedef struct { + int n, m; + int64_t pos; + mem_seed_t *seeds; +} mem_chain_t; + +typedef struct { size_t n, m; mem_chain_t *a; } mem_chain_v; + #include "kbtree.h" #define chain_cmp(a, b) (((b).pos < (a).pos) - ((a).pos < (b).pos)) @@ -398,10 +411,6 @@ void mem_mark_primary_se(const mem_opt_t *opt, int n, mem_alnreg_t *a) // IMPORT free(z.a); } -/************************ - * Pick paired-end hits * - ************************/ - /**************************************** * Construct the alignment from a chain * ****************************************/ diff --git a/bwamem.h b/bwamem.h index ce27c6e..27a3dc1 100644 --- a/bwamem.h +++ b/bwamem.h @@ -11,11 +11,6 @@ struct __smem_i; typedef struct __smem_i smem_i; -typedef struct { - int64_t rbeg; - int32_t qbeg, len; -} mem_seed_t; - #define MEM_F_HARDCLIP 0x1 #define MEM_F_PE 0x2 #define MEM_F_NOPAIRING 0x4 @@ -35,12 +30,6 @@ typedef struct { int8_t mat[25]; // scoring matrix; mat[0] == 0 if unset } mem_opt_t; -typedef struct { - int n, m; - int64_t pos; - mem_seed_t *seeds; -} mem_chain_t; - typedef struct { int64_t rb, re; int score, qb, qe, seedcov, sub, csub; // sub: suboptimal score; csub: suboptimal inside the chain @@ -60,43 +49,26 @@ typedef struct { int score, sub; } bwahit_t; -typedef struct { size_t n, m; mem_chain_t *a; } mem_chain_v; typedef struct { size_t n, m; mem_alnreg_t *a; } mem_alnreg_v; -extern int mem_verbose; - #ifdef __cplusplus extern "C" { #endif -smem_i *smem_itr_init(const bwt_t *bwt); -void smem_itr_destroy(smem_i *itr); -void smem_set_query(smem_i *itr, int len, const uint8_t *query); -const bwtintv_v *smem_next(smem_i *itr, int split_len, int split_width); + smem_i *smem_itr_init(const bwt_t *bwt); + void smem_itr_destroy(smem_i *itr); + void smem_set_query(smem_i *itr, int len, const uint8_t *query); + const bwtintv_v *smem_next(smem_i *itr, int split_len, int split_width); -mem_opt_t *mem_opt_init(void); -void mem_fill_scmat(int a, int b, int8_t mat[25]); + mem_opt_t *mem_opt_init(void); + void mem_fill_scmat(int a, int b, int8_t mat[25]); -mem_chain_v mem_chain(const mem_opt_t *opt, const bwt_t *bwt, int len, const uint8_t *seq); -int mem_chain_flt(const mem_opt_t *opt, int n_chn, mem_chain_t *chains); -void mem_chain2aln(const mem_opt_t *opt, int64_t l_pac, const uint8_t *pac, int l_query, const uint8_t *query, const mem_chain_t *c, mem_alnreg_v *a); -uint32_t *mem_gen_cigar(const mem_opt_t *opt, 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 mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int n, bseq1_t *seqs); -int mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int n, bseq1_t *seqs); - -void mem_pestat(const mem_opt_t *opt, int64_t l_pac, int n, const mem_alnreg_v *regs, mem_pestat_t pes[4]); + void mem_pestat(const mem_opt_t *opt, int64_t l_pac, int n, const mem_alnreg_v *regs, mem_pestat_t pes[4]); #ifdef __cplusplus } #endif -static inline int mem_infer_dir(int64_t l_pac, int64_t b1, int64_t b2, int64_t *dist) -{ - int64_t p2; - int r1 = (b1 >= l_pac), r2 = (b2 >= l_pac); - p2 = r1 == r2? b2 : (l_pac<<1) - 1 - b2; // p2 is the coordinate of read 2 on the read 1 strand - *dist = p2 > b1? p2 - b1 : b1 - p2; - return (r1 == r2? 0 : 1) ^ (p2 > b1? 0 : 3); -} - #endif diff --git a/bwamem_pair.c b/bwamem_pair.c index 57a128a..51f51c9 100644 --- a/bwamem_pair.c +++ b/bwamem_pair.c @@ -15,6 +15,15 @@ #define MAPPING_BOUND 3.0 #define MAX_STDDEV 4.0 +static inline int mem_infer_dir(int64_t l_pac, int64_t b1, int64_t b2, int64_t *dist) +{ + int64_t p2; + int r1 = (b1 >= l_pac), r2 = (b2 >= l_pac); + p2 = r1 == r2? b2 : (l_pac<<1) - 1 - b2; // p2 is the coordinate of read 2 on the read 1 strand + *dist = p2 > b1? p2 - b1 : b1 - p2; + return (r1 == r2? 0 : 1) ^ (p2 > b1? 0 : 3); +} + static int cal_sub(const mem_opt_t *opt, mem_alnreg_v *r) { int j;