Skip to content

Commit

Permalink
Merge branch 'main' into priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Mar 21, 2024
2 parents 25fd49a + 8e9432c commit e5d275f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 46 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/checks.yml → .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
name: Checks
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python3 -m pip install ".[tests]"

- name: Run tests
run: python3 -m pytest tests/
python-lint:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -31,21 +49,3 @@ jobs:
run: rustup component add rustfmt

- run: cargo fmt -- --check
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python3 -m pip install ".[tests]"

- name: Run tests
run: python3 -m pytest tests/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v1.4.0
hooks:
- id: check-added-large-files
- id: detect-private-key
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
rev: v0.2.0
hooks:
- id: ruff-format
- id: ruff
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
[![image](https://img.shields.io/pypi/v/agct.svg)](https://pypi.python.org/pypi/agct)
[![image](https://img.shields.io/pypi/l/agct.svg)](https://pypi.python.org/pypi/agct)
[![image](https://img.shields.io/pypi/pyversions/agct.svg)](https://pypi.python.org/pypi/agct)
[![Actions status](https://github.com/genomicmedlab/agct/workflows/CI/badge.svg)](https://github.com/genomicmedlab/agct/actions)
[![Actions status](https://github.com/genomicmedlab/agct/actions/workflows/checks.yaml/badge.svg)](https://github.com/genomicmedlab/agct/actions/checks.yaml)

<!-- description -->
A drop-in replacement for the [pyliftover](https://github.com/konstantint/pyliftover) tool, using the St. Jude's [chainfile](https://docs.rs/chainfile/latest/chainfile/) crate. Enables significantly faster chainfile loading from cold start (see `analysis/`).
<!-- /description -->
Drop-in replacement for the [pyliftover](https://github.com/konstantint/pyliftover) tool, using the St. Jude's [chainfile](https://docs.rs/chainfile/latest/chainfile/) crate.
<!-- description -->

Enables significantly faster chainfile loading from cold start (see `analysis/`).

## Installation

Expand Down Expand Up @@ -47,16 +49,16 @@ source venv/bin/activate
python3 -m pip install -e '.[dev,tests]'
```

Be sure to install pre-commit hooks:
This installs Python code as editable, but after any changes to Rust code, run ``maturin develop`` to rebuild the Rust binary:

```shell
pre-commit install
maturin develop
```

This installs Python code as editable, but after any changes to Rust code, ``maturin develop`` must be run:
Be sure to install pre-commit hooks:

```shell
maturin develop
pre-commit install
```

Check Python style with `ruff`:
Expand Down
76 changes: 59 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
name = "agct"
version = "0.1.0-dev1"
authors = [
{name = "James Stevenson"}
{name = "James Stevenson"},
{name = "Kori Kuzma"},
]
description = "Another Genome Conversion Tool: Python frontend to Rust chainfile crate"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.8"
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Rust",
Expand All @@ -18,10 +16,14 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
]
requires-python = ">=3.8"
description = "Another Genome Conversion Tool: Python frontend to Rust chainfile crate"
license = {file = "LICENSE"}
dependencies = ["wags-tails"]

[project.optional-dependencies]
Expand All @@ -31,7 +33,7 @@ tests = [
]
dev = [
"maturin",
"ruff>=0.1.12",
"ruff==0.2.0",
"pre-commit",
]

Expand Down Expand Up @@ -60,15 +62,51 @@ branch = true

[tool.ruff]
src = ["src"]
# pycodestyle (E, W)
# Pyflakes (F)
# flake8-annotations (ANN)
# pydocstyle (D)
# pep8-naming (N)
# isort (I)
select = ["E", "W", "F", "ANN", "D", "N", "I"]
fixable = ["I", "F401"]

[tool.ruff.lint]
select = [
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
]
fixable = [
"I",
"F401",
"D",
"UP",
"ANN",
"B",
"C4",
"G",
"PIE",
"PT",
"RSE",
"SIM",
"RUF"
]
# ANN101 - missing-type-self
# ANN003 - missing-type-kwargs
# D203 - one-blank-line-before-class
Expand All @@ -83,16 +121,20 @@ fixable = ["I", "F401"]
# E117 - over-indented*
# E501 - line-too-long*
# W191 - tab-indentation*
# S321 - suspicious-ftp-lib-usage
# *ignored for compatibility with formatter
ignore = [
"ANN101", "ANN003",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191"
"W191",
"S321",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# ANN001 - missing-type-function-argument
# ANN102 - missing-type-cls
# ANN2 - missing-return-type
"tests/*" = ["ANN001", "ANN102", "ANN2"]
# ANN102 - missing-type-cls
# S101 - assert
# B011 - assert-false
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011"]
6 changes: 4 additions & 2 deletions src/agct/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ def __init__(
"""
if not chainfile:
if from_db is None and to_db is None:
raise ValueError("Must provide both `from_db` and `to_db`")
msg = "Must provide both `from_db` and `to_db`"
raise ValueError(msg)

if from_db == to_db:
raise ValueError("Liftover must be to/from different sources.")
msg = "Liftover must be to/from different sources."
raise ValueError(msg)

data_handler = CustomData(
f"chainfile_{from_db.value}_to_{to_db.value}",
Expand Down

0 comments on commit e5d275f

Please sign in to comment.