Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
sudo apt-get -qq update
sudo apt-get install -y clang-format cppcheck python3-pip python3-venv
python3 -m venv "$HOME/.lint-venv"
"$HOME/.lint-venv/bin/pip" install pre-commit $PIP_DEPS black flake8 pylint
"$HOME/.lint-venv/bin/pip" install pre-commit $PIP_DEPS ruff
echo "$HOME/.lint-venv/bin" >> "$GITHUB_PATH"
- name: pre-commit
run: pre-commit run --all-files
Expand Down
28 changes: 7 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,12 @@ repos:
verbose: true
entry: cppcheck
args: [-q,--std=c++11]
- id: black
name: black
language: system
files: \.py$
verbose: true
entry: black
args: [-l,'100']
- id: flake8
name: flake8
language: system
files: \.py$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.1
hooks:
- id: ruff-check
name: ruff-check
verbose: true
entry: flake8
args: [--max-line-length, "100", "--ignore=E501,W503,E722"]
- id: pylint
name: pylint
language: system
files: \.py$
exclude: version\.py
- id: ruff-format
name: ruff-format
verbose: true
entry: env PYTHONPATH=bindings/python pylint
args: [-d, "global-statement,missing-docstring,missing-module-docstring,line-too-long,too-many-arguments,too-many-positional-arguments,duplicate-code,redefined-outer-name,too-many-locals,bare-except,broad-except,import-outside-toplevel,protected-access,too-many-statements,too-many-branches,unspecified-encoding"]
# CI re-run trigger 2026-10-19 (run 39294337754 lost its macOS runner to GitHub capacity)
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
FROM almalinux:8 as builder

ARG CMAKE_VERSION=3.17.3
ARG SQLITE_VERSION=3410200
ARG SQLITE_VERSION=3540100
ARG ZSTD_VERSION=1.5.5
ARG CPU_ARCH=ivybridge
ENV CFLAGS="-march=${CPU_ARCH} -O3"
Expand Down Expand Up @@ -34,7 +34,7 @@ RUN mkdir -p /work/GenomicSQLite

# SQLite
WORKDIR /work
RUN wget -nv http://www.sqlite.org/2023/sqlite-amalgamation-${SQLITE_VERSION}.zip \
RUN wget -nv http://www.sqlite.org/2026/sqlite-amalgamation-${SQLITE_VERSION}.zip \
&& unzip -o sqlite-amalgamation-${SQLITE_VERSION}.zip
WORKDIR /work/sqlite-amalgamation-${SQLITE_VERSION}
RUN bash -c "gcc -shared -o libsqlite3.so.0 -fPIC -shared -Wl,-soname,libsqlite3.so.0 -g ${CFLAGS} ${SQLITE_CFLAGS} sqlite3.c & pid=$? \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cmake --build build -j 4 --target genomicsqlite

* htslib ≥ 1.9, samtools, and tabix
* pigz
* Python ≥ 3.6 and packages: pytest pytest-xdist pre-commit black pylint flake8
* Python ≥ 3.6 and packages: pytest pytest-xdist pre-commit ruff
* JDK, mvn, rust
* clang-format & cppcheck

