Skip to content

Commit

Permalink
build: update build for biobear (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
tshauck authored Dec 19, 2023
1 parent f677325 commit 2f113dd
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 69 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ crate-type = ["cdylib"]
name = "biobear"

[dependencies]
arrow = {version = "48.0.1", features = ["pyarrow"]}
datafusion = "33"
exon = {version = "0.5.3", features = ["all"]}
arrow = {version = "49.0.0", features = ["pyarrow"]}
datafusion = "34"
exon = {version = "0.5.5", features = ["all"]}
pyo3 = "0.20"
thiserror = "1.0"
tokio = {version = "1", features = ["rt"]}
Expand Down
2 changes: 2 additions & 0 deletions python/biobear/bam_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import pyarrow as pa

from biobear.reader import Reader
from biobear.deprecated import deprecated
from .biobear import _BamIndexedReader, _ExonReader


@deprecated
class BamReader(Reader):
"""A BAM File Reader."""

Expand Down
3 changes: 3 additions & 0 deletions python/biobear/bcf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@


from biobear.reader import Reader
from biobear.deprecated import deprecated

from .biobear import _ExonReader, _BCFIndexedReader


@deprecated
class BCFReader(Reader):
"""A BCF File Reader.
Expand All @@ -46,6 +48,7 @@ def inner(self):
return self._bcf_reader


@deprecated
class BCFIndexedReader(Reader):
"""An Indexed BCF File Reader.
Expand Down
32 changes: 32 additions & 0 deletions python/biobear/deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 WHERE TRUE Technologies.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
import functools


def deprecated(cls):
orig_init = cls.__init__

@functools.wraps(orig_init)
def new_init(self, *args, **kwargs):
warnings.warn(
f"{cls.__name__} is deprecated, use a table function via the session",
category=DeprecationWarning,
stacklevel=2,
)
orig_init(self, *args, **kwargs)

cls.__init__ = new_init
return cls
2 changes: 2 additions & 0 deletions python/biobear/fasta_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

from biobear.reader import Reader
from biobear.compression import Compression
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class FastaReader(Reader):
"""FASTA file reader."""

Expand Down
2 changes: 2 additions & 0 deletions python/biobear/fastq_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

from biobear.reader import Reader
from biobear.compression import Compression
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class FastqReader(Reader):
"""FASTQ file reader."""

Expand Down
2 changes: 2 additions & 0 deletions python/biobear/genbank_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

from biobear.reader import Reader
from biobear.compression import Compression
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class GenbankReader(Reader):
"""Genbank file reader."""

Expand Down
2 changes: 2 additions & 0 deletions python/biobear/gff_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

from biobear.compression import Compression
from biobear.reader import Reader
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class GFFReader(Reader):
"""A GFF File Reader."""

Expand Down
2 changes: 2 additions & 0 deletions python/biobear/gtf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

from biobear.compression import Compression
from biobear.reader import Reader
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class GTFReader(Reader):
"""A GTF File Reader."""

Expand Down
2 changes: 2 additions & 0 deletions python/biobear/mzml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

from biobear.compression import Compression
from biobear.reader import Reader
from biobear.deprecated import deprecated

from .biobear import _ExonReader


@deprecated
class MzMLReader(Reader):
"""A MzML File Reader."""

Expand Down
3 changes: 3 additions & 0 deletions python/biobear/vcf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
import pyarrow as pa

from biobear.reader import Reader
from biobear.deprecated import deprecated

from .biobear import _ExonReader, _VCFIndexedReader


@deprecated
class VCFReader(Reader):
"""A VCF File Reader.
Expand All @@ -44,6 +46,7 @@ def inner(self):
return self._vcf_reader


@deprecated
class VCFIndexedReader(Reader):
"""An Indexed VCF File Reader.
Expand Down
10 changes: 0 additions & 10 deletions python/tests/test_bam_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,8 @@ def test_bam_reader_to_pandas():
assert len(df) == 61


def test_bam_reader_no_file():
with pytest.raises(OSError):
BamReader("test.bam")


def test_bam_indexed_reader():
reader = BamIndexedReader(DATA / "bedcov.bam")
rbr = reader.query("chr1:12203700-12205426")

assert 1 == sum(b.num_rows for b in rbr)


def test_bam_indexed_reader_no_file():
with pytest.raises(OSError):
BamIndexedReader("test.bam")
6 changes: 0 additions & 6 deletions python/tests/test_bcf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ def test_bcf_reader_to_pandas():
assert len(df) == 621


def test_bcf_reader_missing_file():
"""Test the BCFReader with a missing file."""
with pytest.raises(OSError):
BCFReader("test.bcf")


def test_bcf_indexed_reader_query():
"""Test the BCFIndexedReader.query() method."""
reader = BCFIndexedReader(DATA / "index.bcf")
Expand Down
5 changes: 0 additions & 5 deletions python/tests/test_fasta_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ def test_fasta_reader_to_arrow():
assert arrow_reader.read_all().num_rows == 2


def test_fasta_reader_no_file():
with pytest.raises(OSError):
FastaReader("test.fasta")


@pytest.mark.skipif(
not importlib.util.find_spec("polars"), reason="polars not installed"
)
Expand Down
5 changes: 0 additions & 5 deletions python/tests/test_fastq_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,3 @@ def test_to_arrow_scanner():
scanner = gzipped_fastq_reader.to_arrow_scanner()

assert scanner.count_rows() == 2


def test_fastq_reader_no_file():
with pytest.raises(OSError):
FastqReader("test.fastq")
5 changes: 0 additions & 5 deletions python/tests/test_genbank_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,3 @@ def test_genbank_reader_to_pandas():
df = reader.to_pandas()

assert len(df) == 1


def test_genbank_missing_file():
with pytest.raises(OSError):
GenbankReader(DATA / "missing.gbk")
10 changes: 0 additions & 10 deletions python/tests/test_gff_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ def test_gff_reader_to_scanner():
assert scanner.count_rows() == 2


def test_gff_reader_no_file():
with pytest.raises(OSError):
GFFReader("")


@pytest.mark.skipif(
not importlib.util.find_spec("polars"), reason="polars not installed"
)
Expand All @@ -72,8 +67,3 @@ def test_gff_reader_gz_to_scanner():
scanner = reader.to_arrow_scanner()

assert scanner.count_rows() == 2


def test_gff_gz_no_file():
with pytest.raises(OSError):
GFFReader("test.gff.gz")
10 changes: 0 additions & 10 deletions python/tests/test_gtf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ def test_gtf_reader_to_scanner():
assert scanner.count_rows() == 77


def test_gtf_reader_no_file():
with pytest.raises(OSError):
GTFReader("test.gtf")


@pytest.mark.skipif(
not importlib.util.find_spec("polars"), reason="polars not installed"
)
Expand All @@ -73,8 +68,3 @@ def test_gtf_reader_gz_to_scanner():
scanner = reader.to_arrow_scanner()

assert scanner.count_rows() == 77


def test_gtf_gz_no_file():
with pytest.raises(OSError):
GTFReader("test.gtf.gz")
10 changes: 0 additions & 10 deletions python/tests/test_mzml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ def test_mzml_reader_to_scanner():
assert scanner.count_rows() == 2


def test_mzml_reader_no_file():
with pytest.raises(OSError):
MzMLReader("test.mzML")


@pytest.mark.skipif(
not importlib.util.find_spec("polars"), reason="polars not installed"
)
Expand All @@ -57,8 +52,3 @@ def test_mzml_reader_gz_to_scanner():
scanner = reader.to_arrow_scanner()

assert scanner.count_rows() == 2


def test_mzml_gz_no_file():
with pytest.raises(OSError):
MzMLReader("test.mzML.gz")
5 changes: 0 additions & 5 deletions python/tests/test_vcf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ def test_vcf_reader_to_pandas():
assert len(df) == 15


def test_vcf_reader_missing_file():
with pytest.raises(OSError):
VCFReader("test.vcf")


def test_vcf_indexed_reader_query():
reader = VCFIndexedReader(DATA / "vcf_file.vcf.gz")
rbr = reader.query("1")
Expand Down

0 comments on commit 2f113dd

Please sign in to comment.