Skip to content

Commit

Permalink
fix tests for trim method
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Nov 13, 2023
1 parent 5c5968a commit 22ffd22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ package_dir =
install_requires =
importlib-metadata; python_version<"3.8"
pandas
biocframe>=0.3.16
biocframe==0.3.16
numpy
biocgenerics
biocutils
biocutils>=0.1.1

[options.packages.find]
where = src
Expand Down
20 changes: 7 additions & 13 deletions src/genomicranges/GenomicRanges.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import math
import random
from collections import OrderedDict
from typing import (
Any,
Callable,
Dict,
List,
Literal,
Optional,
Union,
)
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Union
from warnings import warn

from biocframe import BiocFrame
from biocframe.types import SlicerArgTypes
from biocgenerics.colnames import colnames, set_colnames
from biocgenerics.combine import combine
from biocgenerics.combine_cols import combine_cols
Expand Down Expand Up @@ -477,7 +468,9 @@ def __repr__(self) -> str:
return capture.get()

# for documentation, otherwise serves no real use.
def __getitem__(self, args: SlicerArgTypes) -> Union["GenomicRanges", dict, list]:
def __getitem__(
self, args: Union[int, str, Sequence, tuple]
) -> Union["GenomicRanges", dict, list]:
"""Subset the object.
This operation returns a new object with the same type as the caller.
Expand Down Expand Up @@ -904,10 +897,11 @@ def trim(self) -> "GenomicRanges":
for idx in range(len(all_chrs)):
keep = True
t_chr = all_chrs[idx]
s_idx = seqinfos.seqnames.index(t_chr)
if (
is_circular is not None
and is_circular[t_chr] is False
and all_ends[idx] > seqlengths[t_chr]
and is_circular[s_idx] is False
and all_ends[idx] > seqlengths[s_idx]
):
keep = False

Expand Down
8 changes: 4 additions & 4 deletions src/genomicranges/SeqInfo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List, Optional, Union, Sequence
import biocutils as bu
from typing import Dict, List, Optional, Sequence, Union
from warnings import warn

import biocutils as bu

__author__ = "jkanche"
__copyright__ = "jkanche"
Expand Down Expand Up @@ -112,8 +112,8 @@ def _validate_seqlengths(self):
raise ValueError("'seqlengths' should be a list of integers")
if n != len(self._seqlengths):
raise ValueError("'seqnames' and 'seqlengths' should have the same length")
for l in self._seqlengths:
if l is not None and l < 0:
for sl in self._seqlengths:
if sl is not None and sl < 0:
raise ValueError("all entries of 'seqlengths' should be non-negative")

def _validate_is_circular(self):
Expand Down

0 comments on commit 22ffd22

Please sign in to comment.