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 Q/C reporting #337

Merged
merged 2 commits into from
Oct 29, 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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ classifiers = [
]
dependencies = [
"hpo-toolkit>=0.3.0",
"stairval>=0.2.0",
"Jinja2>=3.1.4,<4.0.0",
"protobuf>=3.15.0",
"pandas>=2.0.0,<3.0.0",
Expand Down
10 changes: 7 additions & 3 deletions src/gpsea/model/_cohort.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,16 @@ def __hash__(self) -> int:


class Cohort(typing.Sized, typing.Iterable[Patient]):
"""
Cohort is a collection of individuals that have been preprocessed
and are ready for genotype-phenotype association analysis.
"""

@staticmethod
def from_patients(
members: typing.Iterable[Patient],
include_patients_with_no_HPO: bool = False,
include_patients_with_no_variants: bool = False,
members: typing.Iterable[Patient],
include_patients_with_no_HPO: bool = False,
include_patients_with_no_variants: bool = False,
):
"""
Create a cohort from a sequence of patients.
Expand Down
2 changes: 0 additions & 2 deletions src/gpsea/preprocessing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from ._api import PreprocessingValidationResult
from ._api import TranscriptCoordinateService, GeneCoordinateService
from ._api import VariantCoordinateFinder, FunctionalAnnotator, ImpreciseSvFunctionalAnnotator, ProteinMetadataService
from ._audit import Auditor, DataSanityIssue, Level, Notepad, NotepadTree
from ._config import load_phenopacket_folder, load_phenopacket_files, load_phenopackets
from ._config import configure_caching_cohort_creator, configure_cohort_creator
from ._config import configure_default_protein_metadata_service, configure_protein_metadata_service
Expand All @@ -27,6 +26,5 @@
'UniprotProteinMetadataService',
'VepFunctionalAnnotator', 'VariantAnnotationCache', 'VarCachingFunctionalAnnotator',
'VVHgvsVariantCoordinateFinder', 'VVMultiCoordinateService',
'Auditor', 'DataSanityIssue', 'Level', 'Notepad', 'NotepadTree',
'DefaultImpreciseSvFunctionalAnnotator',
]
27 changes: 13 additions & 14 deletions src/gpsea/preprocessing/_api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import abc
import io
import os
import sys
import typing

from stairval.notepad import Notepad

from gpsea.model import (
VariantCoordinates,
ProteinMetadata,
Expand All @@ -13,8 +14,6 @@
ImpreciseSvInfo,
)

from ._audit import NotepadTree

T = typing.TypeVar("T")


Expand Down Expand Up @@ -142,7 +141,7 @@ class PreprocessingValidationResult:
def __init__(
self,
policy: str,
notepad: NotepadTree,
notepad: Notepad,
):
self._policy = policy
self._notepad = notepad
Expand Down Expand Up @@ -175,7 +174,7 @@ def is_ok(self) -> bool:

def summarize(
self,
file: io.TextIOBase = sys.stdout,
file: typing.TextIO = sys.stdout,
indent: int = 2,
):
"""
Expand All @@ -189,13 +188,13 @@ def summarize(
file.write(f"Validated under {self._policy} policy")
file.write(os.linesep)

n_errors = sum(node.error_count() for node in self._notepad.iterate_nodes())
n_warnings = sum(node.warning_count() for node in self._notepad.iterate_nodes())
n_errors = sum(node.error_count() for node in self._notepad.iter_sections())
n_warnings = sum(node.warning_count() for node in self._notepad.iter_sections())
if n_errors > 0 or n_warnings > 0:
file.write("Showing errors and warnings")
file.write(os.linesep)

for node in self._notepad.iterate_nodes():
for node in self._notepad.iter_sections():
if node.has_errors_or_warnings(include_subsections=True):
# We must report the node label even if there are no issues with the node.
l_pad = " " * (node.level * indent)
Expand All @@ -207,19 +206,19 @@ def summarize(
file.write(os.linesep)
for error in node.errors():
file.write(
l_pad + " " + error.message + f". {error.solution}"
if error.solution
else ""
l_pad + " ·" + error.message + (
f". {error.solution}" if error.solution else ""
)
)
file.write(os.linesep)
if node.has_warnings():
file.write(l_pad + " warnings:")
file.write(os.linesep)
for warning in node.warnings():
file.write(
l_pad + " ·" + warning.message + f". {warning.solution}"
if warning.solution
else ""
l_pad + " ·" + warning.message + (
f". {warning.solution}" if warning.solution else ""
)
)
file.write(os.linesep)
else:
Expand Down
Loading
Loading