Skip to content

Commit 3187782

Browse files
committed
r1285: better --spsc support
1 parent 005c9a1 commit 3187782

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

index.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ typedef struct mm_idx_spsc_s {
967967
uint64_t *a; // pos<<56 | score<<1 | acceptor
968968
} mm_idx_spsc_t;
969969

970-
int32_t mm_idx_spsc_read(mm_idx_t *idx, const char *fn, int32_t max_sc)
970+
int32_t mm_idx_spsc_read2(mm_idx_t *idx, const char *fn, int32_t max_sc, float scale)
971971
{
972972
gzFile fp;
973973
kstring_t str = {0,0,0};
@@ -1007,6 +1007,8 @@ int32_t mm_idx_spsc_read(mm_idx_t *idx, const char *fn, int32_t max_sc)
10071007
}
10081008
}
10091009
if (i < 4) continue; // not enough fields
1010+
if (scale > 0.0f && scale < 1.0f)
1011+
score = score > 0.0f? (int)(score * scale + .499) : (int)(score * scale - .499);
10101012
if (score > max_sc) score = max_sc;
10111013
if (score < -max_sc) score = -max_sc;
10121014
cid = mm_idx_name2id(idx, name);
@@ -1030,6 +1032,11 @@ int32_t mm_idx_spsc_read(mm_idx_t *idx, const char *fn, int32_t max_sc)
10301032
return 0;
10311033
}
10321034

