Skip to content

Commit

Permalink
feat: make compatible with 2024 May 15 schema of ClinVar (#221) (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored May 31, 2024
1 parent a7480dd commit c0d1a4c
Show file tree
Hide file tree
Showing 13 changed files with 1,824 additions and 70 deletions.
309 changes: 298 additions & 11 deletions clinvar_api/models/sub_payload.py

Large diffs are not rendered by default.

123 changes: 118 additions & 5 deletions clinvar_api/msg/sub_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class StructVarMethodType(Enum):


class ClinicalSignificanceDescription(Enum):
"""Allowed values for the ``clinicalSignificanceDescription``.
"""Allowed values for the ``clinicalSignificanceDescription`` and
``germlineClassificationDescription``.
The values of the enumeration map to the values used by the ClinVar submission API.
"""
Expand Down Expand Up @@ -190,6 +191,37 @@ class ModeOfInheritance(Enum):
OLIGOGENIC_INHERITANCE = "Oligogenic inheritance"


class OncogenicityClassificationDescription(Enum):
ONCOGENIC = "Oncogenic"
LIKELY_ONCOGENIC = "Likely Oncogenic"
UNCERTAIN_SIGNIFICANCE = ("Uncertain significance",)
LIKELY_BENIGN = ("Likely benign",)
BENIGN = "Benign"


class SomaticClinicalImpactClassificationDescription(Enum):
STRONG = "Tier I - Strong"
POTENTIAL = "Tier II - Potential"
UNKNOWN = "Tier III - Unknown"
BENIGN_LIKELY_BENIGN = "Tier IV - Benign/Likely benign"


class PresenceOfSomaticVariantInNormalTissue(Enum):
PRESENT = "present"
ABSENT = "absent"
NOT_TESTED = "not tested"


class SomaticClinicalImpactAssertionType(Enum):
THERAPEUTIC_SENSITIVITY_RESPONSE = "therapeutic: sensitivity/response"
THERAPEUTIC_RESISTANCE = "therapeutic: resistance"
THERAPEUTIC_REDUCED_SENSITIVITY = "therapeutic: reduced sensitivity"
DIAGNOSTIC_SUPPORTS_DIAGNOSIS = "diagnostic: supports diagnosis"
DIAGNOSTIC_EXCLUDES_DIAGNOSIS = "diagnostic: excludes diagnosis"
PROGNOSTIC_BETTER_OUTCOME = "prognostic: better outcome"
PROGNOSTIC_POOR_OUTCOME = "prognostic: poor outcome"


class RecordStatus(Enum):
NOVEL = "novel"
UPDATE = "update"
Expand Down Expand Up @@ -284,10 +316,19 @@ class _SubmissionObservedInBase(BaseModel):
structVarMethodType: typing.Optional[StructVarMethodType] = None


class SubmissionObservedIn(_SubmissionObservedInBase):
class SubmissionObservedInGermline(_SubmissionObservedInBase):
model_config = ConfigDict(frozen=True)


class SubmissionObservedInSomatic(_SubmissionObservedInBase):
model_config = ConfigDict(frozen=True)

presenceOfSomaticVariantInNormalTissue: typing.Optional[
PresenceOfSomaticVariantInNormalTissue
] = None
somaticVariantAlleleFraction: typing.Optional[float] = None


class SubmissionHaplotypeSet(BaseModel):
model_config = ConfigDict(frozen=True)

Expand Down Expand Up @@ -352,14 +393,22 @@ class SubmissionDrugResponse(BaseModel):
condition: typing.Optional[typing.List[SubmissionCondition]] = None


class SubmissionConditionSet(BaseModel):
class SubmissionConditionSetGermline(BaseModel):
model_config = ConfigDict(frozen=True)

condition: typing.Optional[typing.List[SubmissionCondition]] = None
drugResponse: typing.Optional[typing.List[SubmissionDrugResponse]] = None
multipleConditionExplanation: typing.Optional[MultipleConditionExplanation] = None


class SubmissionConditionSetSomatic(BaseModel):
model_config = ConfigDict(frozen=True)

condition: typing.List[SubmissionCondition]
drugResponse: typing.Optional[typing.List[SubmissionDrugResponse]] = None
multipleConditionExplanation: typing.Optional[MultipleConditionExplanation] = None


class SubmissionCompoundHeterozygoteSetVariantSet(BaseModel):
model_config = ConfigDict(frozen=True)

Expand Down Expand Up @@ -416,11 +465,65 @@ class _SubmissionClinvarSubmissionBase(BaseModel):


class SubmissionClinvarSubmission(_SubmissionClinvarSubmissionBase):
"""Old format of ClinVar submission.
The 2024 ClinVar has split germline, somatic clinical impact, and somatic
oncogenicity submission.
"""

model_config = ConfigDict(frozen=True)

clinicalSignificance: SubmissionClinicalSignificance
conditionSet: SubmissionConditionSet
observedIn: typing.List[SubmissionObservedIn]
conditionSet: SubmissionConditionSetGermline
observedIn: typing.List[SubmissionObservedInGermline]


class SomaticClinicalImpactClassification(_SubmissionClinicalSignificanceBase):
"""Details of somatic clinical impact classification."""

clinicalImpactClassificationDescription: SomaticClinicalImpactClassificationDescription
assertionTypeForClinicalImpact: typing.Optional[SomaticClinicalImpactAssertionType] = None
drugForTherapeuticAssertion: typing.Optional[str] = None


class SubmissionClinicalImpactSubmission(_SubmissionClinvarSubmissionBase):
"""Submission relating to somatic clinical impact."""

clinicalImpactClassification: SomaticClinicalImpactClassification
conditionSet: SubmissionConditionSetSomatic
observedIn: typing.List[SubmissionObservedInSomatic]


class SomaticOncogenicityClassification(_SubmissionClinicalSignificanceBase):
"""Details of somatic oncogenicity classification."""

oncogenicityClassificationDescription: OncogenicityClassificationDescription


class SubmissionOncogenicitySubmission(_SubmissionClinvarSubmissionBase):
"""Submission relating to somatic clinical impact."""

oncogenicityClassification: SomaticOncogenicityClassification
conditionSet: SubmissionConditionSetSomatic
observedIn: typing.List[SubmissionObservedInSomatic]


class GermlineClassification(_SubmissionClinicalSignificanceBase):
model_config = ConfigDict(frozen=True)

germlineClassificationDescription: ClinicalSignificanceDescription
modeOfInheritance: ModeOfInheritance
customClassificationScore: typing.Optional[float] = None
explanationOfDrugResponse: typing.Optional[str] = None
explanationOfOtherClassification: typing.Optional[str] = None


class SubmissionGermlineSubmission(_SubmissionClinvarSubmissionBase):
"""Submission relating to somatic clinical impact."""

germlineClassification: GermlineClassification
conditionSet: SubmissionConditionSetGermline
observedIn: typing.List[SubmissionObservedInGermline]


class SubmissionContainer(BaseModel):
Expand All @@ -431,6 +534,16 @@ class SubmissionContainer(BaseModel):
assertionCriteria: typing.Optional[SubmissionAssertionCriteria] = None
behalfOrgID: typing.Optional[int] = None
clinvarDeletion: typing.Optional[SubmissionClinvarDeletion] = None
#: The "old format" ClinVar submission, mutually exclusive with
#: "clinicalImpactSubmission", "oncogenicitySubmission", and "germlineSubmission".
clinvarSubmission: typing.Optional[typing.List[SubmissionClinvarSubmission]] = None
#: ClinVar Submission Set for germline variants
germlineSubmission: typing.Optional[typing.List[SubmissionGermlineSubmission]] = None
#: ClinVar Submission Set for somatic variants with oncogenicityClassification.
oncogenicitySubmission: typing.Optional[typing.List[SubmissionOncogenicitySubmission]] = None
#: ClinVar Submission Set for somatic variants with clinicalImpactClassification.
clinicalImpactSubmission: typing.Optional[typing.List[SubmissionClinicalImpactSubmission]] = (
None
)
clinvarSubmissionReleaseStatus: typing.Optional[ReleaseStatus] = None
submissionName: typing.Optional[str] = None
Loading

0 comments on commit c0d1a4c

Please sign in to comment.