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

Fix issue in counts #440

Merged
merged 1 commit into from
Jul 25, 2024
Merged
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
11 changes: 10 additions & 1 deletion cmat/output_generation/clinvar_to_evidence_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def clinvar_to_evidence_strings(string_to_efo_mappings, variant_to_gene_mappings
# Failure mode 5 (skip). A ClinVar record has at least one trait with at least one valid name, but no
# suitable EFO mappings were found in the database. This will still generate an evidence string, but is
# tracked as a failure so we can continue to measure mapping coverage.
if not any(group[-1] for group in grouped_diseases):
if not contains_mapping(grouped_diseases):
report.clinvar_skip_missing_efo_mapping += 1
unmapped_trait_name = clinvar_record.traits_with_valid_names[0].preferred_or_other_valid_name
report.unmapped_trait_names[unmapped_trait_name] += 1
Expand Down Expand Up @@ -159,6 +159,10 @@ def clinvar_to_evidence_strings(string_to_efo_mappings, variant_to_gene_mappings

if evidence_strings_generated == 0:
report.clinvar_skip_invalid_evidence_string += 1
# If this record also did not have any EFO-mapped traits, it has already been counted as "skip".
# Correct this so the counts match up but we retain the more important skip reason.
if not contains_mapping(grouped_diseases):
report.clinvar_skip_missing_efo_mapping -= 1

report.complete_evidence_string_count += complete_evidence_strings_generated
report.evidence_string_count += evidence_strings_generated
Expand Down Expand Up @@ -408,3 +412,8 @@ def group_diseases_by_efo_mapping(clinvar_record_traits, string_to_efo_mappings)
selected_trait = traits[0]
grouped_tuples.append((selected_trait.preferred_or_other_valid_name, selected_trait.medgen_id, efo_id))
return grouped_tuples


def contains_mapping(grouped_diseases):
"""Checks whether any disease tuple (as described above) contains an EFO mapping."""
return any(group[-1] for group in grouped_diseases)
Loading