Skip to content

Commit 0adcfe6

Browse files
authored
GRI v4 (#1)
Greatly simplified!
1 parent 456c0a5 commit 0adcfe6

6 files changed

Lines changed: 247 additions & 343 deletions

File tree

bindings/python/genomicsqlite/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,10 @@ def vacuum_into_sql(conn: sqlite3.Connection, destfile: str, **config) -> None:
7777

7878

7979
def create_genomic_range_index_sql(
80-
conn: sqlite3.Connection,
81-
table: str,
82-
rid: str,
83-
beg: str,
84-
end: str,
85-
max_depth: Optional[int] = None,
80+
conn: sqlite3.Connection, table: str, rid: str, beg: str, end: str, floor: Optional[int] = None,
8681
) -> str:
8782
return _execute1(
88-
conn, "SELECT create_genomic_range_index_sql(?,?,?,?,?)", (table, rid, beg, end, max_depth)
83+
conn, "SELECT create_genomic_range_index_sql(?,?,?,?,?)", (table, rid, beg, end, floor)
8984
)
9085

9186

@@ -95,12 +90,13 @@ def genomic_range_rowids_sql(
9590
qrid: Optional[str] = None,
9691
qbeg: Optional[str] = None,
9792
qend: Optional[str] = None,
98-
safe: bool = False,
93+
ceiling: Optional[int] = None,
94+
floor: Optional[int] = None,
9995
) -> str:
10096
return _execute1(
10197
conn,
102-
f"SELECT genomic_range_rowids_{'safe_' if safe else ''}sql(?,?,?,?)",
103-
(indexed_table, qrid, qbeg, qend),
98+
"SELECT genomic_range_rowids_sql(?,?,?,?,?,?)",
99+
(indexed_table, qrid, qbeg, qend, ceiling, floor),
104100
)
105101

106102

include/genomicsqlite.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include <sqlite3.h>
22

3-
#define GRI_MAX_POS (68719476735LL)
4-
#define GRI_LEVELS (9)
5-
#define GRI_MAX_LEVEL (GRI_LEVELS - 1)
6-
73
/*
84
* C bindings
95
*
@@ -47,7 +43,7 @@ char *genomicsqlite_vacuum_into_sql(const char *destfile, const char *config_jso
4743
* end: column name or simple SQL expression for the interval end position
4844
*/
4945
char *create_genomic_range_index_sql(const char *table, const char *rid, const char *beg,
50-
const char *end, int max_depth);
46+
const char *end, int floor);
5147

5248
/*
5349
* Generate parenthesized SELECT statement to query the existing genomic range index of the
@@ -67,8 +63,8 @@ char *create_genomic_range_index_sql(const char *table, const char *rid, const c
6763
* qbeg: query range begin position; defaults to "?2"
6864
* qend: query range end position; defaults to "?3"
6965
*/
70-
char *genomic_range_rowids_sql(const char *indexed_table, sqlite3 *dbconn, const char *qrid,
71-
const char *qbeg, const char *qend);
66+
char *genomic_range_rowids_sql(sqlite3 *dbconn, const char *indexed_table, const char *qrid,
67+
const char *qbeg, const char *qend, int ceiling, int floor);
7268

7369
/*
7470
* Optional storage of refrence sequence metadata
@@ -108,10 +104,10 @@ std::string GenomicSQLiteVacuumIntoSQL(const std::string &dbfile,
108104

109105
std::string CreateGenomicRangeIndexSQL(const std::string &table, const std::string &rid,
110106
const std::string &beg, const std::string &end,
111-
int max_depth = -1);
112-
std::string GenomicRangeRowidsSQL(const std::string &indexed_table, sqlite3 *dbconn,
107+
int floor = 0);
108+
std::string GenomicRangeRowidsSQL(sqlite3 *dbconn, const std::string &indexed_table,
113109
const std::string &qrid = "?1", const std::string &qbeg = "?2",
114-
const std::string &qend = "?3");
110+
const std::string &qend = "?3", int ceiling = -1, int floor = -1);
115111

116112
std::string PutGenomicReferenceAssemblySQL(const std::string &assembly,
117113
const std::string &attached_schema = "");

0 commit comments

Comments
 (0)