diff --git a/align.c b/align.c index 4abed92..9bb61bd 100644 --- a/align.c +++ b/align.c @@ -65,7 +65,7 @@ static int mm_check_zdrop(const uint8_t *qseq, const uint8_t *tseq, uint32_t n_c static void mm_update_extra(mm_extra_t *p, const uint8_t *qseq, const uint8_t *tseq, const int8_t *mat, int8_t q, int8_t e) { uint32_t k, l, toff = 0, qoff = 0; - int32_t s = 0, max = 0, n_gtag = 0, n_ctac = 0; + int32_t s = 0, max = 0; if (p == 0) return; for (k = 0; k < p->n_cigar; ++k) { uint32_t op = p->cigar[k]&0xf, len = p->cigar[k]>>4; @@ -99,14 +99,10 @@ static void mm_update_extra(mm_extra_t *p, const uint8_t *qseq, const uint8_t *t uint8_t b[4]; b[0] = tseq[toff], b[1] = tseq[toff+1]; b[2] = tseq[toff+len-2], b[3] = tseq[toff+len-1]; - if (memcmp(b, "\2\3\0\2", 4) == 0) ++n_gtag; - else if (memcmp(b, "\1\3\0\1", 4) == 0) ++n_ctac; toff += len, p->blen += len; } } p->dp_max = max; - if (n_gtag > n_ctac) p->trans_strand = 1; - else if (n_gtag < n_ctac) p->trans_strand = 2; } static void mm_append_cigar(mm_reg1_t *r, uint32_t n_cigar, uint32_t *cigar) // TODO: this calls the libc realloc() @@ -284,7 +280,6 @@ static void mm_align1(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, int if (opt->flag & MM_F_SPLICE) { if (splice_flag & MM_F_SPLICE_FOR) extra_flag |= rev? KSW_EZ_SPLICE_REV : KSW_EZ_SPLICE_FOR; if (splice_flag & MM_F_SPLICE_REV) extra_flag |= rev? KSW_EZ_SPLICE_FOR : KSW_EZ_SPLICE_REV; - if (splice_flag & MM_F_SPLICE_BOTH) extra_flag |= KSW_EZ_SPLICE_FOR|KSW_EZ_SPLICE_REV; } // compute rs0 and qs0 @@ -468,7 +463,7 @@ mm_reg1_t *mm_align_skeleton(void *km, const mm_mapopt_t *opt, const mm_idx_t *m memset(&ez, 0, sizeof(ksw_extz_t)); for (i = 0; i < n_regs; ++i) { mm_reg1_t r2; - if ((opt->flag&MM_F_SPLICE) && (opt->flag&MM_F_SPLICE_FOR) && (opt->flag&MM_F_SPLICE_REV)) { + if ((opt->flag&MM_F_SPLICE) && (opt->flag&MM_F_SPLICE_FOR) && (opt->flag&MM_F_SPLICE_REV)) { // then do two rounds of alignments for both strands mm_reg1_t s[2], s2[2]; int which, trans_strand; s[0] = s[1] = regs[i]; @@ -485,9 +480,9 @@ mm_reg1_t *mm_align_skeleton(void *km, const mm_mapopt_t *opt, const mm_idx_t *m free(s[0].p); } regs[i].p->trans_strand = trans_strand; - } else { + } else { // one round of alignment mm_align1(km, opt, mi, qlen, qseq0, ®s[i], &r2, a, &ez, opt->flag); - if ((opt->flag&MM_F_SPLICE) && !(opt->flag&MM_F_SPLICE_BOTH)) + if (opt->flag&MM_F_SPLICE) regs[i].p->trans_strand = opt->flag&MM_F_SPLICE_FOR? 1 : 2; } if (r2.cnt > 0) regs = mm_insert_reg(&r2, i, &n_regs, regs); diff --git a/main.c b/main.c index 4437625..2909ddc 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ #include "mmpriv.h" #include "getopt.h" -#define MM_VERSION "2.2-r414-dirty" +#define MM_VERSION "2.2-r421-dirty" #ifdef __linux__ #include @@ -124,11 +124,10 @@ int main(int argc, char *argv[]) if (x < 1.0) opt.mid_occ_frac = x, opt.mid_occ = 0; else opt.mid_occ = (int)(x + .499); } else if (c == 'u') { - if (*optarg == 'b') opt.flag |= MM_F_SPLICE_FOR|MM_F_SPLICE_REV; - else if (*optarg == 'B') opt.flag |= MM_F_SPLICE_BOTH; - else if (*optarg == 'f') opt.flag |= MM_F_SPLICE_FOR, opt.flag &= ~MM_F_SPLICE_REV; - else if (*optarg == 'r') opt.flag |= MM_F_SPLICE_REV, opt.flag &= ~MM_F_SPLICE_FOR; - else if (*optarg == 'n') opt.flag &= ~(MM_F_SPLICE_FOR|MM_F_SPLICE_REV); + if (*optarg == 'b') opt.flag |= MM_F_SPLICE_FOR|MM_F_SPLICE_REV; // both strands + else if (*optarg == 'f') opt.flag |= MM_F_SPLICE_FOR, opt.flag &= ~MM_F_SPLICE_REV; // match GT-AG + else if (*optarg == 'r') opt.flag |= MM_F_SPLICE_REV, opt.flag &= ~MM_F_SPLICE_FOR; // match CT-AC (reverse complement of GT-AG) + else if (*optarg == 'n') opt.flag &= ~(MM_F_SPLICE_FOR|MM_F_SPLICE_REV); // don't try to match the GT-AG signal else { fprintf(stderr, "[E::%s] unrecognized cDNA direction\n", __func__); return 1; diff --git a/map.c b/map.c index 09a7024..924e2dd 100644 --- a/map.c +++ b/map.c @@ -38,8 +38,8 @@ void mm_mapopt_init(mm_mapopt_t *opt) void mm_mapopt_update(mm_mapopt_t *opt, const mm_idx_t *mi) { - if (opt->flag & MM_F_SPLICE_BOTH) - opt->flag &= ~(MM_F_SPLICE_FOR|MM_F_SPLICE_REV); + if ((opt->flag & MM_F_SPLICE_FOR) && (opt->flag & MM_F_SPLICE_REV)) + opt->flag |= MM_F_SPLICE; if (opt->mid_occ <= 0) opt->mid_occ = mm_idx_cal_max_occ(mi, opt->mid_occ_frac); if (mm_verbose >= 3) diff --git a/minimap.h b/minimap.h index ebe6715..74bf2ae 100644 --- a/minimap.h +++ b/minimap.h @@ -12,10 +12,9 @@ #define MM_F_NO_QUAL 0x010 #define MM_F_OUT_CG 0x020 #define MM_F_OUT_CS 0x040 -#define MM_F_SPLICE 0x080 -#define MM_F_SPLICE_FOR 0x100 -#define MM_F_SPLICE_REV 0x200 -#define MM_F_SPLICE_BOTH 0x400 +#define MM_F_SPLICE 0x080 // splice mode +#define MM_F_SPLICE_FOR 0x100 // match GT-AG +#define MM_F_SPLICE_REV 0x200 // match CT-AC, the reverse complement of GT-AG #define MM_F_NO_SAM_SQ 0x800 #define MM_F_SR 0x1000