From 21c77566cc76dd4c4cc93a53fc782006a14fced5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kerbiriou?= Date: Mon, 2 Jul 2018 18:14:13 +0200 Subject: [PATCH] get sequences tagged with user supplied splicing sites --- index.c | 21 +++++++++++++++++++++ minimap.h | 1 + 2 files changed, 22 insertions(+) diff --git a/index.c b/index.c index 9111e47e..caa2e1ca 100644 --- a/index.c +++ b/index.c @@ -158,6 +158,27 @@ int mm_idx_getseq(const mm_idx_t *mi, uint32_t rid, uint32_t st, uint32_t en, ui return en - st; } +int mm_idx_getseq_splicetags(const mm_idx_t *mi, uint32_t rid, uint32_t st, uint32_t en, uint8_t *seq) +{ + int res = mm_idx_getseq(mi, rid, st, en, seq); + if (mi->splices) { + const splice_v splices = ((const splice_v*) mi->splices)[rid]; + // Bissects splices array for the left of the interval + int low = 0, high = kv_size(splices) - 1; + while(low <= high) { + size_t mid = (low + high) / 2; + if (SPLICE_POS(kv_A(splices, mid)) >= st) + high = mid - 1; + else + low = mid + 1; + } + const splice_t* splices_end = &kv_A(splices, kv_size(splices)); + for(const splice_t *p = &kv_A(splices, low) ; p < splices_end && SPLICE_POS(*p) < en; p++) + seq[SPLICE_POS(*p) - st] |= 1 << (4 + SPLICE_IS_DONOR(*p)); + } + return res; +} + int32_t mm_idx_cal_max_occ(const mm_idx_t *mi, float f) { int i; diff --git a/minimap.h b/minimap.h index 97527012..63babdfd 100644 --- a/minimap.h +++ b/minimap.h @@ -346,6 +346,7 @@ int mm_map_file_frag(const mm_idx_t *idx, int n_segs, const char **fn, const mm_ int mm_idx_index_name(mm_idx_t *mi); int mm_idx_name2id(const mm_idx_t *mi, const char *name); int mm_idx_getseq(const mm_idx_t *mi, uint32_t rid, uint32_t st, uint32_t en, uint8_t *seq); +int mm_idx_getseq_splicetags(const mm_idx_t *mi, uint32_t rid, uint32_t st, uint32_t en, uint8_t *seq); // deprecated APIs for backward compatibility void mm_mapopt_init(mm_mapopt_t *opt);