change to rst for PyPI
This commit is contained in:
parent
7e98b18ba2
commit
ddc2c6f279
|
|
@ -0,0 +1,11 @@
|
|||
include *.h
|
||||
include Makefile
|
||||
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/README.md
|
||||
|
|
@ -1,43 +1,55 @@
|
|||
## Minimap2 Python Binding
|
||||
=======================
|
||||
Minimap2 Python Binding
|
||||
=======================
|
||||
|
||||
[Minimap2][minimap2] is a fast and accurate pairwise aligner for genomic and
|
||||
transcribed nucleotide sequences. This module wraps minimap2 and provides a
|
||||
convenient interface to calling minimap2 in Python.
|
||||
`Minimap2 <https://github.com/lh3/minimap2>` is a fast and accurate pairwise
|
||||
aligner for genomic and transcribed nucleotide sequences. This module wraps
|
||||
minimap2 and provides a convenient interface to calling minimap2 in Python.
|
||||
|
||||
### Installation
|
||||
Installation
|
||||
------------
|
||||
|
||||
The minimap2 model can be installed directly with:
|
||||
```sh
|
||||
git clone https://github.com/lh3/minimap2
|
||||
cd minimap2
|
||||
python setup.py install
|
||||
```
|
||||
or with [pip][pip]:
|
||||
```sh
|
||||
pip install --user minimap2
|
||||
```
|
||||
|
||||
### Usage
|
||||
.. code:: shell
|
||||
|
||||
git clone https://github.com/lh3/minimap2
|
||||
cd minimap2
|
||||
python setup.py install
|
||||
|
||||
or with pip:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
pip install --user minimap2
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The following Python program shows the key functionality of this module:
|
||||
```python
|
||||
import minimap2 as mm
|
||||
a = mm.Aligner("test/MT-human.fa")
|
||||
if not a: raise Exception("ERROR: failed to load/build index")
|
||||
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"):
|
||||
print("{}\t{}\t{}\t{}".format(hit.ctg, hit.r_st, hit.r_en, hit.cigar_str))
|
||||
```
|
||||
|
||||
.. code:: python
|
||||
|
||||
import minimap2 as mm
|
||||
a = mm.Aligner("test/MT-human.fa")
|
||||
if not a: raise Exception("ERROR: failed to load/build index")
|
||||
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"):
|
||||
print("{}\t{}\t{}\t{}".format(hit.ctg, hit.r_st, hit.r_en, hit.cigar_str))
|
||||
|
||||
It builds an index from the specified sequence file (or loads an index if a
|
||||
pre-built index is supplied), aligns a sequence against it, traverses each hit
|
||||
and prints them out.
|
||||
|
||||
### APIs
|
||||
APIs
|
||||
----
|
||||
|
||||
#### Class minimap2.Aligner
|
||||
Class minimap2.Aligner
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: python
|
||||
|
||||
Aligner(fn_idx_in, preset=None, ...)
|
||||
|
||||
```python
|
||||
Aligner(fn_idx_in, preset=None, ...)
|
||||
```
|
||||
Arguments:
|
||||
|
||||
* `fn_idx_in`: index or sequence file name. Minimap2 automatically tests the
|
||||
|
|
@ -67,13 +79,15 @@ Arguments:
|
|||
|
||||
* `fn_idx_out`: name of file to which the index is written
|
||||
|
||||
```python
|
||||
map(query_seq)
|
||||
```
|
||||
.. code:: python
|
||||
|
||||
map(query_seq)
|
||||
|
||||
This methods maps `query_seq` against the index. It *yields* a generator,
|
||||
generating a series of `Alignment` objects.
|
||||
|
||||
#### Class minimap2.Alignment
|
||||
Class minimap2.Alignment
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This class has the following properties:
|
||||
|
||||
|
|
@ -105,11 +119,7 @@ This class has the following properties:
|
|||
give the length and the operator of each CIGAR operation.
|
||||
|
||||
An Alignment object can be converted to a string in the following format:
|
||||
```
|
||||
q_st q_en strand ctg ctg_len r_st r_en blen-NM blen mapq cg:Z:cigar_str
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
|
||||
[minimap2]: https://github.com/lh3/minimap2
|
||||
[pip]: https://pypi.python.org/pypi/pip
|
||||
q_st q_en strand ctg ctg_len r_st r_en blen-NM blen mapq cg:Z:cigar_str
|
||||
28
setup.py
28
setup.py
|
|
@ -4,9 +4,17 @@ except ImportError:
|
|||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
|
||||
from Cython.Build import cythonize
|
||||
import sys
|
||||
cmdclass = {}
|
||||
|
||||
try:
|
||||
from Cython.Build import build_ext
|
||||
except ImportError: # without Cython
|
||||
module_src = 'python/minimap2.c'
|
||||
else: # with Cython
|
||||
module_src = 'python/minimap2.pyx'
|
||||
cmdclass['build_ext'] = build_ext
|
||||
|
||||
import sys
|
||||
sys.path.append('python')
|
||||
|
||||
setup(
|
||||
|
|
@ -16,12 +24,16 @@ setup(
|
|||
description = 'Minimap2 python binding',
|
||||
author = 'Heng Li',
|
||||
author_email = 'lh3@me.com',
|
||||
license = 'MIT',
|
||||
keywords = ['bioinformatics', 'sequence-alignment'],
|
||||
ext_modules = cythonize([Extension('minimap2',
|
||||
['python/minimap2.pyx', 'align.c', 'bseq.c', 'chain.c', 'format.c', 'hit.c', 'index.c', 'kalloc.c',
|
||||
'ksw2_extd2_sse.c', 'ksw2_exts2_sse.c', 'ksw2_extz2_sse.c', 'ksw2_ll_sse.c', 'kthread.c', 'map.c',
|
||||
'misc.c', 'sdust.c', 'sketch.c'],
|
||||
ext_modules = [Extension('minimap2',
|
||||
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'],
|
||||
extra_compile_args = ['-msse4'], # WARNING: ancient x86_64 CPUs don't have SSE4
|
||||
include_dirs = ['.'],
|
||||
libraries = ['z', 'm', 'pthread'])])
|
||||
)
|
||||
libraries = ['z', 'm', 'pthread'])],
|
||||
cmdclass = cmdclass)
|
||||
|
|
|
|||
Loading…
Reference in New Issue