-
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.
Run example pipelines via pytest instead and check abundance output
- Loading branch information
Showing
2 changed files
with
48 additions
and
9 deletions.
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
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,48 @@ | ||
import pytest | ||
import subprocess | ||
import os | ||
import pandas as pd | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"emu_command, abundance_file, expected_abundancies", | ||
[ | ||
( | ||
"./emu abundance --db emu_database --output-dir test_results example/full_length.fa", | ||
"test_results/full_length_rel-abundance.tsv", | ||
{ | ||
"Sphingobacterium puteale": 0.5, | ||
"Mycobacterium saskatchewanense": 0.25, | ||
"Streptococcus sobrinus": 0.25, | ||
}, | ||
), | ||
( | ||
"./emu abundance --db emu_database --output-dir test_results --type sr example/short_read_f.fq", | ||
"test_results/short_read_f_rel-abundance.tsv", | ||
{ | ||
"Staphylococcus hominis": 1.0, | ||
}, | ||
), | ||
( | ||
"./emu abundance --db emu_database --output-dir test_results --type sr example/short_read_f.fq example/short_read_r.fq", | ||
"test_results/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_full_length_example(emu_command, abundance_file, expected_abundancies): | ||
if os.path.exists(abundance_file): | ||
os.remove(abundance_file) | ||
|
||
subprocess.check_output(emu_command, shell=True) | ||
|
||
assert os.path.exists(abundance_file) | ||
|
||
df = abundance_df = pd.read_csv(abundance_file, sep="\t") | ||
|
||
for species, expected_abundance in expected_abundancies.items(): | ||
assert df[df["species"] == species].iloc[0]["abundance"] == expected_abundance |