-
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.
Revert shigapass changes and create specific MedthodIndex for emmtyper
- Loading branch information
1 parent
139e220
commit 7e726c9
Showing
8 changed files
with
109 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
"""Module for parsing resistance prediction results.""" | ||
|
||
from .amrfinder import parse_amrfinder_amr_pred, parse_amrfinder_vir_pred | ||
from .emmtyper import parse_emmtyper_pred | ||
from .mykrobe import parse_mykrobe_amr_pred | ||
from .resfinder import parse_resfinder_amr_pred | ||
from .shigapass import parse_shigapass_pred | ||
from .tbprofiler import parse_tbprofiler_amr_pred | ||
from .virulencefinder import parse_virulencefinder_vir_pred |
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,28 +1,41 @@ | ||
"""Functions for parsing emmtyper result.""" | ||
|
||
import logging | ||
import pandas as pd | ||
|
||
from typing import Any | ||
|
||
from ...models.phenotype import ElementType, ElementVirulenceSubtype | ||
from ...models.phenotype import (EmmtypeGene) | ||
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 | None: | ||
"""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_emm_gene( | ||
info: dict[str, Any], subtype: ElementVirulenceSubtype = ElementVirulenceSubtype.VIR | ||
) -> EmmtypeGene: | ||
|
||
emm_like_alleles = info["emm_like_alleles"].split(";") | ||
|
||
def _parse_emmtyper_results(info: dict[str, Any]) -> TypingResultEmm: | ||
"""Parse emm gene prediction results.""" | ||
return EmmtypeGene( | ||
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"], | ||
# gene classification | ||
element_type=ElementType.VIR, | ||
element_subtype=subtype, | ||
) |
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