-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GitHub Actions workflow #41
Merged
kdc10
merged 5 commits into
treangenlab:master
from
samuell:add-github-actions-workflow
Jan 22, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
87af854
Add GitHub Actions workflow
samuell bab5937
Run CI on all pushes and pull requests
samuell 6eb78ec
Run example pipelines via pytest instead and check abundance output
samuell d3f80bf
Keep (alignment) files in CLI test commands
samuell b5555b8
Use tempfile for test output directory instead of custom one
samuell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely sure here if it is expected that "Staphylococcus hominis" no longer shows up, and instead we get three equal parts of three other species, although the same forward strand file is used?