Repository: cogent3/cogent3
Pull request #1685 (2024-01-01 21:55:00)

Maintenance


Patch:
diff --git a/pyproject.toml b/pyproject.toml
index 6bedad592..8029b14de 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -44,7 +44,7 @@ Changelog = "https://github.com/cogent3/cogent3/blob/develop/changelog.md"
 
 [project.optional-dependencies]
 test = [
-    "black==23.12.0",
+    "black==23.12.1",
     "isort==5.13.2",
     "click==8.1.7", # black needs this pinned
     "kaleido",
@@ -81,7 +81,7 @@ doc  = ["click==8.1.7",
         "sphinxcontrib-bibtex",
         "sphinxcontrib-video"]
 extra = ["pandas", "plotly", "psutil", "kaleido"]
-dev = ["black==23.12.0",
+dev = ["black==23.12.1",
        "click==8.1.7",
        "flit",
        "ipykernel",
diff --git a/src/cogent3/core/annotation_db.py b/src/cogent3/core/annotation_db.py
index 641e78ed0..b9013f9b2 100644
--- a/src/cogent3/core/annotation_db.py
+++ b/src/cogent3/core/annotation_db.py
@@ -255,9 +255,6 @@ def _matching_conditions(
     str, tuple
         the SQL statement and the tuple of values
     """
-    # todo this needs to support OR operation on some conditions, e.g. if the value of
-    # a condition is a tuple, do OR
-
     start = conditions.pop("start", None)
     end = conditions.pop("end", None)
 
@@ -666,6 +663,7 @@ class SqliteAnnotationDbMixin:
             columns=columns,
             start=start,
             end=end,
+            allow_partial=allow_partial,
         )
         for result in self._execute_sql(sql, values=vals):
             result = dict(zip(result.keys(), result))
@@ -738,7 +736,7 @@ class SqliteAnnotationDbMixin:
         name: str = None,
         start: int = None,
         end: int = None,
-        strand: bool = None,
+        strand: OptionalStr = None,
         attributes: OptionalStr = None,
         on_alignment: bool = None,
         allow_partial: bool = False,
@@ -762,7 +760,7 @@ class SqliteAnnotationDbMixin:
         name: str = None,
         start: int = None,
         end: int = None,
-        strand: bool = None,
+        strand: OptionalStr = None,
         attributes: OptionalStr = None,
         on_alignment: bool = None,
         allow_partial: bool = False,
@@ -1052,13 +1050,17 @@ class SqliteAnnotationDbMixin:
         biotype: str = None,
         seqid: str = None,
         name: str = None,
-        start: int = None,
-        end: int = None,
-        strand: bool = None,
+        start: OptionalInt = None,
+        end: OptionalInt = None,
+        strand: OptionalStr = None,
         attributes: OptionalStr = None,
         allow_partial: bool = False,
     ) -> typing_extensions.Self:
         """returns a new db instance with records matching the provided conditions"""
+        # make sure python, not numpy, integers
+        start = start if start is None else int(start)
+        end = end if end is None else int(end)
+
         kwargs = {k: v for k, v in locals().items() if k not in {"self", "source"}}
 
         result = self.__class__(source=source)
@@ -1402,8 +1404,8 @@ class GenbankAnnotationDb(SqliteAnnotationDbMixin):
                 column="name",
                 name=name,
                 biotype=biotype,
-                start=int(start),
-                end=int(end),
+                start=start,
+                end=end,
                 allow_partial=False,
             ):
                 if feat["biotype"] == exclude_biotype:
@@ -1447,8 +1449,8 @@ class GenbankAnnotationDb(SqliteAnnotationDbMixin):
                 columns=columns,
                 column="name",
                 name=name,
-                start=int(start),
-                end=int(end),
+                start=start,
+                end=end,
                 allow_partial=False,
             ):
                 # add support for != operation to SQL where clause generation


Test patch:
diff --git a/tests/test_core/test_annotation_db.py b/tests/test_core/test_annotation_db.py
index b2a106921..2eac5427a 100644
--- a/tests/test_core/test_annotation_db.py
+++ b/tests/test_core/test_annotation_db.py
@@ -952,8 +952,11 @@ def test_load_annotations_invalid_path():
         load_annotations(path="invalidfile.gff3")
 
 
-def test_subset_gff3_db(gff_db):
-    subset = gff_db.subset(seqid="I", start=40, end=70, allow_partial=True)
+@pytest.mark.parametrize("integer", (int, numpy.int64))
+def test_subset_gff3_db(gff_db, integer):
+    subset = gff_db.subset(
+        seqid="I", start=integer(40), end=integer(70), allow_partial=True
+    )
     # manual inspection of the original GFF3 file indicates 7 records
     # BUT the CDS records get merged into a single row
     assert len(subset) == 6