From 9a567e4b37b866a721a45e09d9aaac63c294c3de Mon Sep 17 00:00:00 2001 From: Heng Li Date: Mon, 6 Aug 2018 09:52:13 -0400 Subject: [PATCH] allow mappy to change scoring --- python/README.rst | 6 ++++++ python/mappy.pyx | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/python/README.rst b/python/README.rst index 7adfdd69..482c7353 100644 --- a/python/README.rst +++ b/python/README.rst @@ -88,6 +88,12 @@ This constructor accepts the following arguments: * **fn_idx_out**: name of file to which the index is written. This parameter has no effect if **seq** is set. +* **scoring**: scoring system. It is a tuple/list consisting of 4, 6 or 7 + positive integers. The first 4 elements specify match scoring, mismatch + penalty, gap open and gap extension penalty. The 5th and 6th elements, if + present, set long-gap open and long-gap extension penalty. The 7th sets a + mismatch penalty involving ambiguous bases. + .. code:: python mappy.Aligner.map(seq, seq2=None, cs=False, MD=False) diff --git a/python/mappy.pyx b/python/mappy.pyx index b1c5067e..3516acbc 100644 --- a/python/mappy.pyx +++ b/python/mappy.pyx @@ -112,7 +112,7 @@ cdef class Aligner: cdef cmappy.mm_idxopt_t idx_opt cdef cmappy.mm_mapopt_t map_opt - def __cinit__(self, fn_idx_in=None, preset=None, k=None, w=None, min_cnt=None, min_chain_score=None, min_dp_score=None, bw=None, best_n=None, n_threads=3, fn_idx_out=None, max_frag_len=None, extra_flags=None, seq=None): + def __cinit__(self, fn_idx_in=None, preset=None, k=None, w=None, min_cnt=None, min_chain_score=None, min_dp_score=None, bw=None, best_n=None, n_threads=3, fn_idx_out=None, max_frag_len=None, extra_flags=None, seq=None, scoring=None): cmappy.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options if preset is not None: cmappy.mm_set_opt(str.encode(preset), &self.idx_opt, &self.map_opt) # apply preset @@ -127,6 +127,14 @@ cdef class Aligner: if best_n is not None: self.map_opt.best_n = best_n if max_frag_len is not None: self.map_opt.max_frag_len = max_frag_len if extra_flags is not None: self.map_opt.flag |= extra_flags + if scoring is not None and len(scoring) >= 4: + self.map_opt.a, self.map_opt.b = scoring[0], scoring[1] + self.map_opt.q, self.map_opt.e = scoring[2], scoring[3] + self.map_opt.q2, self.map_opt.e2 = self.map_opt.q, self.map_opt.e + if len(scoring) >= 6: + self.map_opt.q2, self.map_opt.e2 = scoring[4], scoring[5] + if len(scoring) >= 7: + self.map_opt.sc_ambi = scoring[6] cdef cmappy.mm_idx_reader_t *r;