Skip to content

Commit

Permalink
Tests (pytest and github actions)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrYak committed May 4, 2023
1 parent eeccdb0 commit 3e57e5e
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 21 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Poetry Dynamic Versioning
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build package
run: |
poetry install --extras "cli"
poetry build
- name: Test package
run: |
poetry run pytest -v
- name: Lint package
run: poetry run black --check --diff .

- name: Archive test output
uses: actions/upload-artifact@v3
with:
name: test_curves
path: |
test_results.*
if-no-files-found: error
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
test_results.*

# Compiled python modules.
*.pyc

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Bioconda package](https://img.shields.io/conda/dn/bioconda/lollipop.svg?label=Bioconda)](https://bioconda.github.io/recipes/lollipop/README.html)
[![Docker container](https://quay.io/repository/biocontainers/lollipop/status)](https://quay.io/repository/biocontainers/lollipop)
[![bio.tools](https://img.shields.io/badge/bio-tools-blue.svg)](https://bio.tools/LolliPop)
[![Tests](https://github.com/cbg-ethz/LolliPop/actions/workflows/main.yaml/badge.svg)](https://github.com/cbg-ethz/LolliPop/actions/workflows/main.yaml)

LolliPop - a tool for Deconvolution for Wastewater Genomics

Expand Down
32 changes: 16 additions & 16 deletions preprint/WwSmoothingKernel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
" <th>pos</th>\n",
" <th>proto</th>\n",
" <th>date</th>\n",
" <th>plantcode</th>\n",
" <th>plantname</th>\n",
" <th>location_code</th>\n",
" <th>location</th>\n",
" <th>gene</th>\n",
" <th>base</th>\n",
" <th>cov</th>\n",
Expand Down Expand Up @@ -329,14 +329,14 @@
"</div>"
],
"text/plain": [
" sample batch pos proto date plantcode \\\n",
" sample batch pos proto date location_code \\\n",
"1 A1_05_2021_08_25 20210910_HJF5KDRXY 733 v3 2021-08-25 5.0 \n",
"2 A1_05_2021_08_25 20210910_HJF5KDRXY 913 v3 2021-08-25 5.0 \n",
"3 A1_05_2021_08_25 20210910_HJF5KDRXY 1059 v3 2021-08-25 5.0 \n",
"5 A1_05_2021_08_25 20210910_HJF5KDRXY 5388 v3 2021-08-25 5.0 \n",
"6 A1_05_2021_08_25 20210910_HJF5KDRXY 5986 v3 2021-08-25 5.0 \n",
"\n",
" plantname gene base cov var frac B.1.617.1 P.1 \\\n",
" location gene base cov var frac B.1.617.1 P.1 \\\n",
"1 Lugano (TI) ORF1ab C 1 0 0.000000 0 1 \n",
"2 Lugano (TI) ORF1ab T 1 0 0.000000 0 0 \n",
"3 Lugano (TI) ORF1ab T 52796 24934 0.472271 0 0 \n",
Expand Down Expand Up @@ -564,7 +564,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -724,7 +724,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -975,7 +975,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -1302,7 +1302,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -1637,7 +1637,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -1978,7 +1978,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -2332,7 +2332,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -2624,7 +2624,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" for boot in tqdm(range(n_boot)):\n",
" temp_df2 = resample_mutations(temp_df, temp_df.mutations.unique())[0] \n",
" t_kdec = KernelDeconv(\n",
Expand Down Expand Up @@ -2924,7 +2924,7 @@
"\n",
"for city in tqdm(cities_list):\n",
" print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -3140,7 +3140,7 @@
"for i, kval in enumerate(tqdm(kernel_vals)):\n",
" for j, city in enumerate(cities_list_short):\n",
"# print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -3228,7 +3228,7 @@
" for kap in kappa_vals: \n",
" for city in cities_list_short:\n",
" # print(city)\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == city]\n",
" temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == city]\n",
" t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down Expand Up @@ -3309,7 +3309,7 @@
}
],
"source": [
"temp_df2 = preproc.df_tally[preproc.df_tally[\"plantname\"] == \"Zürich (ZH)\"]\n",
"temp_df2 = preproc.df_tally[preproc.df_tally[\"location\"] == \"Zürich (ZH)\"]\n",
"t_kdec = KernelDeconv(\n",
" temp_df2[variants_list + [\"undetermined\"]],\n",
" temp_df2[\"frac\"],\n",
Expand Down
4 changes: 2 additions & 2 deletions preprint/data/tallymut_line_full.tsv
Git LFS file not shown
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "lollipop"
version = "0.0.0"
description = "tool for Deconvolution for Wastewater Genomics"
authors = ["David Dreifuss <[email protected]>", "Ivan Blagoev Topolsky <[email protected]>", "Matteo Carrara <[email protected]>"]
maintainer = ["Ivan Blagoev Topolsky <[email protected]>"]
maintainers = ["Ivan Blagoev Topolsky <[email protected]>"]
license = "GPL-3.0-or-later"
readme = "README.md"
repository = "https://github.com/cbg-ethz/LolliPop"
Expand Down Expand Up @@ -31,8 +31,8 @@ lollipop = { callable = "lollipop.cli:cli", extras = ["cli"] }
deconvolute = { callable = "lollipop.deconvolute:deconvolute", extras = ["cli"] }

[tool.poetry.dev-dependencies]
black = "^22.1.0"
#pytest = "^6.2.1"
black = "^23.3.0"
pytest = "^6.2.1"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
Expand Down
24 changes: 24 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import subprocess


def test_workflow():
# data: its handled with LFS

# dummy run
subprocess.check_call(["lollipop", "--version"])

# do fast test from preprint
subprocess.check_call(
[
"lollipop",
"deconvolute",
"--output=test_results.csv",
"--out-json=test_results.json",
"--fmt-columns",
"--variants-config=config_preprint.yaml",
"--deconv-config=presets/deconv_linear.yaml",
"--location=Zürich (ZH)",
"--seed=42",
"preprint/data/tallymut_line_full.tsv",
]
)

0 comments on commit 3e57e5e

Please sign in to comment.