@@ -21,6 +21,17 @@ static void ksw_gen_simple_mat(int m, int8_t *mat, int8_t a, int8_t b, int8_t sc
2121 mat [(m - 1 ) * m + j ] = sc_ambi ;
2222}
2323
24+ static void ksw_gen_ts_mat (int m , int8_t * mat , int8_t a , int8_t b , int8_t transition , int8_t sc_ambi )
25+ {
26+ assert (m == 5 );
27+ ksw_gen_simple_mat (m ,mat ,a ,b ,sc_ambi );
28+ transition = transition > 0 ? - transition : transition ;
29+ mat [0 * m + 2 ]= transition ; // A->G
30+ mat [1 * m + 3 ]= transition ; // C->T
31+ mat [2 * m + 0 ]= transition ; // G->A
32+ mat [3 * m + 1 ]= transition ; // T->C
33+ }
34+
2435static inline void mm_seq_rev (uint32_t len , uint8_t * seq )
2536{
2637 uint32_t i ;
@@ -323,6 +334,7 @@ static void mm_align_pair(void *km, const mm_mapopt_t *opt, int qlen, const uint
323334 for (i = 0 ; i < qlen ; ++ i ) fputc ("ACGTN" [qseq [i ]], stderr );
324335 fputc ('\n' , stderr );
325336 }
337+ if (opt -> b != opt -> transition ) flag |= KSW_EZ_GENERIC_SC ;
326338 if (opt -> max_sw_mat > 0 && (int64_t )tlen * qlen > opt -> max_sw_mat ) {
327339 ksw_reset_extz (ez );
328340 ez -> zdropped = 1 ;
@@ -586,7 +598,7 @@ static void mm_align1(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, int
586598
587599 r2 -> cnt = 0 ;
588600 if (r -> cnt == 0 ) return ;
589- ksw_gen_simple_mat (5 , mat , opt -> a , opt -> b , opt -> sc_ambi );
601+ ksw_gen_ts_mat (5 , mat , opt -> a , opt -> b , opt -> transition , opt -> sc_ambi );
590602 bw = (int )(opt -> bw * 1.5 + 1. );
591603 bw_long = (int )(opt -> bw_long * 1.5 + 1. );
592604 if (bw_long < bw ) bw_long = bw ;
@@ -844,7 +856,7 @@ static int mm_align1_inv(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, i
844856 if (ql < opt -> min_chain_score || ql > opt -> max_gap ) return 0 ;
845857 if (tl < opt -> min_chain_score || tl > opt -> max_gap ) return 0 ;
846858
847- ksw_gen_simple_mat (5 , mat , opt -> a , opt -> b , opt -> sc_ambi );
859+ ksw_gen_ts_mat (5 , mat , opt -> a , opt -> b , opt -> transition , opt -> sc_ambi );
848860 tseq = (uint8_t * )kmalloc (km , tl );
849861 mm_idx_getseq (mi , r1 -> rid , r1 -> re , r2 -> rs , tseq );
850862 qseq = r1 -> rev ? & qseq0 [0 ][r2 -> qe ] : & qseq0 [1 ][qlen - r2 -> qs ];
0 commit comments