Skip to content
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

Handle emmtyper alt types #97

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Added

### Fixed
- Handle alt types for emmtyper

### Changed

Expand Down
6 changes: 3 additions & 3 deletions prp/models/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class TypingResultEmm(RWModel):
"""Container for emmtype gene information"""

cluster_count: int
emmtype: str
emm_like_alleles: list[str]
emm_cluster: str
emmtype: str | None = None
emm_like_alleles: list[str] | None = None
emm_cluster: str | None = None


class EmmTypingMethodIndex(RWModel):
Expand Down
6 changes: 3 additions & 3 deletions prp/parse/phenotype/emmtyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def parse_emmtyper_pred(path: str) -> EmmTypingMethodIndex:
pred_result = []
df = pd.read_csv(path, sep='\t', header=None)
df.columns = ["sample_name", "cluster_count", "emmtype", "emm_like_alleles", "emm_cluster"]
df.replace(["-", ""], None, inplace=True)
df_loa = df.to_dict(orient="records")
for emmtype_array in df_loa:
emmtype_results = _parse_emmtyper_results(emmtype_array)
Expand All @@ -31,10 +32,9 @@ def parse_emmtyper_pred(path: str) -> EmmTypingMethodIndex:

def _parse_emmtyper_results(info: dict[str, Any]) -> TypingResultEmm:
"""Parse emm gene prediction results."""
emm_like_alleles = info["emm_like_alleles"].split(";")
emm_like_alleles = info["emm_like_alleles"].split(";") if not pd.isna(info["emm_like_alleles"]) else None
return TypingResultEmm(
# info
cluster_count=info["cluster_count"],
cluster_count=int(info["cluster_count"]),
emmtype=info["emmtype"],
emm_like_alleles=emm_like_alleles,
emm_cluster=info["emm_cluster"],
Expand Down
Loading