Skip to content
Merged
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
24 changes: 0 additions & 24 deletions .github/workflows/black.yml

This file was deleted.

32 changes: 16 additions & 16 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ name: Push docs
on:
push:
branches:
- main
- documentation
- main
- documentation

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x

- name: Install font
run: |
cd /usr/share/fonts
wget https://github.com/JulietaUla/Montserrat/archive/refs/tags/v7.222.tar.gz
tar -xvzf v7.222.tar.gz
sudo chmod -R --reference=/usr/share/fonts/truetype Montserrat-7.222
sudo fc-cache -fv
fc-match Montserrat
- name: Install font
run: |
cd /usr/share/fonts
wget https://github.com/JulietaUla/Montserrat/archive/refs/tags/v7.222.tar.gz
tar -xvzf v7.222.tar.gz
sudo chmod -R --reference=/usr/share/fonts/truetype Montserrat-7.222
sudo fc-cache -fv
fc-match Montserrat

- run: pip install ".[docs]"
- run: mkdocs gh-deploy --force
- run: pip install ".[docs]"
- run: mkdocs gh-deploy --force
36 changes: 18 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: PyPI
name: Publish to PyPI

on:
release:
Expand All @@ -10,21 +7,24 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest

environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
- name: Checkout project
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python-version-file: pyproject.toml

- name: Build
run: |
python -m build --sdist --wheel .
twine upload dist/*
uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
62 changes: 36 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,55 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: tests
name: Lint and Test

on:
push:
branches: [ master ]
branches: [main]
pull_request:
branches: [ master ]
schedule:
- cron: "0 0 1 1/1 *" # Run monthly
branches: [main]

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files

- name: Check Linting
uses: astral-sh/ruff-action@v3

- name: Check Formatting
uses: astral-sh/ruff-action@v3
with:
args: format --check --diff


test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Checkout project
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version-file: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov wheel
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run unit and system tests
run: |
pytest --cov=ppx tests/
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
uv run pytest tests/
32 changes: 27 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
repos:
- repo: https://github.com/psf/black
rev: 25.1.0 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: detect-private-key
- id: pretty-format-json
args: [--autofix]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
hooks:
# Run the linter.
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --show-fixes]
# Run the formatter.
- id: ruff-format
types_or: [python, pyi, jupyter]
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Repository Guidelines

## Project Structure & Module Organization
- Python package lives in `gopher/`; `gopher/gopher.py` is the CLI entry point wired to `gopher` console script.
- Shared utilities and domain logic sit in modules like `annotations.py`, `enrichment.py`, `graph_search.py`, and `normalize.py`.
- Tests are split by scope: unit tests in `tests/unit_tests/`, integration/system checks in `tests/system_tests/`, and fixtures/data in `tests/data/`.
- Documentation sources are in `docs/`; MkDocs configuration is at `mkdocs.yml`.

## Build, Test, and Development Commands
- Install for development (creates editable install with extras):
`uv sync --dev` or `pip install -e .[dev]`
- Run the test suite:
`uv run pytest` or `pytest`
- Lint and format with Ruff (configured in `pyproject.toml`):
`uv run ruff check .` and `uv run ruff format .`
- Pre-commit hooks (lint/format/metadata checks):
`pre-commit run --all-files`
- Build docs locally:
`uv run mkdocs serve`

## Coding Style & Naming Conventions
- Ruff enforces PEP8-style rules; line length is 79. Target Python 3.10+.
- Prefer type hints and docstrings for public functions; docstring checks are relaxed for tests and `__init__.py`.
- Use snake_case for functions/variables, CapWords for classes, and UPPER_SNAKE_CASE for constants.
- Keep modules focused; place CLI-only code in `gopher/gopher.py` and reusable logic elsewhere.

## Testing Guidelines
- Write fast, deterministic tests; mock network/filesystem when practical.
- Place new unit tests beside related code in `tests/unit_tests/`; heavier end-to-end flows go in `tests/system_tests/`.
- Name tests descriptively (`test_handles_missing_annotations`), and prefer given/when/then structure in assertions.
- Aim to cover new branches and edge cases before opening a PR; run `pytest -q` to keep output compact.

## Commit & Pull Request Guidelines
- Commit messages in this repo are short, imperative phrases (e.g., `Update pre-commit hooks`, `Migrate to uv and ruff`). Match that style.
- Keep commits focused; include only related changes plus updated tests.
- PRs should state the problem, the solution, and validation (tests, screenshots for visual changes). Link related issues and note breaking changes explicitly.
- Ensure lint, tests, and (if touched) docs build succeed before requesting review.

## Security & Configuration Notes
- Avoid committing secrets or private keys; pre-commit includes a detector, but double-check before pushing.
- Network calls (e.g., ontology downloads) should remain in well-scoped helper functions in `gopher/` so they can be mocked in tests.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog for gopher-enrich
# Changelog for gopher

## [v0.3.0] - 2025-12-09
### Changed
- Modernized codebase for uv.

### Fixed
- Linting errors.
- Publish action.

## [v0.2.0] - 2025-05-08
- Update github actions
- Update mkdocs.yml
- Add `read_diann` function
- Add `read_diann` function
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,3 @@ version 2.0, available at

[homepage]: https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ There are three exceptions to this:

2. The Vignettes are created from Jupyter notebooks.

3. The Code of Conduct, Release Notes, and this Contributing document are
3. The Code of Conduct, Release Notes, and this Contributing document are
markdown files that live in the root of the gopher-enrich repository.

### Editing most documents
Expand All @@ -39,7 +39,7 @@ way.

## Contributing to the code

We welcome contributions to the source code of gopher-enrich---particularly
We welcome contributions to the source code of gopher-enrich---particularly
ones that address discussed [issues](https://github.com/TalusBio/gopher/issues).

Contributions to gopher-enrich follow a standard GitHub contribution workflow:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ pip install gopher-enrich
```python
import gopher # import the package

gopher.test_enrichment(proteins=protein_quant) # run the enrichment
```
gopher.test_enrichment(proteins=protein_quant) # run the enrichment
```
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
::: gopher.normalize_values
::: gopher.get_rankings
::: gopher.in_term
::: gopher.roc
::: gopher.roc
4 changes: 2 additions & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gopher returns a dataframe with the following columns:
- GO Aspect: String with the gene ontology aspect. Either C (cellular component), F (molecular function), and B (biological process).
- Columns containing p-values from the GO enrichment.

Example output:
Example output:

GO ID | GO Name | GO Aspect | Sample 1 | Sample 2 | Sample 3
---------- | ----------- | ---------- | ---------- | ---------- | ----------
Expand Down Expand Up @@ -107,4 +107,4 @@ normalized_proteins = gopher.normalize_values(quant_proteins, "human_fasta.fasta

# Peform the GO enrichment analysis:
results = gopher.test_enrichment(proteins=normalized_proteins)
```
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Gopher be pip installed using:

```python
pip install gopher-enrich
```
```
Loading