Skip to content

Commit

Permalink
Was on old branch, needed to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
endrebak committed Feb 24, 2020
2 parents 2324da8 + 1ea632a commit 7692e67
Show file tree
Hide file tree
Showing 9 changed files with 26,790 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.0.53 (unreleased)
- add datastructure FNCLS which uses floating point starts and ends

# 0.0.52 (20.02.20)
- fix missing functions in headers (thanks Igor Gotlibovych)

Expand Down
10 changes: 10 additions & 0 deletions ncls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ def NCLS(starts, ends, ids):
else:
raise Exception("Starts/Ends not int64 or int32: " + str(starts.dtype))


def FNCLS(starts, ends, ids):

from ncls.src.fncls import FNCLS

if starts.dtype == np.double:
return FNCLS(starts, ends, ids)
else:
raise Exception("Starts/Ends not double: " + str(starts.dtype))

from ncls.version import __version__
74 changes: 74 additions & 0 deletions ncls/src/cfncls.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from libc.stdint cimport int64_t


cdef extern from "stdlib.h":
void free(void *)
void *malloc(size_t)
void *calloc(size_t,size_t)
void *realloc(void *,size_t)
int c_abs "abs" (int)
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(void *,void *))

cdef extern from "stdio.h":
ctypedef struct FILE:
pass

FILE *fopen(char *,char *)
FILE *open_memstream(void *, size_t *)
FILE *fmemopen (void *, size_t, const char *)

int fclose(FILE *)
int fflush(FILE *)
int sscanf(char *str,char *fmt,...)
int sprintf(char *str,char *fmt,...)
int fprintf(FILE *ifile,char *fmt,...)
char *fgets(char *str,int size,FILE *ifile)


cdef extern from "ncls/src/fintervaldb.h":
ctypedef struct IntervalMap:
double start
double end
int target_id
int sublist

ctypedef struct IntervalIterator:
pass

ctypedef struct SublistHeader:
int start
int len

int find_overlap_start(double start, double end, IntervalMap im[], int n)
int imstart_qsort_cmp(void *void_a,void *void_b)
# int target_qsort_cmp(void *void_a,void *void_b)
IntervalMap *read_intervals(int n,FILE *ifile)
SublistHeader *build_nested_list(IntervalMap im[],int n,int *p_n,int *p_nlists)
SublistHeader *build_nested_list_inplace(IntervalMap im[],int n,int *p_n,int *p_nlists)
IntervalMap *interval_map_alloc(int n)
IntervalIterator *interval_iterator_alloc()
int free_interval_iterator(IntervalIterator *it)
IntervalIterator *reset_interval_iterator(IntervalIterator *it)
int *alloc_array(int n)
int find_intervals_stack(int start_stack[], int end_stack[], int sp, int start,
int end, IntervalMap im[], int n,
SublistHeader subheader[], IntervalMap buf[],
int *nfound)

int find_intervals(IntervalIterator *it0,
double start,
double end,
IntervalMap im[],
int n,
SublistHeader subheader[],
int nlists,
IntervalMap buf[],
int nbuf,
int *p_nreturn,
IntervalIterator **it_return)
void find_k_next(int start, int end,
IntervalMap im[], int n,
SublistHeader subheader[], int nlists,
IntervalMap buf[], int ktofind,
int *p_nreturn)
Loading

0 comments on commit 7692e67

Please sign in to comment.