allow to test if index is present
This commit is contained in:
parent
6b66ec6167
commit
3544c60c71
|
|
@ -23,6 +23,7 @@ The following Python program shows the key functionality of this module:
|
||||||
```python
|
```python
|
||||||
import minimap2 as mm
|
import minimap2 as mm
|
||||||
a = mm.Aligner("test/MT-human.fa")
|
a = mm.Aligner("test/MT-human.fa")
|
||||||
|
if not a: raise Exception("ERROR: failed to load/build index")
|
||||||
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"):
|
for hit in a.map("GGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTGCAATACTTAATTTCTGT"):
|
||||||
print("{}\t{}\t{}\t{}".format(hit.ctg, hit.r_st, hit.r_en, hit.cigar_str))
|
print("{}\t{}\t{}\t{}".format(hit.ctg, hit.r_st, hit.r_en, hit.cigar_str))
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,9 @@ cdef class Aligner:
|
||||||
if self._idx is not NULL:
|
if self._idx is not NULL:
|
||||||
cminimap2.mm_idx_destroy(self._idx)
|
cminimap2.mm_idx_destroy(self._idx)
|
||||||
|
|
||||||
|
def __bool__(self):
|
||||||
|
return (self._idx != NULL)
|
||||||
|
|
||||||
def map(self, seq, buf=None):
|
def map(self, seq, buf=None):
|
||||||
cdef cminimap2.mm_reg1_t *regs
|
cdef cminimap2.mm_reg1_t *regs
|
||||||
cdef cminimap2.mm_hitpy_t h
|
cdef cminimap2.mm_hitpy_t h
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ def main(argv):
|
||||||
print("Usage: mm2-lite.py <ref.fa>|<ref.mmi> <query.fq>")
|
print("Usage: mm2-lite.py <ref.fa>|<ref.mmi> <query.fq>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
a = mm.Aligner(args[0]) # load/build index
|
a = mm.Aligner(args[0]) # load/build index
|
||||||
|
if not a:
|
||||||
|
print("ERROR: failed to load/build index")
|
||||||
|
return
|
||||||
for name, seq, qual in readfq(open(args[1])): # read one sequence
|
for name, seq, qual in readfq(open(args[1])): # read one sequence
|
||||||
for h in a.map(seq): # traverse hits
|
for h in a.map(seq): # traverse hits
|
||||||
print('{}\t{}\t{}'.format(name, len(seq), h))
|
print('{}\t{}\t{}'.format(name, len(seq), h))
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -11,7 +11,7 @@ sys.path.append('python')
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'minimap2',
|
name = 'minimap2',
|
||||||
version = '2.1.1',
|
version = '2.2rc',
|
||||||
url = 'https://github.com/lh3/minimap2',
|
url = 'https://github.com/lh3/minimap2',
|
||||||
description = 'Minimap2 python binding',
|
description = 'Minimap2 python binding',
|
||||||
author = 'Heng Li',
|
author = 'Heng Li',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue