Skip to content

Update to numpy v2 #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-cov coveralls
pip install -r requirements.txt
pip install .
pip install -e ".[dev]"
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -49,6 +47,6 @@ jobs:
pyensembl install --release 93 --species mouse --custom-mirror https://github.com/openvax/ensembl-data/releases/download/GRCm38.93/
- name: Run unit tests
run: |
./test.sh
pytest --cov=pyensembl/ --cov-report=term-missing tests/
- name: Publish coverage to Coveralls
uses: coverallsapp/github-action@v2.2.3
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cursor
.cursor/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<img src="https://img.shields.io/pypi/v/pyensembl.svg?maxAge=1000" alt="PyPI" />
</a>

# PyEnsembl
PyEnsembl
=========

PyEnsembl is a Python interface to [Ensembl](http://www.ensembl.org) reference genome metadata such as exons and transcripts. PyEnsembl downloads [GTF](https://en.wikipedia.org/wiki/Gene_transfer_format) and [FASTA](https://en.wikipedia.org/wiki/FASTA_format) files from the [Ensembl FTP server](ftp://ftp.ensembl.org) and loads them into a local database. PyEnsembl can also work with custom reference data specified using user-supplied GTF and FASTA files.

Expand Down Expand Up @@ -138,6 +139,60 @@ data.index()
gene_names = data.gene_names_at_locus(contig=6, position=29945884)
```

# Development and Testing

## Installation for Development

To install PyEnsembl for development with testing dependencies:

```sh
pip install -e ".[dev]"
```

This installs PyEnsembl in editable mode along with development dependencies including `pytest`, `pytest-cov`, `flake8`, and `coveralls`.

## Running Tests

PyEnsembl uses pytest for testing. Before running tests, you'll need to install some Ensembl data:

```sh
# Install required Ensembl releases for testing
pyensembl install --release 75 --species human \
&& pyensembl install --release 77 --species human \
&& pyensembl install --release 93 --species human \
&& pyensembl install --release 111 --species homo_sapiens
```

### Run all tests:

```sh
pytest tests/
```

### Run tests with coverage:

```sh
pytest --cov=pyensembl/ --cov-report=term-missing tests/
```

### Run a specific test file:

```sh
pytest tests/test_gene_names.py
```

### Run a specific test function:

```sh
pytest tests/test_gene_names.py::test_all_gene_names
```

### Run tests with verbose output:

```sh
pytest -v tests/
```

# API

The `EnsemblRelease` object has methods to let you access all possible
Expand Down
10 changes: 10 additions & 0 deletions pyensembl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""pyensembl public API and compatibility helpers."""

import numpy as np

# ``numpy.typeDict`` was removed in NumPy 2.0. Some of ``pyensembl``'s
# dependencies still rely on this old attribute, so provide it when
# running under newer versions of NumPy.
if not hasattr(np, "typeDict"):
np.typeDict = np.sctypeDict

from .database import Database
from .download_cache import DownloadCache
from .ensembl_release import EnsemblRelease, cached_release
Expand Down
9 changes: 7 additions & 2 deletions pyensembl/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@

import argparse
import logging.config
import pkg_resources
try:
from importlib import resources as importlib_resources
except ImportError: # pragma: no cover - Python <3.9 fallback
import importlib_resources # type: ignore
import os

from .ensembl_release import EnsemblRelease
Expand All @@ -49,7 +52,9 @@
from .species import Species
from .version import __version__

logging.config.fileConfig(pkg_resources.resource_filename(__name__, "logging.conf"))
logging.config.fileConfig(
importlib_resources.files(__package__).joinpath("logging.conf")
)
logger = logging.getLogger(__name__)


Expand Down
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pyensembl"
dynamic = ["version"]
description = "Python interface to Ensembl reference genome metadata"
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [{name = "Alex Rubinsteyn", email = "alex.rubinsteyn@unc.edu"}]
keywords = ["ensembl", "genomics", "bioinformatics"]

dependencies = [
"typechecks>=0.0.2,<1.0.0",
"datacache>=1.4.0,<2.0.0",
"memoized-property>=1.0.2",
"tinytimer>=0.0.0,<1.0.0",
#"gtfparse>=2.5.0",
"gtfparse @ git+https://github.com/nick-youngblut/gtfparse.git@pyarrow_update",
"serializable>=0.2.1,<1.0.0",
"pyarrow>=16.0.0",
"pandas>=2.0.0",
]

[project.optional-dependencies]
dev = [
"pytest>=6.0",
"pytest-cov>=2.0",
"flake8>=3.8",
"coveralls>=3.0",
]

[project.urls]
Homepage = "https://github.com/openvax/pyensembl"
Source = "https://github.com/openvax/pyensembl"

[project.scripts]
pyensembl = "pyensembl.shell:run"

[tool.setuptools.packages.find]
where = ["."]
include = ["pyensembl*"]

[tool.setuptools.package-data]
pyensembl = ["logging.conf"]

[tool.setuptools.dynamic]
version = {attr = "pyensembl.version.__version__"}
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

74 changes: 0 additions & 74 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion test.sh

This file was deleted.