Skip to content

Commit cf72234

Browse files
authored
feat!: add base and aac-2017 models from 1.0.0-ballot.2024-11.2 release (#14)
close #11
1 parent cb23350 commit cf72234

17 files changed

+1026
-538
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "submodules/va_spec"]
22
path = submodules/va_spec
33
url = https://github.com/ga4gh/va-spec
4-
branch = 1.x
4+
branch = 1.0.0-ballot.2024-11

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ keywords = [
3131
requires-python = ">=3.10"
3232
dynamic = ["version"]
3333
dependencies = [
34-
"ga4gh.vrs~=2.0.0a12",
35-
"ga4gh.cat_vrs~=0.1.0",
34+
"ga4gh.vrs==2.0.0a13",
35+
"ga4gh.cat_vrs~=0.2.1",
3636
"pydantic==2.*"
3737
]
3838

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

143143
[tool.setuptools.packages.find]
144144
where = ["src"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Module to load and init namespace at package level."""
2+
3+
from .models import (
4+
VariantDiagnosticStudyStatement,
5+
VariantPrognosticStudyStatement,
6+
VariantTherapeuticResponseStudyStatement,
7+
)
8+
9+
__all__ = [
10+
"VariantDiagnosticStudyStatement",
11+
"VariantPrognosticStudyStatement",
12+
"VariantTherapeuticResponseStudyStatement",
13+
]

src/ga4gh/va_spec/aac_2017/models.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""AMP/ASCO/CAP 2017"""
2+
3+
from ga4gh.va_spec.base.core import (
4+
Statement,
5+
VariantDiagnosticProposition,
6+
VariantPrognosticProposition,
7+
VariantTherapeuticResponseProposition,
8+
)
9+
from pydantic import (
10+
Field,
11+
)
12+
13+
14+
class VariantDiagnosticStudyStatement(Statement):
15+
"""A statement reporting a conclusion from a single study about whether a variant is
16+
associated with a disease (a diagnostic inclusion criterion), or absence of a
17+
disease (diagnostic exclusion criterion) - based on interpretation of the study's
18+
results.
19+
"""
20+
21+
proposition: VariantDiagnosticProposition = Field(
22+
...,
23+
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.",
24+
)
25+
26+
27+
class VariantPrognosticStudyStatement(Statement):
28+
"""A statement reporting a conclusion from a single study about whether a variant is
29+
associated with a disease prognosis - based on interpretation of the study's
30+
results.
31+
"""
32+
33+
proposition: VariantPrognosticProposition = Field(
34+
...,
35+
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.",
36+
)
37+
38+
39+
class VariantTherapeuticResponseStudyStatement(Statement):
40+
"""A statement reporting a conclusion from a single study about whether a variant is
41+
associated with a therapeutic response (positive or negative) - based on
42+
interpretation of the study's results.
43+
"""
44+
45+
proposition: VariantTherapeuticResponseProposition = Field(
46+
...,
47+
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.",
48+
)

src/ga4gh/va_spec/base/__init__.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""Module to load and init namespace at package level."""
2+
3+
from .caf_study_result import CohortAlleleFrequencyStudyResult
4+
from .core import (
5+
Agent,
6+
ClinicalVariantProposition,
7+
Contribution,
8+
CoreType,
9+
DataSet,
10+
DiagnosticPredicate,
11+
Direction,
12+
Document,
13+
EvidenceLine,
14+
ExperimentalVariantFunctionalImpactProposition,
15+
InformationEntity,
16+
Method,
17+
PrognosticPredicate,
18+
Proposition,
19+
Statement,
20+
StudyGroup,
21+
StudyResult,
22+
SubjectVariantProposition,
23+
TherapeuticResponsePredicate,
24+
VariantDiagnosticProposition,
25+
VariantOncogenicityProposition,
26+
VariantPathogenicityProposition,
27+
VariantPrognosticProposition,
28+
VariantTherapeuticResponseProposition,
29+
)
30+
from .domain_entities import Condition, Therapeutic, TherapyGroup, TraitSet
31+
from .experimental_variant_functional_impact import (
32+
ExperimentalVariantFunctionalImpactStudyResult,
33+
)
34+
35+
__all__ = [
36+
"CohortAlleleFrequencyStudyResult",
37+
"InformationEntity",
38+
"StudyResult",
39+
"Proposition",
40+
"SubjectVariantProposition",
41+
"ClinicalVariantProposition",
42+
"ExperimentalVariantFunctionalImpactProposition",
43+
"DiagnosticPredicate",
44+
"VariantDiagnosticProposition",
45+
"VariantOncogenicityProposition",
46+
"VariantPathogenicityProposition",
47+
"PrognosticPredicate",
48+
"VariantPrognosticProposition",
49+
"TherapeuticResponsePredicate",
50+
"VariantTherapeuticResponseProposition",
51+
"CoreType",
52+
"Method",
53+
"Contribution",
54+
"Document",
55+
"Agent",
56+
"Direction",
57+
"DataSet",
58+
"EvidenceLine",
59+
"Statement",
60+
"StudyGroup",
61+
"TraitSet",
62+
"Condition",
63+
"TherapyGroup",
64+
"Therapeutic",
65+
"ExperimentalVariantFunctionalImpactStudyResult",
66+
]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""Cohort Allele Frequency Study Result Standard Profile"""
2+
3+
from __future__ import annotations
4+
5+
from typing import Any, Literal
6+
7+
from ga4gh.core.models import iriReference
8+
from ga4gh.va_spec.base.core import DataSet, StudyGroup, StudyResult
9+
from ga4gh.vrs.models import Allele
10+
from pydantic import Field, field_validator
11+
12+
13+
class CohortAlleleFrequencyStudyResult(StudyResult):
14+
"""A StudyResult that reports measures related to the frequency of an Allele in a cohort"""
15+
16+
type: Literal["CohortAlleleFrequencyStudyResult"] = Field(
17+
"CohortAlleleFrequencyStudyResult",
18+
description="MUST be 'CohortAlleleFrequencyStudyResult'.",
19+
)
20+
sourceDataSet: DataSet | None = Field(
21+
None,
22+
description="The dataset from which the CohortAlleleFrequencyStudyResult was reported.",
23+
)
24+
focus: None = Field(
25+
None, exclude=True, repr=False
26+
) # extends property in JSON Schema. Should not be used
27+
focusAllele: Allele | iriReference = Field(
28+
..., description="The Allele for which frequency results are reported."
29+
)
30+
focusAlleleCount: int = Field(
31+
..., description="The number of occurrences of the focusAllele in the cohort."
32+
)
33+
locusAlleleCount: int = Field(
34+
...,
35+
description="The number of occurrences of all alleles at the locus in the cohort.",
36+
)
37+
focusAlleleFrequency: float = Field(
38+
..., description="The frequency of the focusAllele in the cohort."
39+
)
40+
cohort: StudyGroup = Field(
41+
..., description="The cohort from which the frequency was derived."
42+
)
43+
subCohortFrequency: list[CohortAlleleFrequencyStudyResult] | None = Field(
44+
None,
45+
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.",
46+
)
47+
ancillaryResults: dict | None = None
48+
qualityMeasures: dict | None = None
49+
50+
def __getattribute__(self, name: str) -> Any: # noqa: ANN401
51+
"""Retrieve the value of the specified attribute
52+
53+
:param name: Name of attribute being accessed
54+
:return: The value of the specified attribute
55+
:raises ValueError: If the attribute being accessed is not already defined in
56+
CohortAlleleFrequencyStudyResult or the attribute is `focus`
57+
"""
58+
if name == "focus":
59+
err_msg = f"'{type(self).__name__!r}' object has no attribute '{name!r}'"
60+
raise AttributeError(err_msg)
61+
return super().__getattribute__(name)
62+
63+
@field_validator("focus", mode="before")
64+
def set_focus_to_none(cls, v: Any) -> None: # noqa: ANN401, N805
65+
"""Set focus to None"""
66+
return
67+
68+
69+
del CohortAlleleFrequencyStudyResult.model_fields[
70+
"focus"
71+
] # Need to remove inherited property

0 commit comments

Comments
 (0)