renamed module name from minimap2 to mmappy

minimap2 clashed with minimap2 from conda
This commit is contained in:
Heng Li 2017-09-16 23:29:41 -04:00
parent 06b79c4a52
commit 28fd3d63fd
8 changed files with 43 additions and 43 deletions

View File

@ -4,8 +4,8 @@ include ksw2_dispatch.c
include getopt.c
include main.c
include README.md
include python/minimap2.c
include python/cminimap2.h
include python/cminimap2.pxd
include python/minimap2.pyx
include python/mmappy.c
include python/cmmappy.h
include python/cmmappy.pxd
include python/mmappy.pyx
include python/README.rst

View File

@ -56,7 +56,7 @@ ksw2_dispatch.o:ksw2_dispatch.c ksw2.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) -DKSW_CPU_DISPATCH $(INCLUDES) $< -o $@
clean:
rm -fr gmon.out *.o a.out $(PROG) $(PROG_EXTRA) *~ *.a *.dSYM build dist minimap2.so minimap2.c python/minimap2.c minimap2.egg*
rm -fr gmon.out *.o a.out $(PROG) $(PROG_EXTRA) *~ *.a *.dSYM build dist mmappy.so mmappy.c python/mmappy.c mmappy.egg*
depend:
(LC_ALL=C; export LC_ALL; makedepend -Y -- $(CFLAGS) $(CPPFLAGS) -- *.c)

View File

@ -1,6 +1,6 @@
=======================
Minimap2 Python Binding
=======================
===============================
Mmappy: Minimap2 Python Binding
===============================
`Minimap2 <https://github.com/lh3/minimap2>`_ is a fast and accurate pairwise
aligner for genomic and transcribed nucleotide sequences. This module wraps
@ -21,7 +21,7 @@ or with `pip <https://en.wikipedia.org/wiki/Pip_(package_manager)>`_:
.. code:: shell
pip install --user minimap2
pip install --user mmappy
Usage
-----
@ -30,7 +30,7 @@ The following Python program shows the key functionality of this module:
.. code:: python
import minimap2 as mm
import mmappy as mm
a = mm.Aligner("test/MT-human.fa") # load or build index
if not a: raise Exception("ERROR: failed to load/build index")
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"):
@ -86,7 +86,7 @@ Arguments:
This method maps :code:`seq` against the index. It *yields* a generator,
generating a series of :code:`Alignment` objects.
Class minimap2.Alignment
Class mmappy.Alignment
~~~~~~~~~~~~~~~~~~~~~~~~
This class has the following properties:

View File

@ -1,5 +1,5 @@
#ifndef CMINIMAP2_H
#define CMINIMAP2_H
#ifndef CMMAPPY_H
#define CMMAPPY_H
#include <stdlib.h>
#include "minimap.h"

View File

@ -62,7 +62,7 @@ cdef extern from "minimap.h":
void mm_mapopt_update(mm_mapopt_t *opt, const mm_idx_t *mi)
#
# Mapping (key struct defined in cminimap2.h below)
# Mapping (key struct defined in cmmappy.h below)
#
ctypedef struct mm_reg1_t:
pass
@ -77,7 +77,7 @@ cdef extern from "minimap.h":
#
# Helper header (because it is hard to expose mm_reg1_t with Cython
#
cdef extern from "cminimap2.h":
cdef extern from "cmmappy.h":
ctypedef struct mm_hitpy_t:
const char *ctg
int32_t ctg_start, ctg_end

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
import sys, getopt
import minimap2 as mm
import mmappy as mm
def readfq(fp): # multi-line fasta/fastq parser
last = None

View File

