-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""Fixtures""" | ||
|
||
from .ecoli import * | ||
from .shigella import * | ||
from .saureus import * | ||
from .mtuberculosis import * |
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,9 @@ | ||
"""Fixtures for Shigella.""" | ||
import pytest | ||
|
||
from ..fixtures import data_path | ||
|
||
@pytest.fixture() | ||
def shigella_shigapass_path(data_path): | ||
"""Get path for Shigapass results for shigella.""" | ||
return str(data_path.joinpath("shigella", "shigapass.csv")) |
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,5 @@ | ||
Name;rfb;rfb_hits,(%);MLST;fliC;CRISPR;ipaH;Predicted_Serotype;Predicted_FlexSerotype;Comments | ||
ERR5888634;C2;79,(48.2%);ST145;ShH57(ShH3cplx);A-var2;ipaH+;SB2;; | ||
ERR5952732;B1-5;139,(93.3%);ST245;ShH2(ShH2cplx);A-var3,x,16;ipaH+;SF1-5;1b; | ||
ERR5976293;D;202,(70.6%);ST152;ShH25(ShH1cplx);A-var0,27;ipaH+;SS;; | ||
ERR5982186;A2;100,(61.7%);ST147;none;A-var1,12,3,5,11-var1;ipaH+;SD2;; |
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,69 @@ | ||
"""Test functions for parsing Shigapass results.""" | ||
|
||
import pytest | ||
from prp.parse.phenotype.shigapass import parse_shigapass_pred, _extract_percentage | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input,expected", | ||
[ | ||
("79,(48.2%)", 48.2), | ||
("79,(48.0%)", 48.0), | ||
("79,(48%)", 48.0), | ||
("NA,(0.0%)", 0.0), | ||
("NA,(0%)", 0.0), | ||
], | ||
) | ||
def test_extract_percentage(input, expected): | ||
""" | ||
Test that the percentage can be extracted from rfb_hits. | ||
"foo, (12%)" -> 12% | ||
""" | ||
result = _extract_percentage(input) | ||
assert result == expected | ||
|
||
|
||
def test_parse_shigapass_results(ecoli_shigapass_path, shigella_shigapass_path): | ||
"""Test parsing of shigapass result files.""" | ||
|
||
# test parsing the output of an ecoli. | ||
result = parse_shigapass_pred(ecoli_shigapass_path) | ||
expected_ecoli = { | ||
"type": "shigatype", | ||
"software": "shigapass", | ||
"result": { | ||
"rfb": None, | ||
"rfb_hits": 0.0, | ||
"mlst": None, | ||
"flic": None, | ||
"crispr": None, | ||
"ipah": "ipaH-", | ||
"predicted_serotype": "Not Shigella/EIEC", | ||
"predicted_flex_serotype": None, | ||
"comments": None, | ||
}, | ||
} | ||
# check if data matches | ||
assert expected_ecoli == result[0].model_dump() | ||
|
||
# test parsing the output with a shigella. | ||
result = parse_shigapass_pred(shigella_shigapass_path) | ||
expected_shigella = { | ||
"type": "shigatype", | ||
"software": "shigapass", | ||
"result": { | ||
"rfb": "C2", | ||
"rfb_hits": 48.2, | ||
"mlst": "ST145", | ||
"flic": "ShH57(ShH3cplx)", | ||
"crispr": "A-var2", | ||
"ipah": "ipaH+", | ||
"predicted_serotype": "SB2", | ||
"predicted_flex_serotype": None, | ||
"comments": None, | ||
}, | ||
} | ||
|
||
# check if data matches | ||
assert expected_shigella == result[0].model_dump() |