Expand Down
20 changes: 10 additions & 10 deletions bindings/jdbc/genomicsqlite-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -72,44 +72,44 @@
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<version>3.5.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.5.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.16.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.6.0</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.5.1</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.2.0</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<version>3.22.0</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<version>3.9.0</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
Expand Down
24 changes: 11 additions & 13 deletions bindings/python/genomicsqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
GenomicSQLite Python binding
"""

import json
import os
import sys
import platform
import json
import sqlite3
from typing import Optional, NamedTuple, Dict, Any
import sys
from typing import Any, Dict, NamedTuple, Optional

_HERE = os.path.dirname(__file__)
_YES = ("1", "true", "t", "yes", "y")
Expand Down Expand Up @@ -182,9 +182,9 @@ def get_reference_sequences_by_rid(
params = (assembly,)
ans = {}
for row in con.execute(sql, params):
assert (
isinstance(row[0], int) and row[0] not in ans
), "genomicsqlite: invalid or duplicate reference sequence rid"
assert isinstance(row[0], int) and row[0] not in ans, (
"genomicsqlite: invalid or duplicate reference sequence rid"
)
ans[row[0]] = ReferenceSequence(
rid=row[0],
name=row[1],
Expand All @@ -200,7 +200,7 @@ def get_reference_sequences_by_name(
con: sqlite3.Connection, assembly: Optional[str] = None, schema: Optional[str] = None
) -> Dict[str, ReferenceSequence]:
ans = {}
for _, item in get_reference_sequences_by_rid(con, assembly, schema).items():
for item in get_reference_sequences_by_rid(con, assembly, schema).values():
assert item.name not in ans, "genomicsqlite: non-unique reference sequence names"
ans[item.name] = item
return ans
Expand Down Expand Up @@ -333,12 +333,10 @@ def _cli(argv=None):
print(
" ".join(
(
(
(arg if " " not in arg else f"'{arg}'")
+ (" \\\n " if len(arg) > 50 else "")
)
for arg in cmd
(arg if " " not in arg else f"'{arg}'")
+ (" \\\n " if len(arg) > 50 else "")
)
for arg in cmd
)
)
os.execvp("sqlite3", cmd)
Expand Down Expand Up @@ -403,7 +401,7 @@ def _compact(dbfilename, argv):

# sniff whether input db is currently compressed with zstd_vfs or not
con = None
web = dbfilename.startswith("http:") or dbfilename.startswith("https:")
web = dbfilename.startswith(("http:", "https:"))
if not web:
con = sqlite3.connect(f"file:{urllib.parse.quote(dbfilename)}?mode=ro", uri=True)
if next(con.execute("PRAGMA application_id"))[0] != 0x7A737464:
Expand Down
1 change: 1 addition & 0 deletions bindings/python/genomicsqlite/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from . import _cli

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from os import path
from setuptools import setup, find_packages # pylint: disable=import-error

from setuptools import find_packages, setup # pylint: disable=import-error
from version import get_version

HERE = path.abspath(path.dirname(__file__))
Expand Down
6 changes: 2 additions & 4 deletions bindings/python/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def read_git_version():
return None
match = re.search(_GIT_DESCRIPTION_RE, ver)
if not match:
sys.stderr.write("version: git description (%s) is invalid, " "ignoring\n" % ver)
sys.stderr.write("version: git description (%s) is invalid, ignoring\n" % ver)
return None

commits = int(match.group("commits"))
Expand All @@ -90,9 +90,7 @@ def read_release_version():
with open(RELEASE_VERSION_FILE) as infile:
ver = infile.readline().strip()
if not re.search(_PEP386_VERSION_RE, ver):
sys.stderr.write(
"version: release version (%s) is invalid, " "will use it anyway\n" % ver
)
sys.stderr.write("version: release version (%s) is invalid, will use it anyway\n" % ver)
return ver
except:
return None
Expand Down
6 changes: 3 additions & 3 deletions docs/guide_db.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ First complete the [installation instructions](index.md).
=== "Python"
``` python3
dbconn = genomicsqlite.connect(
db_filename,
read_only=False,
**kwargs # genomicsqlite + sqlite3.connect() arguments
db_filename,
read_only=False,
**kwargs, # genomicsqlite + sqlite3.connect() arguments
)
assert isinstance(dbconn, sqlite3.Connection)
```
Expand Down
42 changes: 20 additions & 22 deletions docs/guide_gri.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ The extension provides routines to populate a small `_gri_refseq` table describi
=== "Python"
``` python3
create_gri_sql = genomicsqlite.create_genomic_range_index_sql(
dbconn,
'tableName',
'chromosome',
'beginPosition',
'endPosition'
dbconn, "tableName", "chromosome", "beginPosition", "endPosition"
)
dbconn.executescript(create_gri_sql)
```
Expand Down Expand Up @@ -229,9 +225,7 @@ The following routines support the aforementioned, recommended convention for st

=== "Python"
``` python3
refseq_sql = genomicsqlite.put_reference_assembly_sql(
dbconn, 'GRCh38_no_alt_analysis_set'
)
refseq_sql = genomicsqlite.put_reference_assembly_sql(dbconn, "GRCh38_no_alt_analysis_set")
dbconn.executescript(refseq_sql)
```

Expand Down Expand Up @@ -307,8 +301,10 @@ Available assemblies:
=== "Python"
``` python3
refseq_sql = genomicsqlite.put_reference_sequence_sql(
dbconn, 'chr17', 83257441
# optional: assembly, refget_id, meta (dict), rid
dbconn,
"chr17",
83257441,
# optional: assembly, refget_id, meta (dict), rid
)
dbconn.executescript(refseq_sql)
```
Expand Down Expand Up @@ -407,12 +403,13 @@ If the `rid` argument is omitted or -1 then it will be assigned automatically up
=== "Python"
``` python3
class ReferenceSequence(NamedTuple):
rid: int
name: str
length: int
assembly: Optional[str]
refget_id: Optional[str]
meta: Dict[str, Any]
rid: int
name: str
length: int
assembly: Optional[str]
refget_id: Optional[str]
meta: Dict[str, Any]


refseq_by_rid = genomicsqlite.get_reference_sequences_by_rid(dbconn)
# refseq_by_rid: Dict[int, ReferenceSequence]
Expand Down Expand Up @@ -492,12 +489,13 @@ The optional `assembly` argument restricts the retrieved sequences to those with
=== "Python"
``` python3
class ReferenceSequence(NamedTuple):
rid: int
name: str
length: int
assembly: Optional[str]
refget_id: Optional[str]
meta: Dict[str, Any]
rid: int
name: str
length: int
assembly: Optional[str]
refget_id: Optional[str]
meta: Dict[str, Any]


refseq_by_name = genomicsqlite.get_reference_sequences_by_name(dbconn)
# refseq_by_name: Dict[str, ReferenceSequence]
Expand Down
10 changes: 5 additions & 5 deletions docs/guide_helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ The [UINT collating sequence](https://www.sqlite.org/uintcseq.html) is also bund

=== "Python"
``` python3
dbconn = sqlite3.connect('any.db', uri=True)
attach_sql = genomicsqlite.attach_sql(dbconn, 'compressed.db', 'db2')
dbconn = sqlite3.connect("any.db", uri=True)
attach_sql = genomicsqlite.attach_sql(dbconn, "compressed.db", "db2")
# attach_sql() also takes configuration keyword arguments like
# genomicsqlite.connect()
dbconn.executescript(attach_sql)
Expand Down Expand Up @@ -190,13 +190,13 @@ The [UINT collating sequence](https://www.sqlite.org/uintcseq.html) is also bund

=== "Python"
``` python3
dbconn = sqlite3.connect('existing.db', uri=True)
vacuum_sql = genomicsqlite.vacuum_into_sql(dbconn, 'compressed.db')
dbconn = sqlite3.connect("existing.db", uri=True)
vacuum_sql = genomicsqlite.vacuum_into_sql(dbconn, "compressed.db")
# vacuum_into_sql() also takes configuration keyword arguments like
# genomicsqlite.connect() to control compression level & page sizes

dbconn.executescript(vacuum_sql)
dbconn2 = genomicsqlite.connect('compressed.db')
dbconn2 = genomicsqlite.connect("compressed.db")
```

=== "Java"
Expand Down
18 changes: 12 additions & 6 deletions docs/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ The extension also exposes the routine to generate the SQL subquery, which you c
=== "Python"
``` python3
query = (
'SELECT * FROM tableName WHERE tableName._rowid_ IN ' +
genomicsqlite.genomic_range_rowids_sql(dbconn, 'tableName',
# defaults:
qrid='?1', qbeg='?2', qend='?3',
ceiling=-1, floor=-1)
"SELECT * FROM tableName WHERE tableName._rowid_ IN "
+ genomicsqlite.genomic_range_rowids_sql(
dbconn,
"tableName",
# defaults:
qrid="?1",
qbeg="?2",
qend="?3",
ceiling=-1,
floor=-1,
)
)
cursor = dbconn.execute(query, ('chr12',111803912,111804012))
cursor = dbconn.execute(query, ("chr12", 111803912, 111804012))
```

=== "SQLiteCpp"
Expand Down
16 changes: 16 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ruff: run on ruff's own defaults (project lint policy, 2026-10-20).
# Opt out of specific rules only where warranted; each opt-out is documented
# inline. No rule sets are selected or opted into.
line-length = 100 # exception to the ruff default (88): matches this codebase's black -l 100 formatting; avoids a whole-tree reformat

[lint]
ignore = [
"E722", # bare except: deliberate bare-except uses in this codebase, carried from the flake8 era
"UP006", # non-pep585-annotation: binding annotations are evaluated at runtime; package declares python_requires>=3.6
"UP045", # non-pep604-annotation-optional: same runtime-annotation / python>=3.6 constraint as UP006
"UP035", # deprecated-import: typing.Dict/Optional etc. retained for the same python>=3.6 annotation constraint
"UP031", # printf-string-formatting: fires only in vendored bindings/python/version.py (third-party, public domain), not hand-edited
"UP009", # utf8-encoding-declaration: fires only in vendored bindings/python/version.py, not hand-edited
"PLE0605", # invalid-all-format: fires only in vendored bindings/python/version.py, not hand-edited
"BLE001", # blind-except: smoke-test harness deliberately catches broad exceptions to degrade gracefully
]
Loading
Loading