-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from samuell/add-github-actions-workflow
Add GitHub Actions workflow
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Python Package using Conda | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
max-parallel: 5 | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.6.15 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.6.15' | ||
- name: Create conda/mamba environment using micromamba | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: environment.yml | ||
cache-downloads: true | ||
- name: Add micromamba to system path | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Set EMU_DATABASE env variable | ||
run: echo "EMU_DATABASE_DIR=./emu_database" >> $GITHUB_ENV | ||
- name: Lint with flake8 | ||
run: | | ||
micromamba install flake8 | ||
# 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: Test with pytest | ||
run: | | ||
micromamba install pytest | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
name: custom-emu | ||
|
||
channels: | ||
- bioconda | ||
- conda-forge | ||
- bioconda | ||
- nodefaults | ||
|
||
dependencies: | ||
- biopython | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def test_placeholder(): | ||
""" | ||
Add an empty test so as not to fail the pytest process until some real | ||
tests have been added. | ||
""" | ||
assert True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
import subprocess | ||
import os | ||
import pandas as pd | ||
import tempfile | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"emu_command_tpl, abundance_filepath_tpl, expected_abundancies", | ||
[ | ||
( | ||
"./emu abundance --db emu_database --output-dir {tempdir_path} --keep-files example/full_length.fa", | ||
"{tempdir_path}/full_length_rel-abundance.tsv", | ||
{ | ||
"Sphingobacterium puteale": 0.5, | ||
"Mycobacterium saskatchewanense": 0.25, | ||
"Streptococcus sobrinus": 0.25, | ||
}, | ||
), | ||
( | ||
"./emu abundance --db emu_database --output-dir {tempdir_path} --type sr --keep-files example/short_read_f.fq", | ||
"{tempdir_path}/short_read_f_rel-abundance.tsv", | ||
{ | ||
"Staphylococcus hominis": 1.0, | ||
}, | ||
), | ||
( | ||
"./emu abundance --db emu_database --output-dir {tempdir_path} --type sr --keep-files example/short_read_f.fq example/short_read_r.fq", | ||
"{tempdir_path}/short_read_f-short_read_r_rel-abundance.tsv", | ||
{ | ||
"Staphylococcus aureus": 1.0 / 3, | ||
"Salmonella enterica": 1.0 / 3, | ||
"Enterococcus columbae": 1.0 / 3, | ||
}, | ||
), | ||
], | ||
) | ||
def test_cli_on_example_datasets(emu_command_tpl, abundance_filepath_tpl, expected_abundancies): | ||
tempdir = tempfile.TemporaryDirectory() | ||
|
||
emu_command = emu_command_tpl.format(tempdir_path=tempdir.name) | ||
abundance_filepath = abundance_filepath_tpl.format(tempdir_path=tempdir.name) | ||
|
||
if os.path.exists(abundance_filepath): | ||
os.remove(abundance_filepath) | ||
|
||
subprocess.check_output(emu_command, shell=True) | ||
|
||
assert os.path.exists(abundance_filepath) | ||
|
||
df = abundance_df = pd.read_csv(abundance_filepath, sep="\t") | ||
|
||
for species, expected_abundance in expected_abundancies.items(): | ||
assert df[df["species"] == species].iloc[0]["abundance"] == expected_abundance |