change to rst for PyPI

This commit is contained in:
Heng Li 2017-09-16 22:29:52 -04:00
parent 7e98b18ba2
commit ddc2c6f279
3 changed files with 78 additions and 45 deletions

11
MANIFEST.in 100644
View File

@ -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

View File

@ -1,43 +1,55 @@
## Minimap2 Python Binding =======================
Minimap2 Python Binding
=======================
[Minimap2][minimap2] is a fast and accurate pairwise aligner for genomic and `Minimap2 <https://github.com/lh3/minimap2>` is a fast and accurate pairwise
transcribed nucleotide sequences. This module wraps minimap2 and provides a aligner for genomic and transcribed nucleotide sequences. This module wraps
convenient interface to calling minimap2 in Python. minimap2 and provides a convenient interface to calling minimap2 in Python.
### Installation Installation
------------
The minimap2 model can be installed directly with: 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: The following Python program shows the key functionality of this module:
```python
import minimap2 as mm .. code:: python
a = mm.Aligner("test/MT-human.fa")
if not a: raise Exception("ERROR: failed to load/build index") import minimap2 as mm
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"): a = mm.Aligner("test/MT-human.fa")
print("{}\t{}\t{}\t{}".format(hit.ctg, hit.r_st, hit.r_en, hit.cigar_str)) 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 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 pre-built index is supplied), aligns a sequence against it, traverses each hit
and prints them out. 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: Arguments:
* `fn_idx_in`: index or sequence file name. Minimap2 automatically tests the * `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 * `fn_idx_out`: name of file to which the index is written
```python .. code:: python
map(query_seq)
``` map(query_seq)
This methods maps `query_seq` against the index. It *yields* a generator, This methods maps `query_seq` against the index. It *yields* a generator,
generating a series of `Alignment` objects. generating a series of `Alignment` objects.
#### Class minimap2.Alignment Class minimap2.Alignment
~~~~~~~~~~~~~~~~~~~~~~~~
This class has the following properties: 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. give the length and the operator of each CIGAR operation.
An Alignment object can be converted to a string in the following format: 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
```
::
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

View File

@ -4,9 +4,17 @@ except ImportError:
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from Cython.Build import cythonize cmdclass = {}
import sys
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') sys.path.append('python')
setup( setup(
@ -16,12 +24,16 @@ setup(
description = 'Minimap2 python binding', description = 'Minimap2 python binding',
author = 'Heng Li', author = 'Heng Li',
author_email = 'lh3@me.com', author_email = 'lh3@me.com',
license = 'MIT',
keywords = ['bioinformatics', 'sequence-alignment'], keywords = ['bioinformatics', 'sequence-alignment'],
ext_modules = cythonize([Extension('minimap2', ext_modules = [Extension('minimap2',
['python/minimap2.pyx', 'align.c', 'bseq.c', 'chain.c', 'format.c', 'hit.c', 'index.c', 'kalloc.c', 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', 'kthread.c', 'map.c', 'ksw2_extd2_sse.c', 'ksw2_exts2_sse.c', 'ksw2_extz2_sse.c', 'ksw2_ll_sse.c',
'misc.c', 'sdust.c', 'sketch.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 extra_compile_args = ['-msse4'], # WARNING: ancient x86_64 CPUs don't have SSE4
include_dirs = ['.'], include_dirs = ['.'],
libraries = ['z', 'm', 'pthread'])]) libraries = ['z', 'm', 'pthread'])],
) cmdclass = cmdclass)