1035+
int32_t mm_idx_spsc_read(mm_idx_t *idx, const char *fn, int32_t max_sc)
1036+
{
1037+
return mm_idx_spsc_read2(idx, fn, max_sc, 1.0f);
1038+
}
1039+
10331040
static int32_t mm_idx_find_intv(int32_t n, const uint64_t *a, int64_t x)
10341041
{
10351042
int32_t s = 0, e = n;

main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static ko_longopt_t long_options[] = {
8585
{ "jump-min-match", ko_required_argument, 360 },
8686
{ "write-junc", ko_no_argument, 361 },
8787
{ "pass1", ko_required_argument, 362 },
88+
{ "spsc-scale", ko_required_argument, 363 },
89+
{ "spsc0", ko_required_argument, 364 },
8890
{ "dbg-seed-occ", ko_no_argument, 501 },
8991
{ "help", ko_no_argument, 'h' },
9092
{ "max-intron-len", ko_required_argument, 'G' },
@@ -134,6 +136,7 @@ int main(int argc, char *argv[])
134136
mm_mapopt_t opt;
135137
mm_idxopt_t ipt;
136138
int i, c, n_threads = 3, n_parts, old_best_n = -1;
139+
float spsc_scale = 0.7f;
137140
char *fnw = 0, *rg = 0, *fn_bed_junc = 0, *fn_bed_jump = 0, *fn_bed_pass1 = 0, *fn_spsc = 0, *s, *alt_list = 0;
138141
FILE *fp_help = stderr;
139142
mm_idx_reader_t *idx_rdr;
@@ -240,7 +243,6 @@ int main(int argc, char *argv[])
240243
else if (c == 338) opt.max_qlen = mm_parse_num(o.arg); // --max-qlen
241244
else if (c == 340) fn_bed_junc = o.arg; // --junc-bed
242245
else if (c == 341) opt.junc_bonus = atoi(o.arg); // --junc-bonus
243-
else if (c == 358) opt.junc_pen = atoi(o.arg); // --junc-pen
244246
else if (c == 342) opt.flag |= MM_F_SAM_HIT_ONLY; // --sam-hit-only
245247
else if (c == 343) opt.chain_gap_scale = atof(o.arg); // --chain-gap-scale
246248
else if (c == 351) opt.chain_skip_scale = atof(o.arg); // --chain-skip-scale
@@ -260,6 +262,8 @@ int main(int argc, char *argv[])
260262
else if (c == 361) opt.flag |= MM_F_OUT_JUNC | MM_F_CIGAR; // --write-junc
261263
else if (c == 362) fn_bed_pass1 = o.arg; // --jump-pass1
262264
else if (c == 501) mm_dbg_flag |= MM_DBG_SEED_FREQ; // --dbg-seed-occ
265+
else if (c == 363) spsc_scale = atof(o.arg); // --spsc-scale
266+
else if (c == 358 || c == 364) opt.junc_pen = atoi(o.arg); // --junc-pen or --spsc0
263267
else if (c == 330) {
264268
fprintf(stderr, "[WARNING] \033[1;31m --lj-min-ratio has been deprecated.\033[0m\n");
265269
} else if (c == 313) { // --sr
@@ -476,7 +480,7 @@ int main(int argc, char *argv[])
476480
fprintf(stderr, "[WARNING] failed to load the pass-1 jump BED file\n");
477481
}
478482
if (fn_spsc) {
479-
mm_idx_spsc_read(mi, fn_spsc, mm_max_spsc_bonus(&opt));
483+
mm_idx_spsc_read2(mi, fn_spsc, mm_max_spsc_bonus(&opt), spsc_scale);
480484
if (mi->spsc == 0 && mm_verbose >= 2)
481485
fprintf(stderr, "[WARNING] failed to load the splice score file\n");
482486
}

minimap.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <stdio.h>
66
#include <sys/types.h>
77

8-
#define MM_VERSION "2.29-r1283"
8+
#define MM_VERSION "2.29-r1285-dirty"
99

1010
#define MM_F_NO_DIAG (0x001LL) // no exact diagonal hit
1111
#define MM_F_NO_DUAL (0x002LL) // skip pairs where query name is lexicographically larger than target name
@@ -163,7 +163,8 @@ typedef struct {
163163
int transition; // transition mismatch score (A:G, C:T)
164164
int sc_ambi; // score when one or both bases are "N"
165165
int noncan; // cost of non-canonical splicing sites
166-
int junc_bonus, junc_pen;
166+
int junc_bonus; // bonus for a splice site in annotation
167+
int junc_pen; // penalty for GT- or -AG not scored in --spsc
167168
int zdrop, zdrop_inv; // break alignment if alignment score drops too fast along the diagonal
168169
int end_bonus;
169170
int min_dp_max; // drop an alignment if the score of the max scoring segment is below this threshold
@@ -420,6 +421,7 @@ int mm_idx_bed_junc(const mm_idx_t *mi, int32_t ctg, int32_t st, int32_t en, uin
420421

421422
int mm_max_spsc_bonus(const mm_mapopt_t *mo);
422423
int32_t mm_idx_spsc_read(mm_idx_t *idx, const char *fn, int32_t max_sc);
424+
int32_t mm_idx_spsc_read2(mm_idx_t *idx, const char *fn, int32_t max_sc, float scale);
423425
int64_t mm_idx_spsc_get(const mm_idx_t *db, int32_t cid, int64_t st0, int64_t en0, int32_t rev, uint8_t *sc);
424426

425427
// deprecated APIs for backward compatibility

minimap2.1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,23 @@ line corresponds to a donor site and `A' for an acceptor site.
443443
A positive score suggests the junction is preferred and a negative score
444444
suggests the junction is not preferred.
445445
.TP
446-
.BR --junc-pen \ INT
447-
Penalty for a position not in FILE specified by
446+
.BR --spsc0 \ INT
447+
Penalty for positions not in
448+
.I FILE
449+
specified by
448450
.B --spsc
449451
[5]. Effective with
450452
.B --spsc
451453
but not
452454
.BR --junc-bed .
453455
.TP
456+
.BR --spsc-scale \ FLOAT
457+
Scale splice scores in
458+
.B --spsc
459+
by
460+
.IR FLOAT
461+
rounded to the nearest integer [0.7].
462+
.TP
454463
.BR --junc-bed \ FILE
455464
Junctions to prefer during base alignment [].
456465
Same format as

0 commit comments

Comments
 (0)