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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.6
rev: v0.16.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def build_cmake(self, ext):
ext_modules=[CMakeExtension("biostrings")],
cmdclass={"build_ext": build_ext},
)
except: # noqa
except:
print(
"\n\nAn error occurred while building the project, "
"please ensure you have the most updated version of setuptools, "
Expand Down
8 changes: 4 additions & 4 deletions src/biostrings/dnastring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re
from copy import deepcopy
from typing import Any, Dict, Optional, Union
from typing import Any

import biocutils as ut

Expand Down Expand Up @@ -34,8 +34,8 @@ class DNAString(ut.BiocObject):

def __init__(
self,
sequence: Union[str, bytes],
metadata: Optional[Union[Dict[str, Any], ut.NamedList]] = None,
sequence: str | bytes,
metadata: dict[str, Any] | ut.NamedList | None = None,
_validate: bool = True,
):
"""Create a DNAString.
Expand Down Expand Up @@ -145,7 +145,7 @@ def __eq__(self, other) -> bool:
#### Getitem/setitem ####
#########################

def __getitem__(self, key: Union[int, slice]) -> DNAString:
def __getitem__(self, key: int | slice) -> DNAString:
"""Extract a subsequence (slicing).

Args:
Expand Down
24 changes: 12 additions & 12 deletions src/biostrings/dnastringset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from copy import deepcopy
from typing import Any, Dict, List, Optional, Union
from typing import Any
from warnings import warn

import biocutils as ut
Expand Down Expand Up @@ -36,11 +36,11 @@ class DNAStringSet(ut.BiocObject):

def __init__(
self,
sequences: Optional[List[str]] = None,
names: Optional[Union[List[str], ut.Names]] = None,
_pool: Optional[bytes] = None,
_ranges: Optional[IRanges] = None,
metadata: Optional[Union[Dict[str, Any], ut.NamedList]] = None,
sequences: list[str] | None = None,
names: list[str] | ut.Names | None = None,
_pool: bytes | None = None,
_ranges: IRanges | None = None,
metadata: dict[str, Any] | ut.NamedList | None = None,
_validate: bool = True,
):
"""Create a DNAStringSet.
Expand Down Expand Up @@ -141,7 +141,7 @@ def __deepcopy__(self, memo) -> DNAStringSet:
#### Getter/setters ####
########################

def get_names(self) -> Optional[ut.Names]:
def get_names(self) -> ut.Names | None:
"""Get range names.

Returns:
Expand All @@ -150,7 +150,7 @@ def get_names(self) -> Optional[ut.Names]:
"""
return self._ranges.get_names()

def set_names(self, names: Optional[List[str]], in_place: bool = False) -> DNAStringSet:
def set_names(self, names: list[str] | None, in_place: bool = False) -> DNAStringSet:
"""
Args:
names:
Expand All @@ -169,12 +169,12 @@ def set_names(self, names: Optional[List[str]], in_place: bool = False) -> DNASt
return output

@property
def names(self) -> Optional[ut.Names]:
def names(self) -> ut.Names | None:
"""Return the names of the sequences."""
return self._ranges.get_names()

@names.setter
def names(self, new_names: List[str]):
def names(self, new_names: list[str]):
"""Set the names of the sequences."""
warn(
"Setting property 'names' is an in-place operation, use 'set_names' instead",
Expand Down Expand Up @@ -251,7 +251,7 @@ def width(self) -> np.ndarray:
"""Alias to :py:meth:`~.get_width`."""
return self.get_width()

def __getitem__(self, key: Union[int, slice, List[int], np.ndarray]) -> Union[DNAString, DNAStringSet]:
def __getitem__(self, key: int | slice | list[int] | np.ndarray) -> DNAString | DNAStringSet:
"""Extract one or more sequences.

Args:
Expand All @@ -278,7 +278,7 @@ def __getitem__(self, key: Union[int, slice, List[int], np.ndarray]) -> Union[DN
else:
raise TypeError(f"Index must be int, slice, or list, not {type(key)}")

def to_list(self) -> List[str]:
def to_list(self) -> list[str]:
"""Convert the set to a list of Python strings."""
output = []
for i in range(len(self._ranges)):
Expand Down
1 change: 0 additions & 1 deletion tests/test_dnastring.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def test_reverse_complement_simple():


def test_reverse_complement_iupac():
#
dna = DNAString("ACGTRYSWKMBDHVN-")
rc = dna.reverse_complement()
# From our complement table
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dnastringset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def sample_seqs():
"ACGT",
"GATTACA",
"",
"TTGAAAA-CTC-N", #
"TTGAAAA-CTC-N",
"ACGTACGT",
],
"names": ["seq1", "seq2", "empty", "iupac", "seq5"],
Expand Down
Loading