diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..8916f8d --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,39 @@ +# This pipeline builds the documentation. +name: docs + +on: + push: + branches: [ main ] + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + version: "1.5.1" + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v2 + with: + path: .venv + key: pydeps-${{ hashFiles('**/poetry.lock') }} + - name: Install the dependencies + run: poetry install --no-interaction --no-root --with dev + if: steps.cache-deps.outputs.cache-hit != 'true' + - name: Install the module + run: poetry install --with dev --no-interaction + - name: Generate the documentation + run: poetry run mkdocs gh-deploy --force diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..65a1a18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +# This pipeline checks whether the package +# installs properly, passes unit tests and whether +# the code formatting is right. +name: build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + python-version: ["3.10"] + poetry-version: ["1.3.2"] + + steps: + - uses: actions/checkout@v3 + - name: Run black formatting check + uses: psf/black@stable + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + version: ${{ matrix.poetry-version }} + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v2 + with: + path: .venv + key: pydeps-${{ hashFiles('**/poetry.lock') }} + - name: Install the dependencies + run: poetry install --no-interaction --no-root --with dev + if: steps.cache-deps.outputs.cache-hit != 'true' + - name: Install the module + run: poetry install --with dev --no-interaction + - name: Run unit tests + run: poetry run pytest + - name: Run Ruff + run: poetry run ruff check . + - name: Run Pyright (type checking) + run: poetry run pyright + diff --git a/.gitignore b/.gitignore index 68bc17f..fa12c16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,20 @@ +# Notebooks by default should not be uploaded (use Quarto Markdown as an alternative) +*.nb +*.ipynb + +# Data and plots +*.csv +*.jpg +*.jpeg +*.npy +*.npz +*.pdf +*.png +*.zip + +# Poetry lock file +poetry.lock + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d43179a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.245' + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - repo: local + hooks: + - id: pyright + name: pyright + entry: poetry run pyright + language: node + pass_filenames: true + types: [python] diff --git a/README.md b/README.md index 12aa20c..0533cd9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ -# covvfit- -fitness estimates of SARS-CoV-2 variants +[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) +[![build](https://github.com/cbg-ethz/covvfit/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/cbg-ethz/covvfit/actions/workflows/test.yml) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/charliermarsh/ruff) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) + + +# covvfit +Fitness estimates of SARS-CoV-2 variants. + + - **Documentation:** [https://cbg-ethz.github.io/covvfit](https://cbg-ethz.github.io/covvfit) + - **Source code:** [https://github.com/cbg-ethz/covvfit](https://github.com/cbg-ethz/covvfit) + - **Bug reports:** [https://github.com/cbg-ethz/covvfit/issues](https://github.com/cbg-ethz/covvfit/issues) + + +## Installation + +### Developers +Create a new environment, e.g., using [Micromamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html): +```bash +$ micromamba create -n covvfit -c conda-forge python=3.10 +``` + +Then, install the package. + +For a machine where development happens it comes with developer utilities: + +```bash +$ pip install poetry +$ poetry install --with dev +$ pre-commit install +``` + +## See Also + + - [V-pipe](https://cbg-ethz.github.io/V-pipe/): a bioinformatics pipeline for viral sequencing data. + - [cojac](https://github.com/cbg-ethz/cojac): command-line tools for the analysis of co-occurrence of mutations on amplicons. + diff --git a/docs/index.md b/docs/index.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/docs/index.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..24db20f --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,47 @@ +site_name: Inference of SARS-Cov-2 variant fitness + +theme: + name: "material" + features: + - navigation.tabs + - navigation.sections + - toc.integrate + - search.suggest + - search.highlight + - content.tabs.link + - content.code.annotation + - content.code.copy + language: en + palette: + - scheme: default + toggle: + icon: material/toggle-switch-off-outline + name: Switch to dark mode + primary: teal + accent: purple + - scheme: slate + toggle: + icon: material/toggle-switch + name: Switch to light mode + primary: teal + accent: lime + +plugins: + - search + - mkdocstrings: + default_handler: python + handlers: + python: + options: + show_source: false + show_root_heading: true + +nav: + - Documentation: index.md + - API Reference: api.md + +repo_name: covvfit +repo_url: https://github.com/cbg-ethz/covvfit + +watch: + - src/covvfit diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d7a3137 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[tool.poetry] +name = "covvfit" +version = "0.1.0" +description = "" +authors = ["David Dreifuss ", "Paweł Czyż "] +readme = "README.md" +packages = [{include = "covvfit", from = "src"}] + +[tool.poetry.dependencies] +python = ">=3.10,<3.12" +numpy = "^1.25" +matplotlib = "^3.8.0" +pymc = "^5.9.1" +scipy = "^1.11.3" + + +[tool.poetry.group.dev.dependencies] +pytest = "^7.4.3" +ruff = "^0.1.3" +black = "^23.10.1" +pre-commit = "^3.5.0" +pyright = "^1.1.333" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/src/covvfit/__init__.py b/src/covvfit/__init__.py new file mode 100644 index 0000000..1cf6267 --- /dev/null +++ b/src/covvfit/__init__.py @@ -0,0 +1 @@ +VERSION = "0.1.0" diff --git a/tests/test_installed.py b/tests/test_installed.py new file mode 100644 index 0000000..d282cbe --- /dev/null +++ b/tests/test_installed.py @@ -0,0 +1,5 @@ +import covvfit + + +def test_imports() -> None: + assert isinstance(covvfit.VERSION, str)