diff --git a/align.c b/align.c index e1855f3..7d7d4f1 100644 --- a/align.c +++ b/align.c @@ -696,7 +696,7 @@ mm_reg1_t *mm_align_skeleton(void *km, const mm_mapopt_t *opt, const mm_idx_t *m 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); - if (!(opt->flag&MM_F_SPLICE) && !(opt->flag&MM_F_SR) && i > 0) { // don't try inversion alignment for -xsplice or -xsr + if (!(opt->flag&(MM_F_SPLICE|MM_F_SR)) && !(opt->flag&(MM_F_FOR_ONLY|MM_F_REV_ONLY)) && i > 0) { // don't try inversion alignment for -xsplice or -xsr, or --for-only/rev-only if (mm_align1_inv(km, opt, mi, qlen, qseq0, ®s[i-1], ®s[i], &r2, &ez)) { regs = mm_insert_reg(&r2, i, &n_regs, regs); ++i; // skip the inserted INV alignment diff --git a/main.c b/main.c index 6c02a4d..0292207 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ #include "mmpriv.h" #include "getopt.h" -#define MM_VERSION "2.7-r654" +#define MM_VERSION "2.7-r655-dirty" #ifdef __linux__ #include @@ -45,6 +45,8 @@ static struct option long_options[] = { { "splice-flank", optional_argument, 0, 0 }, { "idx-no-seq", no_argument, 0, 0 }, { "end-seed-pen", required_argument, 0, 0 }, // 21 + { "for-only", no_argument, 0, 0 }, // 22 + { "rev-only", no_argument, 0, 0 }, // 23 { "help", no_argument, 0, 'h' }, { "max-intron-len", required_argument, 0, 'G' }, { "version", no_argument, 0, 'V' }, @@ -142,6 +144,8 @@ int main(int argc, char *argv[]) else if (c == 0 && long_idx ==18) opt.flag |= MM_F_INDEPEND_SEG; // --no-pairing else if (c == 0 && long_idx ==20) ipt.flag |= MM_I_NO_SEQ; // --idx-no-seq else if (c == 0 && long_idx ==21) opt.anchor_ext_shift = atoi(optarg); // --end-seed-pen + else if (c == 0 && long_idx ==22) opt.flag |= MM_F_FOR_ONLY; // --for-only + else if (c == 0 && long_idx ==23) opt.flag |= MM_F_REV_ONLY; // --rev-only else if (c == 0 && long_idx == 14) { // --frag if (optarg == 0 || strcmp(optarg, "yes") == 0 || strcmp(optarg, "y") == 0) opt.flag |= MM_F_FRAG_MODE; diff --git a/map.c b/map.c index 6574f54..054cd91 100644 --- a/map.c +++ b/map.c @@ -117,6 +117,11 @@ int mm_set_opt(const char *preset, mm_idxopt_t *io, mm_mapopt_t *mo) int mm_check_opt(const mm_idxopt_t *io, const mm_mapopt_t *mo) { + if ((mo->flag & MM_F_FOR_ONLY) && (mo->flag & MM_F_REV_ONLY)) { + if (mm_verbose >= 1) + fprintf(stderr, "[ERROR]\033[1;31m --for-only and --rev-only can't be applied at the same time\033[0m\n"); + return -3; + } if ((mo->q != mo->q2 || mo->e != mo->e2) && !(mo->e > mo->e2 && mo->q + mo->e < mo->q2 + mo->e2)) { if (mm_verbose >= 1) fprintf(stderr, "[ERROR]\033[1;31m dual gap penalties violating E1>E2 and O1+E1flag&MM_F_AVA) && cmp > 0) // all-vs-all mode: map once continue; } + if (opt->flag & (MM_F_FOR_ONLY|MM_F_REV_ONLY)) { + if ((r[k]&1) == (q->qpos&1)) { // forward strand + if (opt->flag & MM_F_REV_ONLY) continue; + } else { + if (opt->flag & MM_F_FOR_ONLY) continue; + } + } p = &a[(*n_a)++]; if ((r[k]&1) == (q->qpos&1)) { // forward strand p->x = (r[k]&0xffffffff00000000ULL) | rpos; diff --git a/minimap.h b/minimap.h index 1cff5ed..26cf187 100644 --- a/minimap.h +++ b/minimap.h @@ -25,6 +25,8 @@ #define MM_F_INDEPEND_SEG 0x20000 #define MM_F_SPLICE_FLANK 0x40000 #define MM_F_SOFTCLIP 0x80000 +#define MM_F_FOR_ONLY 0x100000 +#define MM_F_REV_ONLY 0x200000 #define MM_I_HPC 0x1 #define MM_I_NO_SEQ 0x2 diff --git a/minimap2.1 b/minimap2.1 index bac22e8..67b61c9 100644 --- a/minimap2.1 +++ b/minimap2.1 @@ -1,4 +1,4 @@ -.TH minimap2 1 "9 January 2018" "minimap2-2.7 (r654)" "Bioinformatics tools" +.TH minimap2 1 "16 January 2018" "minimap2-2.7-dirty (r655)" "Bioinformatics tools" .SH NAME .PP minimap2 - mapping and alignment between collections of DNA sequences @@ -206,6 +206,14 @@ seeds with ungapped alignment. .TP .BR --frag [= no | yes ] Whether to enable the fragment mode [no] +.TP +.B --for-only +Only map to the forward strand of the reference sequences. For paired-end +reads in the forward-reverse orientation, the first read is mapped to forward +strand of the reference and the second read to the reverse stand. +.TP +.B --rev-only +Only map to the reverse complement strand of the reference sequences. .SS Alignment options .TP 10 .BI -A \ INT