Skip to content

Commit

Permalink
Merge pull request #55 from monarch-initiative/54-write-error-when-no…
Browse files Browse the repository at this point in the history
…-results-found-for-a-omim-id-not-present-in-the-phenotypehpoa

54 write error when no results found for a omim id not present in the phenotypehpoa
  • Loading branch information
yaseminbridges authored Jan 8, 2025
2 parents 667adf5 + fb99c84 commit ae0a6b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "phenotype2phenopacket"
version = "0.6.11"
version = "0.6.12"
description = ""
authors = ["Yasemin Bridges <[email protected]>"]
readme = "README.md"
Expand Down
10 changes: 9 additions & 1 deletion src/phenotype2phenopacket/create/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from phenotype2phenopacket.utils.utils import (
filter_diseases,
load_ontology,
read_omim_id_list,
return_phenotype_annotation_data,
)

Expand Down Expand Up @@ -74,7 +75,14 @@ def create_synthetic_patients(
grouped_omim_diseases = filter_diseases(
num_disease, omim_id, omim_id_list, phenotype_annotation_data
)
for omim_disease in grouped_omim_diseases:
omim_ids = (
read_omim_id_list(omim_id_list) if omim_id_list else [None] * len(grouped_omim_diseases)
)
for omim_id, omim_disease in zip(omim_ids, grouped_omim_diseases):
if len(omim_disease) == 0:
id_message = f" for {omim_id}!" if omim_id else "!"
print(f"Skipping... Could not find any phenotype entries{id_message}")
continue
create_synthetic_patient_phenopacket(
human_phenotype_ontology,
omim_disease,
Expand Down
6 changes: 3 additions & 3 deletions src/phenotype2phenopacket/utils/phenopacket_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ def worker():
if len(self.filtered_df) == 0:
return frequency_df.sample(n=max_number)
else:
return pl.from_dicts(self.filtered_df)
return pl.from_dicts(self.filtered_df, infer_schema_length=len(self.filtered_df))
else:
return pl.from_dicts(self.filtered_df)
return pl.from_dicts(self.filtered_df, infer_schema_length=len(self.filtered_df))

def get_patient_terms(self) -> pl.DataFrame:
"""
Expand Down Expand Up @@ -570,7 +570,7 @@ def patient_term_annotation_set(self) -> pl.DataFrame:
patient_terms, patient_terms_sub_sample
)
final_patient_terms = patient_terms_filtered.to_dicts() + new_phenotype_terms
return pl.from_dicts(final_patient_terms)
return pl.from_dicts(final_patient_terms, infer_schema_length=len(final_patient_terms))


class PhenotypeAnnotationToPhenopacketConverter:
Expand Down

0 comments on commit ae0a6b2

Please sign in to comment.