Skip to content

Commit

Permalink
Update to 50 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
endrebak authored Nov 11, 2019
1 parent 2e97975 commit 4cc843b
Show file tree
Hide file tree
Showing 6 changed files with 1,899 additions and 2,149 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 0.0.48 (08.11.19)
# 0.0.50 (11.11.19)
- fix last_overlaps_both

# 0.0.49 (08.11.19)
- add last_overlaps_both

# 0).0.47 (30.10.19)
Expand Down
2,075 changes: 977 additions & 1,098 deletions ncls/src/ncls.c

Large diffs are not rendered by default.

34 changes: 15 additions & 19 deletions ncls/src/ncls.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ cdef class NCLS64:
if not self.im: # if empty
return [], []

# from time import time
# start = time()
it_alloc = cn.interval_iterator_alloc()
it = it_alloc
for loop_counter in range(length):
Expand Down Expand Up @@ -138,6 +140,9 @@ cdef class NCLS64:
it = it_alloc

cn.free_interval_iterator(it_alloc)
# end = time()

# print("ncls time:", end - start)

return output_arr[:nfound], output_arr_other[:nfound]

Expand All @@ -152,6 +157,7 @@ cdef class NCLS64:
cdef int length = len(starts)
cdef int loop_counter = 0
cdef int nfound = 0
cdef int max_end = -1

output_arr = np.zeros(length, dtype=long)
output_arr_other = np.zeros(length, dtype=long)
Expand All @@ -172,35 +178,25 @@ cdef class NCLS64:
it = it_alloc
for loop_counter in range(length):

# print("loop_counter", loop_counter)
# remember first pointer for dealloc
while it:
i = 0
cn.find_intervals(it, starts[loop_counter], ends[loop_counter], self.im, self.ntop,
self.subheader, self.nlists, im_buf, 1024,
&(nhit), &(it)) # GET NEXT BUFFER CHUNK

# print("nhit", nhit)
# print("length", length)
# print("nfound", nfound)
# print(nfound + nhit >= length)
if nfound + nhit >= length:

length = (length + nhit) * 2
output_arr = np.resize(output_arr, length)
output_arr_other = np.resize(output_arr_other, length)
output = output_arr
output_other = output_arr_other

if nhit:
max_end = -1
while i < nhit:
if im_buf[i].end >= max_end:
# print("max_end", im_buf[i].end)
output[nfound] = indexes[loop_counter]
output_other[nfound] = im_buf[i].target_id
max_end = im_buf[i].end

# print("length", length)
# print("nfound", nfound)
# print("loop_counter", loop_counter)
output[nfound] = indexes[loop_counter]
output_other[nfound] = im_buf[nhit - 1].target_id
i += 1

nfound += 1
i += 1

cn.reset_interval_iterator(it_alloc)
it = it_alloc
Expand Down
Loading

0 comments on commit 4cc843b

Please sign in to comment.