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

feat!: add base and aac-2017 models from 1.0.0-ballot.2024-11.2 release #14

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "submodules/va_spec"]
path = submodules/va_spec
url = https://github.com/ga4gh/va-spec
branch = 1.x
branch = 1.0.0-ballot.2024-11
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ keywords = [
requires-python = ">=3.10"
dynamic = ["version"]
dependencies = [
"ga4gh.vrs~=2.0.0a12",
"ga4gh.cat_vrs~=0.1.0",
#"ga4gh.vrs==2.0.0a13",
#"ga4gh.cat_vrs~=0.1.0",
"pydantic==2.*"
]

Expand Down Expand Up @@ -138,7 +138,7 @@ ignore = [
# B011 - assert-false
# N815 - mixed-case-variable-in-class-scope
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011"]
"src/ga4gh/va_spec/profiles/*" = ["ANN102", "N815"]
"src/ga4gh/va_spec/*" = ["ANN102", "N815"]

[tool.setuptools.packages.find]
where = ["src"]
Expand Down
13 changes: 13 additions & 0 deletions src/ga4gh/va_spec/aac_2017/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Module to load and init namespace at package level."""

from .models import (
VariantDiagnosticStudyStatement,
VariantPrognosticStudyStatement,
VariantTherapeuticResponseStudyStatement,
)

__all__ = [
"VariantDiagnosticStudyStatement",
"VariantPrognosticStudyStatement",
"VariantTherapeuticResponseStudyStatement",
]
48 changes: 48 additions & 0 deletions src/ga4gh/va_spec/aac_2017/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""AMP/ASCO/CAP 2017"""

from ga4gh.va_spec.base.core import (
Statement,
VariantDiagnosticProposition,
VariantPrognosticProposition,
VariantTherapeuticResponseProposition,
)
from pydantic import (
Field,
)


class VariantDiagnosticStudyStatement(Statement):
"""A statement reporting a conclusion from a single study about whether a variant is
associated with a disease (a diagnostic inclusion criterion), or absence of a
disease (diagnostic exclusion criterion) - based on interpretation of the study's
results.
"""

proposition: VariantDiagnosticProposition = Field(
...,
description="A proposition about a diagnostic association between a variant and condition, for which the study provides evidence. The validity of this proposition, and the level of confidence/evidence supporting it, may be assessed and reported by the Statement.",
)


class VariantPrognosticStudyStatement(Statement):
"""A statement reporting a conclusion from a single study about whether a variant is
associated with a disease prognosis - based on interpretation of the study's
results.
"""

proposition: VariantPrognosticProposition = Field(
...,
description="A proposition about a prognostic association between a variant and condition, for which the study provides evidence. The validity of this proposition, and the level of confidence/evidence supporting it, may be assessed and reported by the Statement.",
)


class VariantTherapeuticResponseStudyStatement(Statement):
"""A statement reporting a conclusion from a single study about whether a variant is
associated with a therapeutic response (positive or negative) - based on
interpretation of the study's results.
"""

proposition: VariantTherapeuticResponseProposition = Field(
...,
description="A proposition about the therapeutic response associated with a variant, for which the study provides evidence. The validity of this proposition, and the level of confidence/evidence supporting it, may be assessed and reported by the Statement.",
)
66 changes: 66 additions & 0 deletions src/ga4gh/va_spec/base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Module to load and init namespace at package level."""

from .caf_study_result import CohortAlleleFrequencyStudyResult
from .core import (
Agent,
ClinicalVariantProposition,
Contribution,
CoreType,
DataSet,
DiagnosticPredicate,
Direction,
Document,
EvidenceLine,
ExperimentalVariantFunctionalImpactProposition,
InformationEntity,
Method,
PrognosticPredicate,
Proposition,
Statement,
StudyGroup,
StudyResult,
SubjectVariantProposition,
TherapeuticResponsePredicate,
VariantDiagnosticProposition,
VariantOncogenicityProposition,
VariantPathogenicityProposition,
VariantPrognosticProposition,
VariantTherapeuticResponseProposition,
)
from .domain_entities import Condition, Therapeutic, TherapyGroup, TraitSet
from .experimental_variant_functional_impact import (
ExperimentalVariantFunctionalImpactStudyResult,
)

__all__ = [
"CohortAlleleFrequencyStudyResult",
"InformationEntity",
"StudyResult",
"Proposition",
"SubjectVariantProposition",
"ClinicalVariantProposition",
"ExperimentalVariantFunctionalImpactProposition",
"DiagnosticPredicate",
"VariantDiagnosticProposition",
"VariantOncogenicityProposition",
"VariantPathogenicityProposition",
"PrognosticPredicate",
"VariantPrognosticProposition",
"TherapeuticResponsePredicate",
"VariantTherapeuticResponseProposition",
"CoreType",
"Method",
"Contribution",
"Document",
"Agent",
"Direction",
"DataSet",
"EvidenceLine",
"Statement",
"StudyGroup",
"TraitSet",
"Condition",
"TherapyGroup",
"Therapeutic",
"ExperimentalVariantFunctionalImpactStudyResult",
]
66 changes: 66 additions & 0 deletions src/ga4gh/va_spec/base/caf_study_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Cohort Allele Frequency Study Result Standard Profile"""

from __future__ import annotations

from typing import Any, Literal

from ga4gh.core.models import iriReference
from ga4gh.va_spec.base.core import DataSet, StudyGroup, StudyResult
from ga4gh.vrs.models import Allele
from pydantic import Field


class CohortAlleleFrequencyStudyResult(StudyResult):
"""A StudyResult that reports measures related to the frequency of an Allele in a cohort"""

type: Literal["CohortAlleleFrequencyStudyResult"] = Field(
"CohortAlleleFrequencyStudyResult",
description="MUST be 'CohortAlleleFrequencyStudyResult'.",
)
sourceDataSet: DataSet | None = Field(
None,
description="The dataset from which the CohortAlleleFrequencyStudyResult was reported.",
)
focus: None = Field(
None, exclude=True, repr=False
) # extends property in JSON Schema. Should not be used
focusAllele: Allele | iriReference = Field(
..., description="The Allele for which frequency results are reported."
)
focusAlleleCount: int = Field(
..., description="The number of occurrences of the focusAllele in the cohort."
)
locusAlleleCount: int = Field(
...,
description="The number of occurrences of all alleles at the locus in the cohort.",
)
focusAlleleFrequency: int = Field(
korikuzma marked this conversation as resolved.
Show resolved Hide resolved
..., description="The frequency of the focusAllele in the cohort."
)
cohort: StudyGroup = Field(
..., description="The cohort from which the frequency was derived."
)
subCohortFrequency: list[CohortAlleleFrequencyStudyResult] | None = Field(
None,
description="A list of CohortAlleleFrequency objects describing subcohorts of the cohort currently being described. Subcohorts can be further subdivided into more subcohorts. This enables, for example, the description of different ancestry groups and sexes among those ancestry groups.",
)
ancillaryResults: dict | None = None
qualityMeasures: dict | None = None

def __getattribute__(self, name: str) -> Any: # noqa: ANN401
"""Retrieve the value of the specified attribute

:param name: Name of attribute being accessed
:return: The value of the specified attribute
:raises ValueError: If the attribute being accessed is not already defined in
CohortAlleleFrequencyStudyResult or the attribute is `focus`
"""
if name == "focus":
err_msg = f"'{type(self).__name__!r}' object has no attribute '{name!r}'"
raise AttributeError(err_msg)
return super().__getattribute__(name)


del CohortAlleleFrequencyStudyResult.model_fields[
"focus"
] # Need to remove inherited property
Loading
Loading