Repository: cogent3/cogent3
Pull request #1531 (2023-07-11 07:31:44)

MAINT: modify param name to match new feature API


Patch:
diff --git a/src/cogent3/core/alignment.py b/src/cogent3/core/alignment.py
index e0d64d090..61a5c2bd2 100644
--- a/src/cogent3/core/alignment.py
+++ b/src/cogent3/core/alignment.py
@@ -61,7 +61,6 @@ from cogent3.core.annotation_db import (
     BasicAnnotationDb,
     FeatureDataType,
     GenbankAnnotationDb,
-    GffAnnotationDb,
     SupportsFeatures,
     load_annotations,
 )
@@ -2295,11 +2294,11 @@ class Aligned:
 
     @extend_docstring_from(Sequence.annotate_matches_to)
     def annotate_matches_to(
-        self, pattern, annot_type, name, allow_multiple=False
+        self, pattern: str, biotype: str, name: str, allow_multiple: bool = False
     ):  # noqa
         return self.data.annotate_matches_to(
             pattern=pattern,
-            annot_type=annot_type,
+            biotype=biotype,
             name=name,
             allow_multiple=allow_multiple,
         )
diff --git a/src/cogent3/core/sequence.py b/src/cogent3/core/sequence.py
index 8c1c4e972..f50fe5d15 100644
--- a/src/cogent3/core/sequence.py
+++ b/src/cogent3/core/sequence.py
@@ -1507,20 +1507,22 @@ class Sequence(SequenceI):
         num = self.annotation_db.num_matches() if self.annotation_db else 0
         return num != 0
 
-    def annotate_matches_to(self, pattern, annot_type, name, allow_multiple=False):
+    def annotate_matches_to(
+        self, pattern: str, biotype: str, name: str, allow_multiple: bool = False
+    ):
         """Adds an annotation at sequence positions matching pattern.
 
         Parameters
         ----------
-        pattern : string
+        pattern
             The search string for which annotations are made. IUPAC ambiguities
             are converted to regex on sequences with the appropriate MolType.
-        annot_type : string
+        biotype
             The type of the annotation (e.g. "domain").
-        name : string
+        name
             The name of the annotation.
-        allow_multiple : boolean
-            If True, allows multiple occurrences of the input pattern. Otherwise
+        allow_multiple
+            If True, allows multiple occurrences of the input pattern. Otherwise,
             only the first match is used.
 
         Returns
@@ -1540,7 +1542,7 @@ class Sequence(SequenceI):
         num_match = len(pos) if allow_multiple else 1
         return [
             self.add_feature(
-                biotype=annot_type,
+                biotype=biotype,
                 name=f"{name}:{i}" if allow_multiple else name,
                 spans=[pos[i]],
             )


Test patch:
diff --git a/tests/test_core/test_alignment.py b/tests/test_core/test_alignment.py
index 1909da254..28864b731 100644
--- a/tests/test_core/test_alignment.py
+++ b/tests/test_core/test_alignment.py
@@ -3166,13 +3166,13 @@ def test_annotate_matches_to():
     seq = aln.named_seqs["x"]
     pattern = "CCRC"
     annot = seq.annotate_matches_to(
-        pattern=pattern, annot_type="domain", name="fred", allow_multiple=True
+        pattern=pattern, biotype="domain", name="fred", allow_multiple=True
     )
     got = [a.get_slice() for a in annot]
     matches = ["CCAC", "CCGC"]
     assert got == matches
     annot = seq.annotate_matches_to(
-        pattern=pattern, annot_type="domain", name="fred", allow_multiple=False
+        pattern=pattern, biotype="domain", name="fred", allow_multiple=False
     )
     got = [a.get_slice() for a in annot]
     assert got == matches[:1]
diff --git a/tests/test_core/test_features.py b/tests/test_core/test_features.py
index 22d0cd11a..cbe7e8895 100755
--- a/tests/test_core/test_features.py
+++ b/tests/test_core/test_features.py
@@ -75,11 +75,11 @@ class FeaturesTest(TestCase):
         seq = DNA.make_seq("TTCCACTTCCGCTT", name="x")
         pattern = "CCRC"
         annot = seq.annotate_matches_to(
-            pattern=pattern, annot_type="domain", name="fred", allow_multiple=True
+            pattern=pattern, biotype="domain", name="fred", allow_multiple=True
         )
         self.assertEqual([a.get_slice() for a in annot], ["CCAC", "CCGC"])
         annot = seq.annotate_matches_to(
-            pattern=pattern, annot_type="domain", name="fred", allow_multiple=False
+            pattern=pattern, biotype="domain", name="fred", allow_multiple=False
         )
         self.assertEqual(len(annot), 1)
         fred = annot[0].get_slice()
@@ -88,7 +88,7 @@ class FeaturesTest(TestCase):
         # should return an empty annotation.
         seq = ASCII.make_seq(seq="TTCCACTTCCGCTT")
         annot = seq.annotate_matches_to(
-            pattern=pattern, annot_type="domain", name="fred", allow_multiple=False
+            pattern=pattern, biotype="domain", name="fred", allow_multiple=False
         )
         self.assertEqual(annot, [])