-
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.
Merge pull request #92 from Clinical-Genomics-Lund/91-add-emmtyper
Add emmtyper, update shigapass and fix quast
- Loading branch information
Showing
15 changed files
with
126 additions
and
10 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
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
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
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
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 @@ | ||
"""Functions for parsing emmtyper result.""" | ||
|
||
import logging | ||
import pandas as pd | ||
|
||
from typing import Any | ||
|
||
from ...models.typing import EmmTypingMethodIndex, TypingMethod, TypingResultEmm | ||
from ...models.typing import TypingSoftware as Software | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
def parse_emmtyper_pred(path: str) -> EmmTypingMethodIndex: | ||
"""Parse emmtyper's output re emm-typing""" | ||
LOG.info("Parsing emmtyper results") | ||
pred_result = [] | ||
df = pd.read_csv(path, sep='\t', header=None) | ||
df.columns = ["sample_name", "cluster_count", "emmtype", "emm_like_alleles", "emm_cluster"] | ||
df_loa = df.to_dict(orient="records") | ||
for emmtype_array in df_loa: | ||
emmtype_results = _parse_emmtyper_results(emmtype_array) | ||
pred_result.append( | ||
EmmTypingMethodIndex( | ||
type=TypingMethod.EMMTYPE, | ||
result=emmtype_results, | ||
software=Software.EMMTYPER, | ||
) | ||
) | ||
return pred_result | ||
|
||
|
||
def _parse_emmtyper_results(info: dict[str, Any]) -> TypingResultEmm: | ||
"""Parse emm gene prediction results.""" | ||
emm_like_alleles = info["emm_like_alleles"].split(";") | ||
return TypingResultEmm( | ||
# info | ||
cluster_count=info["cluster_count"], | ||
emmtype=info["emmtype"], | ||
emm_like_alleles=emm_like_alleles, | ||
emm_cluster=info["emm_cluster"], | ||
) |
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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
from .mtuberculosis import * | ||
from .saureus import * | ||
from .shigella import * | ||
from .streptococcus 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,10 @@ | ||
"""Fixtures for Streptococcus.""" | ||
import pytest | ||
|
||
from ..fixtures import data_path | ||
|
||
|
||
@pytest.fixture() | ||
def streptococcus_emmtyper_path(data_path): | ||
"""Get path for Emmtyper results for streptococcus.""" | ||
return str(data_path.joinpath("streptococcus", "emmtyper.tsv")) |
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 @@ | ||
test1_240920_nb000000_0000_test 2 EMM169.3 EMM164.2~* E4 |
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,22 @@ | ||
"""Test functions for parsing Emmtyper results.""" | ||
|
||
import pytest | ||
|
||
from prp.parse.phenotype.emmtyper import parse_emmtyper_pred | ||
|
||
|
||
def test_parse_emmtyper_results(streptococcus_emmtyper_path): | ||
"""Test parsing of emmtyper result files.""" | ||
|
||
# test parsing the output of an streptococcus. | ||
result = parse_emmtyper_pred(streptococcus_emmtyper_path) | ||
expected_streptococcus = { | ||
"cluster_count": 2, | ||
"emmtype": "EMM169.3", | ||
"emm_like_alleles": [ | ||
"EMM164.2~*" | ||
], | ||
"emm_cluster": "E4" | ||
} | ||
# check if data matches | ||
assert expected_streptococcus == result[0].result.model_dump() |