diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..727e356 --- /dev/null +++ b/.github/workflows/main.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 073bc2a..e3da8c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +test_results.* + # Compiled python modules. *.pyc diff --git a/README.md b/README.md index 3c2dca2..8209a14 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/preprint/WwSmoothingKernel.ipynb b/preprint/WwSmoothingKernel.ipynb index c930252..1865c4d 100644 --- a/preprint/WwSmoothingKernel.ipynb +++ b/preprint/WwSmoothingKernel.ipynb @@ -197,8 +197,8 @@ " pos\n", " proto\n", " date\n", - " plantcode\n", - " plantname\n", + " location_code\n", + " location\n", " gene\n", " base\n", " cov\n", @@ -329,14 +329,14 @@ "" ], "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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/preprint/data/tallymut_line_full.tsv b/preprint/data/tallymut_line_full.tsv index e1dc607..fb71297 100644 --- a/preprint/data/tallymut_line_full.tsv +++ b/preprint/data/tallymut_line_full.tsv @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea20760dc042b7f3ff58d4106c11114959c59e9dd9b66f4ee2198e062870dc99 -size 145451725 +oid sha256:9797b0c77fa71b69c253e2f79097510edd225fb532d43b62728ee6a061debf49 +size 145451728 diff --git a/pyproject.toml b/pyproject.toml index 4cde72c..e499a7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "lollipop" version = "0.0.0" description = "tool for Deconvolution for Wastewater Genomics" authors = ["David Dreifuss ", "Ivan Blagoev Topolsky ", "Matteo Carrara "] -maintainer = ["Ivan Blagoev Topolsky "] +maintainers = ["Ivan Blagoev Topolsky "] license = "GPL-3.0-or-later" readme = "README.md" repository = "https://github.com/cbg-ethz/LolliPop" @@ -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"] diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..807edd5 --- /dev/null +++ b/tests/test_integration.py @@ -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", + ] + )