@ -1,6 +1,6 @@
from libc.stdint cimport uint8_t, int8_t
from libc.stdlib cimport free
cimport cminimap2
cimport cmmappy
cdef class Alignment:
cdef int _ctg_len, _r_st, _r_en
@ -69,23 +69,23 @@ cdef class Alignment:
str(self._blen - self._NM), str(self._blen), str(self._mapq), "NM:i:" + str(self._NM), tp, "cg:Z:" + self.cigar_str])
cdef class ThreadBuffer:
cdef cminimap2.mm_tbuf_t *_b
cdef cmmappy.mm_tbuf_t *_b
def __cinit__(self):
self._b = cminimap2.mm_tbuf_init()
self._b = cmmappy.mm_tbuf_init()
def __dealloc__(self):
cminimap2.mm_tbuf_destroy(self._b)
cmmappy.mm_tbuf_destroy(self._b)
cdef class Aligner:
cdef cminimap2.mm_idx_t *_idx
cdef cminimap2.mm_idxopt_t idx_opt
cdef cminimap2.mm_mapopt_t map_opt
cdef cmmappy.mm_idx_t *_idx
cdef cmmappy.mm_idxopt_t idx_opt
cdef cmmappy.mm_mapopt_t map_opt
def __cinit__(self, fn_idx_in, 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):
cminimap2.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options
cmmappy.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options
if preset is not None:
cminimap2.mm_set_opt(str.encode(preset), &self.idx_opt, &self.map_opt) # apply preset
cmmappy.mm_set_opt(str.encode(preset), &self.idx_opt, &self.map_opt) # apply preset
self.map_opt.flag |= 4 # always perform alignment
self.idx_opt.batch_size = 0x7fffffffffffffffL # always build a uni-part index
if k is not None: self.idx_opt.k = k
@ -96,40 +96,40 @@ cdef class Aligner:
if bw is not None: self.map_opt.bw = bw
if best_n is not None: self.best_n = best_n
cdef cminimap2.mm_idx_reader_t *r;
cdef cmmappy.mm_idx_reader_t *r;
if fn_idx_out is None:
r = cminimap2.mm_idx_reader_open(str.encode(fn_idx_in), &self.idx_opt, NULL)
r = cmmappy.mm_idx_reader_open(str.encode(fn_idx_in), &self.idx_opt, NULL)
else:
r = cminimap2.mm_idx_reader_open(str.encode(fn_idx_in), &self.idx_opt, fn_idx_out)
r = cmmappy.mm_idx_reader_open(str.encode(fn_idx_in), &self.idx_opt, fn_idx_out)
if r is not NULL:
self._idx = cminimap2.mm_idx_reader_read(r, n_threads) # NB: ONLY read the first part
cminimap2.mm_idx_reader_close(r)
cminimap2.mm_mapopt_update(&self.map_opt, self._idx)
self._idx = cmmappy.mm_idx_reader_read(r, n_threads) # NB: ONLY read the first part
cmmappy.mm_idx_reader_close(r)
cmmappy.mm_mapopt_update(&self.map_opt, self._idx)
def __dealloc__(self):
if self._idx is not NULL:
cminimap2.mm_idx_destroy(self._idx)
cmmappy.mm_idx_destroy(self._idx)
def __bool__(self):
return (self._idx != NULL)
def map(self, seq, buf=None):
cdef cminimap2.mm_reg1_t *regs
cdef cminimap2.mm_hitpy_t h
cdef cmmappy.mm_reg1_t *regs
cdef cmmappy.mm_hitpy_t h
cdef ThreadBuffer b
cdef int n_regs
if self._idx is NULL: return None
if buf is None: b = ThreadBuffer()
else: b = buf
regs = cminimap2.mm_map(self._idx, len(seq), str.encode(seq), &n_regs, b._b, &self.map_opt, NULL)
regs = cmmappy.mm_map(self._idx, len(seq), str.encode(seq), &n_regs, b._b, &self.map_opt, NULL)
for i in range(n_regs):
cminimap2.mm_reg2hitpy(self._idx, &regs[i], &h)
cmmappy.mm_reg2hitpy(self._idx, &regs[i], &h)
cigar = []
for k in range(h.n_cigar32):
c = h.cigar32[k]
cigar.append([c>>4, c&0xf])
yield Alignment(h.ctg, h.ctg_len, h.ctg_start, h.ctg_end, h.strand, h.qry_start, h.qry_end, h.mapq, cigar, h.is_primary, h.blen, h.NM, h.trans_strand)
cminimap2.mm_free_reg1(&regs[i])
cmmappy.mm_free_reg1(&regs[i])
free(regs)

View File

@ -9,9 +9,9 @@ cmdclass = {}
try:
from Cython.Build import build_ext
except ImportError: # without Cython
module_src = 'python/minimap2.c'
module_src = 'python/mmappy.c'
else: # with Cython
module_src = 'python/minimap2.pyx'
module_src = 'python/mmappy.pyx'
cmdclass['build_ext'] = build_ext
import sys
@ -22,8 +22,8 @@ def readme():
return f.read()
setup(
name = 'minimap2',
version = '2.2rc',
name = 'mmappy',
version = '2.2rc1',
url = 'https://github.com/lh3/minimap2',
description = 'Minimap2 python binding',
long_description = readme(),
@ -31,13 +31,13 @@ setup(
author_email = 'lh3@me.com',
license = 'MIT',
keywords = ['bioinformatics', 'sequence-alignment'],
ext_modules = [Extension('minimap2',
ext_modules = [Extension('mmappy',
sources = [module_src, 'align.c', 'bseq.c', 'chain.c', 'format.c', 'hit.c', 'index.c',
'ksw2_extd2_sse.c', 'ksw2_exts2_sse.c', 'ksw2_extz2_sse.c', 'ksw2_ll_sse.c',
'kalloc.c', 'kthread.c', 'map.c', 'misc.c', 'sdust.c', 'sketch.c'],
depends = ['minimap.h', 'bseq.h', 'kalloc.h', 'kdq.h', 'khash.h', 'kseq.h', 'ksort.h',
'ksw2.h', 'kthread.h', 'kvec.h', 'mmpriv.h', 'sdust.h',
'python/cminimap2.h', 'python/cminimap2.pxd'],
'python/cmmappy.h', 'python/cmmappy.pxd'],
extra_compile_args = ['-msse4'], # WARNING: ancient x86_64 CPUs don't have SSE4
include_dirs = ['.'],
libraries = ['z', 'm', 'pthread'])],