diff --git a/clinvar_api/models/sub_payload.py b/clinvar_api/models/sub_payload.py index 6a2fa7f..b252d57 100644 --- a/clinvar_api/models/sub_payload.py +++ b/clinvar_api/models/sub_payload.py @@ -23,8 +23,12 @@ ConditionDb, ModeOfInheritance, MultipleConditionExplanation, + OncogenicityClassificationDescription, + PresenceOfSomaticVariantInNormalTissue, RecordStatus, ReleaseStatus, + SomaticClinicalImpactAssertionType, + SomaticClinicalImpactClassificationDescription, StructVarMethodType, VariantType, ) @@ -182,17 +186,17 @@ class _SubmissionObservedInBase(BaseModel): struct_var_method_type: typing.Optional[StructVarMethodType] = None -class SubmissionObservedIn(_SubmissionObservedInBase): +class SubmissionObservedInGermline(_SubmissionObservedInBase): model_config = ConfigDict(frozen=True) - def to_msg(self) -> msg.SubmissionObservedIn: + def to_msg(self) -> msg.SubmissionObservedInGermline: clinical_features = None if self.clinical_features: clinical_features = [ SubmissionClinicalFeature.to_msg(msg_feature) for msg_feature in self.clinical_features ] - return msg.SubmissionObservedIn( + return msg.SubmissionObservedInGermline( affectedStatus=self.affected_status, alleleOrigin=self.allele_origin, collectionMethod=self.collection_method, @@ -203,6 +207,34 @@ def to_msg(self) -> msg.SubmissionObservedIn: ) +class SubmissionObservedInSomatic(_SubmissionObservedInBase): + model_config = ConfigDict(frozen=True) + + presence_of_somatic_variant_in_normal_tissue: typing.Optional[ + PresenceOfSomaticVariantInNormalTissue + ] = None + somatic_variant_allele_fraction: typing.Optional[float] = None + + def to_msg(self) -> msg.SubmissionObservedInSomatic: + clinical_features = None + if self.clinical_features: + clinical_features = [ + SubmissionClinicalFeature.to_msg(msg_feature) + for msg_feature in self.clinical_features + ] + return msg.SubmissionObservedInSomatic( + affectedStatus=self.affected_status, + alleleOrigin=self.allele_origin, + collectionMethod=self.collection_method, + clinicalFeatures=clinical_features, + clinicalFeaturesComment=self.clinical_features_comment, + numberOfIndividuals=self.number_of_individuals, + structVarMethodType=self.struct_var_method_type, + presenceOfSomaticVariantInNormalTissue=self.presence_of_somatic_variant_in_normal_tissue, + somaticVariantAlleleFraction=self.somatic_variant_allele_fraction, + ) + + class SubmissionHaplotypeSet(BaseModel): model_config = ConfigDict(frozen=True) @@ -331,21 +363,40 @@ def to_msg(self) -> msg.SubmissionDrugResponse: ) -class SubmissionConditionSet(BaseModel): +class SubmissionConditionSetGermline(BaseModel): model_config = ConfigDict(frozen=True) condition: typing.Optional[typing.List[SubmissionCondition]] = None drug_response: typing.Optional[typing.List[SubmissionDrugResponse]] = None multiple_condition_explanation: typing.Optional[MultipleConditionExplanation] = None - def to_msg(self) -> msg.SubmissionConditionSet: + def to_msg(self) -> msg.SubmissionConditionSetGermline: condition = None if self.condition: condition = [msg_condition.to_msg() for msg_condition in self.condition] drug_response = None if self.drug_response: drug_response = [msg_response.to_msg() for msg_response in self.drug_response] - return msg.SubmissionConditionSet( + return msg.SubmissionConditionSetGermline( + condition=condition, + drugResponse=drug_response, + multipleConditionExplanation=self.multiple_condition_explanation, + ) + + +class SubmissionConditionSetSomatic(BaseModel): + model_config = ConfigDict(frozen=True) + + condition: typing.List[SubmissionCondition] + drug_response: typing.Optional[typing.List[SubmissionDrugResponse]] = None + multiple_condition_explanation: typing.Optional[MultipleConditionExplanation] = None + + def to_msg(self) -> msg.SubmissionConditionSetSomatic: + condition = [msg_condition.to_msg() for msg_condition in self.condition] + drug_response = None + if self.drug_response: + drug_response = [msg_response.to_msg() for msg_response in self.drug_response] + return msg.SubmissionConditionSetSomatic( condition=condition, drugResponse=drug_response, multipleConditionExplanation=self.multiple_condition_explanation, @@ -402,13 +453,13 @@ def to_msg(self) -> msg.SubmissionClinicalSignificance: citation = [msg_citation.to_msg() for msg_citation in self.citation] return msg.SubmissionClinicalSignificance( clinicalSignificanceDescription=self.clinical_significance_description, - citation=citation, - comment=self.comment, customAssertionScore=self.custom_assertion_score, - dateLastEvaluated=self.date_last_evaluated, explanationOfDrugResponse=self.explanation_of_drug_response, explanationOfOtherClinicalSignificance=self.explanation_of_other_clinical_significance, modeOfInheritance=self.mode_of_inheritance, + citation=citation, + comment=self.comment, + dateLastEvaluated=self.date_last_evaluated, ) @@ -435,8 +486,8 @@ class SubmissionClinvarSubmission(_SubmissionClinvarSubmissionBase): model_config = ConfigDict(frozen=True) clinical_significance: SubmissionClinicalSignificance - condition_set: SubmissionConditionSet - observed_in: typing.List[SubmissionObservedIn] + condition_set: SubmissionConditionSetGermline + observed_in: typing.List[SubmissionObservedInGermline] #: Additional information from import. Will not be used for conversion to message but can be converted back to #: external formats. extra_data: typing.Optional[typing.Dict[str, typing.Any]] = None @@ -481,6 +532,219 @@ def to_msg(self) -> msg.SubmissionClinvarSubmission: ) +class SomaticClinicalImpactClassification(_SubmissionClinicalSignificanceBase): + """Details of somatic clinical impact classification.""" + + clinical_impact_classification_description: SomaticClinicalImpactClassificationDescription + assertion_type_for_clinical_impact: typing.Optional[SomaticClinicalImpactAssertionType] = None + drug_for_therapeutic_assertion: typing.Optional[str] = None + + def to_msg(self) -> msg.SomaticClinicalImpactClassification: + citation = None + if self.citation: + citation = [msg_citation.to_msg() for msg_citation in self.citation] + return msg.SomaticClinicalImpactClassification( + clinicalImpactClassificationDescription=self.clinical_impact_classification_description, + assertionTypeForClinicalImpact=self.assertion_type_for_clinical_impact, + drugForTherapeuticAssertion=self.drug_for_therapeutic_assertion, + citation=citation, + comment=self.comment, + dateLastEvaluated=self.date_last_evaluated, + ) + + +class SubmissionClinicalImpactSubmission(_SubmissionClinvarSubmissionBase): + model_config = ConfigDict(frozen=True) + + clinical_impact_classification: SomaticClinicalImpactClassification + condition_set: SubmissionConditionSetSomatic + observed_in: typing.List[SubmissionObservedInSomatic] + #: Additional information from import. Will not be used for conversion to message but can be converted back to + #: external formats. + extra_data: typing.Optional[typing.Dict[str, typing.Any]] = None + + def to_msg(self) -> msg.SubmissionClinicalImpactSubmission: + compound_heterozygote_set = None + if self.compound_heterozygote_set: + compound_heterozygote_set = self.compound_heterozygote_set.to_msg() + diplotype_set = None + if self.diplotype_set: + diplotype_set = self.diplotype_set.to_msg() + distinct_chromosomes_set = None + if self.distinct_chromosomes_set: + distinct_chromosomes_set = self.distinct_chromosomes_set.to_msg() + haplotype_set = None + if self.haplotype_set: + haplotype_set = self.haplotype_set.to_msg() + haplotype_single_variant_set = None + if self.haplotype_single_variant_set: + haplotype_single_variant_set = self.haplotype_single_variant_set.to_msg() + phase_unknown_set = None + if self.phase_unknown_set: + phase_unknown_set = self.phase_unknown_set.to_msg() + variant_set = None + if self.variant_set: + variant_set = self.variant_set.to_msg() + return msg.SubmissionClinicalImpactSubmission( + clinicalImpactClassification=self.clinical_impact_classification.to_msg(), + conditionSet=self.condition_set.to_msg(), + observedIn=[msg_observed_in.to_msg() for msg_observed_in in self.observed_in], + recordStatus=self.record_status, + clinvarAccession=self.clinvar_accession, + compoundHeterozygoteSet=compound_heterozygote_set, + diplotypeSet=diplotype_set, + distinctChromosomesSet=distinct_chromosomes_set, + haplotypeSet=haplotype_set, + haplotypeSingleVariantSet=haplotype_single_variant_set, + localID=self.local_id, + localKey=self.local_key, + phaseUnknownSet=phase_unknown_set, + variantSet=variant_set, + ) + + +class SomaticOncogenicityClassification(_SubmissionClinicalSignificanceBase): + """Details of somatic clinical impact classification.""" + + oncogenicity_classification_description: OncogenicityClassificationDescription + + def to_msg(self) -> msg.SomaticOncogenicityClassification: + citation = None + if self.citation: + citation = [msg_citation.to_msg() for msg_citation in self.citation] + return msg.SomaticOncogenicityClassification( + oncogenicityClassificationDescription=self.oncogenicity_classification_description, + citation=citation, + comment=self.comment, + dateLastEvaluated=self.date_last_evaluated, + ) + + +class SubmissionOncogenicitySubmission(_SubmissionClinvarSubmissionBase): + model_config = ConfigDict(frozen=True) + + oncogenicity_classification: SomaticOncogenicityClassification + condition_set: SubmissionConditionSetSomatic + observed_in: typing.List[SubmissionObservedInSomatic] + #: Additional information from import. Will not be used for conversion to message but can be converted back to + #: external formats. + extra_data: typing.Optional[typing.Dict[str, typing.Any]] = None + + def to_msg(self) -> msg.SubmissionOncogenicitySubmission: + compound_heterozygote_set = None + if self.compound_heterozygote_set: + compound_heterozygote_set = self.compound_heterozygote_set.to_msg() + diplotype_set = None + if self.diplotype_set: + diplotype_set = self.diplotype_set.to_msg() + distinct_chromosomes_set = None + if self.distinct_chromosomes_set: + distinct_chromosomes_set = self.distinct_chromosomes_set.to_msg() + haplotype_set = None + if self.haplotype_set: + haplotype_set = self.haplotype_set.to_msg() + haplotype_single_variant_set = None + if self.haplotype_single_variant_set: + haplotype_single_variant_set = self.haplotype_single_variant_set.to_msg() + phase_unknown_set = None + if self.phase_unknown_set: + phase_unknown_set = self.phase_unknown_set.to_msg() + variant_set = None + if self.variant_set: + variant_set = self.variant_set.to_msg() + return msg.SubmissionOncogenicitySubmission( + oncogenicityClassification=self.oncogenicity_classification.to_msg(), + conditionSet=self.condition_set.to_msg(), + observedIn=[msg_observed_in.to_msg() for msg_observed_in in self.observed_in], + recordStatus=self.record_status, + clinvarAccession=self.clinvar_accession, + compoundHeterozygoteSet=compound_heterozygote_set, + diplotypeSet=diplotype_set, + distinctChromosomesSet=distinct_chromosomes_set, + haplotypeSet=haplotype_set, + haplotypeSingleVariantSet=haplotype_single_variant_set, + localID=self.local_id, + localKey=self.local_key, + phaseUnknownSet=phase_unknown_set, + variantSet=variant_set, + ) + + +class GermlineClassification(_SubmissionClinicalSignificanceBase): + """Details of somatic clinical impact classification.""" + + germline_classification_description: ClinicalSignificanceDescription + mode_of_inheritance: ModeOfInheritance + custom_classification_score: typing.Optional[float] = None + explanation_of_drug_response: typing.Optional[str] = None + explanation_of_other_classification: typing.Optional[str] = None + + def to_msg(self) -> msg.GermlineClassification: + citation = None + if self.citation: + citation = [msg_citation.to_msg() for msg_citation in self.citation] + return msg.GermlineClassification( + germlineClassificationDescription=self.germline_classification_description, + modeOfInheritance=self.mode_of_inheritance, + customClassificationScore=self.custom_classification_score, + explanationOfDrugResponse=self.explanation_of_drug_response, + explanationOfOtherClassification=self.explanation_of_other_classification, + citation=citation, + comment=self.comment, + dateLastEvaluated=self.date_last_evaluated, + ) + + +class SubmissionGermlineSubmission(_SubmissionClinvarSubmissionBase): + model_config = ConfigDict(frozen=True) + + germline_classification: GermlineClassification + condition_set: SubmissionConditionSetGermline + observed_in: typing.List[SubmissionObservedInGermline] + #: Additional information from import. Will not be used for conversion to message but can be converted back to + #: external formats. + extra_data: typing.Optional[typing.Dict[str, typing.Any]] = None + + def to_msg(self) -> msg.SubmissionGermlineSubmission: + compound_heterozygote_set = None + if self.compound_heterozygote_set: + compound_heterozygote_set = self.compound_heterozygote_set.to_msg() + diplotype_set = None + if self.diplotype_set: + diplotype_set = self.diplotype_set.to_msg() + distinct_chromosomes_set = None + if self.distinct_chromosomes_set: + distinct_chromosomes_set = self.distinct_chromosomes_set.to_msg() + haplotype_set = None + if self.haplotype_set: + haplotype_set = self.haplotype_set.to_msg() + haplotype_single_variant_set = None + if self.haplotype_single_variant_set: + haplotype_single_variant_set = self.haplotype_single_variant_set.to_msg() + phase_unknown_set = None + if self.phase_unknown_set: + phase_unknown_set = self.phase_unknown_set.to_msg() + variant_set = None + if self.variant_set: + variant_set = self.variant_set.to_msg() + return msg.SubmissionGermlineSubmission( + germlineClassification=self.germline_classification.to_msg(), + conditionSet=self.condition_set.to_msg(), + observedIn=[msg_observed_in.to_msg() for msg_observed_in in self.observed_in], + recordStatus=self.record_status, + clinvarAccession=self.clinvar_accession, + compoundHeterozygoteSet=compound_heterozygote_set, + diplotypeSet=diplotype_set, + distinctChromosomesSet=distinct_chromosomes_set, + haplotypeSet=haplotype_set, + haplotypeSingleVariantSet=haplotype_single_variant_set, + localID=self.local_id, + localKey=self.local_key, + phaseUnknownSet=phase_unknown_set, + variantSet=variant_set, + ) + + class SubmissionContainer(BaseModel): model_config = ConfigDict(frozen=True) @@ -488,6 +752,11 @@ class SubmissionContainer(BaseModel): behalf_org_id: typing.Optional[int] = None clinvar_deletion: typing.Optional[SubmissionClinvarDeletion] = None clinvar_submission: typing.Optional[typing.List[SubmissionClinvarSubmission]] = None + germline_submission: typing.Optional[typing.List[SubmissionGermlineSubmission]] = None + oncogenicity_submission: typing.Optional[typing.List[SubmissionOncogenicitySubmission]] = None + clinical_impact_submission: typing.Optional[typing.List[SubmissionClinicalImpactSubmission]] = ( + None + ) clinvar_submission_release_status: typing.Optional[ReleaseStatus] = None submission_name: typing.Optional[str] = None @@ -503,11 +772,29 @@ def to_msg(self) -> msg.SubmissionContainer: clinvar_submission = [ msg_submission.to_msg() for msg_submission in self.clinvar_submission ] + germline_submission = None + if self.germline_submission: + germline_submission = [ + msg_submission.to_msg() for msg_submission in self.germline_submission + ] + oncogenicity_submission = None + if self.oncogenicity_submission: + oncogenicity_submission = [ + msg_submission.to_msg() for msg_submission in self.oncogenicity_submission + ] + clinical_impact_submission = None + if self.clinical_impact_submission: + clinical_impact_submission = [ + msg_submission.to_msg() for msg_submission in self.clinical_impact_submission + ] return msg.SubmissionContainer( assertionCriteria=assertion_criteria, behalfOrgID=self.behalf_org_id, clinvarDeletion=clinvar_deletion, clinvarSubmission=clinvar_submission, + germlineSubmission=germline_submission, + oncogenicitySubmission=oncogenicity_submission, + clinicalImpactSubmission=clinical_impact_submission, clinvarSubmissionReleaseStatus=self.clinvar_submission_release_status, submissionName=self.submission_name, ) diff --git a/clinvar_api/msg/sub_payload.py b/clinvar_api/msg/sub_payload.py index ac3061a..c9c6530 100644 --- a/clinvar_api/msg/sub_payload.py +++ b/clinvar_api/msg/sub_payload.py @@ -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. """ @@ -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" @@ -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) @@ -352,7 +393,7 @@ 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 @@ -360,6 +401,14 @@ class SubmissionConditionSet(BaseModel): 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) @@ -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): @@ -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 diff --git a/clinvar_api/schemas/submission_schema.json b/clinvar_api/schemas/submission_schema.json index 690c428..6b50b7b 100644 --- a/clinvar_api/schemas/submission_schema.json +++ b/clinvar_api/schemas/submission_schema.json @@ -1,9 +1,38 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", - "anyOf": [ - {"required": ["clinvarSubmission"]}, - {"required": ["clinvarDeletion"]} + "allOf": [ + { + "if": { + "required": ["clinvarSubmission"] + }, + "then": { + "allOf": [ + {"not": {"required": ["clinicalImpactSubmission"]}, + "errors": {"not": "old format clinvarSubmission and new format clinicalImpactSubmission cannot appear in a single submission"} + }, + {"not": {"required": ["oncogenicitySubmission"]}, + "errors": {"not": "old format clinvarSubmission and new format oncogenicitySubmission cannot appear in a single submission"} + }, + {"not": {"required": ["germlineSubmission"]}, + "errors": {"not": "old format clinvarSubmission and new format germlineSubmission cannot appear in a single submission"} + } + ] + }, + "else": { + "allOf": [ + {"not": {"required": ["clinicalImpactSubmission","oncogenicitySubmission"]}, + "errors": {"not": "clinicalImpactSubmission and oncogenicitySubmission cannot appear in a single submission"} + }, + {"not": {"required": ["oncogenicitySubmission", "germlineSubmission"]}, + "errors": {"not": "germlineSubmission and oncogenicitySubmission cannot appear in a single submission"} + }, + {"not": {"required": ["germlineSubmission", "clinicalImpactSubmission"]}, + "errors": {"not": "germlineSubmission and clinicalImpactSubmission cannot appear in a single submission"} + } + ] + } + } ], "properties": { "clinvarDeletion": { @@ -204,6 +233,350 @@ "maxItems": "no more than 10000 clinvarSubmission allowed" } }, + "germlineSubmission": { + "title": "ClinVar Submission Set for germline variants", + "description": "A set of germline variant submissions", + "type": "array", + "minItems": 1, + "maxItems": 10000, + "items": + { + "type": "object", + "title": "ClinVar Germline Submission", + "description": "Submissions to ClinVar are considered 'variant-level' (not case-level or patient-specific), because they are focused on the variant or set of variants that was classified. One of variantSet, haplotypeSet, haplotypeSingleVariantSet, phaseUnknownSet, distinctChromosomesSet, diplotypeSet, compoundHeterozygoteSet is required to define the variant or set of variants that was classified.", + "required": [ + "germlineClassification", + "observedIn", + "conditionSet" + ], + "$ref": "#/definitions/baseSubmissionType", + "properties": { + "germlineClassification": { + "type": "object", + "description": "Germline classification", + "$ref": "#/definitions/baseClassificationType", + "required": ["germlineClassificationDescription"], + "properties": { + "germlineClassificationDescription": { + "type": "string", + "description": "The Germline classification of the variant for the submitted condition, equivalent to Germline classification in the submission spreadsheet.", + "enum": [ + "Pathogenic", + "Likely pathogenic", + "Uncertain significance", + "Likely benign", + "Benign", + "Pathogenic, low penetrance", + "Uncertain risk allele", + "Likely pathogenic, low penetrance", + "Established risk allele", + "Likely risk allele", + "affects", + "association", + "drug response", + "confers sensitivity", + "protective", + "other", + "not provided" + ] + }, + "modeOfInheritance": { + "type": "string", + "description": "The mode of inheritance specific to the variant-disease pair, not generally for the disease.", + "enum": [ + "Autosomal dominant inheritance", + "Autosomal recessive inheritance", + "Mitochondrial inheritance", + "Genetic anticipation", + "Sporadic", + "Sex-limited autosomal dominant", + "X-linked recessive inheritance", + "X-linked dominant inheritance", + "Y-linked inheritance", + "Other", + "X-linked inheritance", + "Codominant", + "Semidominant inheritance", + "Autosomal unknown", + "Autosomal dominant inheritance with maternal imprinting", + "Autosomal dominant inheritance with paternal imprinting", + "Multifactorial inheritance", + "Unknown mechanism", + "Oligogenic inheritance" + ] + }, + "customClassificationScore": { + "type": "number", + "description": "The final score, or point value, calculated when the assertion method uses a point-based scoring system, e.g. ACMG/ClinGen CNV Guidelines, 2019 (PMID: 31690835). The assertion method must also be provided. " + }, + "explanationOfDrugResponse": { + "type": "string", + "description": "Required for a record with clinical significance of 'drug response'. Please provide a value describing the drug response, e.g. 'likely responsive'. This value must be short for display purposes. A longer explanation should be provided in the 'Comment on clinical significance'." + }, + "explanationOfOtherClassification": { + "type": "string", + "description": "Required if 'other' is selected for clinical significance. Please provide the new value for clinical significance, e.g. pseudodeficiency allele. This value must be short for display purposes. A longer explanation should be provided in the 'Comment on clinical significance'." + } + }, + "unevaluatedProperties": false + }, + "observedIn": { + "type": "array", + "minItems": 1, + "items": + { + "type": "object", + "$ref": "#/definitions/baseObservationType", + "unevaluatedProperties": false + }, + "errors": {"minItems": "Empty list of observedIn not allowed"} + }, + "conditionSet": { + "type": "object", + "description": "The condition for which the variant is interpreted. Detailed information about reporting condition is available at https://www.ncbi.nlm.nih.gov/clinvar/docs/faq_submitters/#pheno If multiple conditions are submitted for a variant, this indicates that the variant was interpreted for the combination of conditions in the same individual(s). i.e. this variant causes both condition A and condition B in the same individual. This scenario is most common for a new disease or syndrome that does not yet have a name and is described by several clinical features. If you want to indicate that the variant has been interpreted for more than one condition, please submit these as separate records. i.e. this variant causes condition A in some individuals and causes disease B in other individuals. Provide only one name or identifier for a condition; do not provide multiple names or identifiers for the same condition.", + "oneOf": [ + { + "required": ["condition"] + }, + { + "allOf": [ + {"required": ["drugResponse"]}, + {"not": { "required": ["multipleConditionExplanation"]}} + ] + } + ], + "properties": { + "multipleConditionExplanation": { + "type": "string", + "enum": [ + "Novel disease", + "Uncertain", + "Co-occurring" + ], + "description": "Variants in ClinVar are typically classified for a single condition (disease or drug response). If more than one condition is provided in the conditionSet, this field is required and explains why multiple conditions are valid. Options are \"Novel disease\" when a new disease is unnamed and only described by a set of clinical features (HPO ids); \"Uncertain\" when a variant is classified for several related diseases and it may be uncertain whether the variant causes one or several of them; and \"Co-occurring\" when a variant causes more than one disease in the same individual (this is expected to be rare)." + }, + "condition": { + "description": "The condition must be provided as either a database identifier or a name, but not both. A database identifier is preferred by ClinVar; a name should be provided only if there is no database identifier available.", + "$ref": "#/definitions/conditionType" + }, + "drugResponse": { + "description": "The drug Response evaluated specified by database ID or drug name, but not both", + "$ref": "#/definitions/drugResponseType" + } + }, + "additionalProperties": false + } + }, + "unevaluatedProperties": false, + "if": { + "properties": { + "germlineClassification": { + "properties" : { + "germlineClassificationDescription": { "const": "drug response" } + } + } + } + }, + "then": { + "properties": { + "conditionSet": { + "required": ["drugResponse"], + "errors": {"required": "when germlineClassificationDescription is \"drug response\", conditionSet.drugResponse is a required property"} + } + } + }, + "else" : { + "properties": { + "conditionSet": { + "required": ["condition"], + "errors": {"required": "conditionSet.drugResponse is allowed only when germlineClassificationDescription is \"drug response\""} + } + } + } + }, + "errors": { + "minItems": "Empty list of germlineSubmission not allowed", + "maxItems": "no more than 10000 germlineSubmission allowed" + } + }, + "oncogenicitySubmission": { + "title": "ClinVar Submission Set for somatic variants with oncogenicityClassification", + "description": "A set of somatic variants with oncogenicityClassification", + "type": "array", + "minItems": 1, + "maxItems": 10000, + "items": + { + "type": "object", + "title": "ClinVar somatic oncogenicity Submission", + "description": "Submissions to ClinVar are considered 'variant-level' (not case-level or patient-specific), because they are focused on the variant or set of variants that was classified. One of variantSet, haplotypeSet, haplotypeSingleVariantSet, phaseUnknownSet, distinctChromosomesSet, diplotypeSet, compoundHeterozygoteSet is required to define the variant or set of variants that was classified.", + "$ref": "#/definitions/baseSubmissionType", + "required": [ + "oncogenicityClassification", + "observedIn", + "conditionSet" + ], + "properties": { + "oncogenicityClassification": { + "type": "object", + "description": "Oncogenicity classification", + "$ref": "#/definitions/baseClassificationType", + "required": ["oncogenicityClassificationDescription"], + "properties": { + "oncogenicityClassificationDescription": { + "type": "string", + "description": "For somatic variants, either “somaticClassificationClinicalImpact” or “oncogenicityClassification” is required. If you have both types of classifications for the same variant and tumor type, provide the classifications on separate entries. ", + "enum": [ + "Oncogenic", + "Likely oncogenic", + "Uncertain significance", + "Likely benign", + "Benign" + ] + } + }, + "unevaluatedProperties": false + }, + "observedIn": { + "type": "array", + "minItems": 1, + "items": + { + "$ref": "#/definitions/baseObservationType", + "properties": { + "presenceOfSomaticVariantInNormalTissue": { + "type": "string", + "description": "Optional. Indicate whether the variant was present or absent in normal tissue, or that normal tissue was not tested.", + "enum": [ + "present", "absent", "not tested" + ] + }, + "somaticVariantAlleleFraction": { + "type": "number", + "description": "Optional. Indicate the variant allele fraction (or frequency) observed in this tumor, expressed as a percentage, e.g. 20." + } + }, + "unevaluatedProperties": false + }, + "errors": {"minItems": "Empty list of observedIn not allowed"} + }, + "conditionSet": { + "type": "object", + "description": "The condition for which the variant is classified. Detailed information about reporting condition is available at https://www.ncbi.nlm.nih.gov/clinvar/docs/faq_submitters/#pheno If multiple conditions are submitted for a variant, this indicates that the variant was interpreted for the combination of conditions in the same individual(s). i.e. this variant causes both condition A and condition B in the same individual. This scenario is most common for a new disease or syndrome that does not yet have a name and is described by several clinical features. If you want to indicate that the variant has been interpreted for more than one condition, please submit these as separate records. i.e. this variant causes condition A in some individuals and causes disease B in other individuals. Provide only one name or identifier for a condition; do not provide multiple names or identifiers for the same condition.", + "required": ["condition"], + "properties": { + "condition": { + "description": "The condition must be provided as either a database identifier or a name, but not both. A database identifier is preferred by ClinVar; a name should be provided only if there is no database identifier available.", + "$ref": "#/definitions/conditionType" + } + }, + "unevaluatedProperties": false + } + }, + "unevaluatedProperties": false + }, + "errors": { + "minItems": "Empty list of oncogenicitySubmission not allowed", + "maxItems": "no more than 10000 oncogenicitySubmission allowed" + } + }, + "clinicalImpactSubmission": { + "title": "ClinVar Submission Set for somatic variants with clinicalImpactClassification", + "description": "A set of somatic variants with clinicalImpactClassification", + "type": "array", + "minItems": 1, + "maxItems": 10000, + "items": + { + "type": "object", + "title": "ClinVar somatic clinicalImpact Submission", + "description": "Submissions to ClinVar are considered 'variant-level' (not case-level or patient-specific), because they are focused on the variant or set of variants that was classified. One of variantSet, haplotypeSet, haplotypeSingleVariantSet, phaseUnknownSet, distinctChromosomesSet, diplotypeSet, compoundHeterozygoteSet is required to define the variant or set of variants that was classified.", + "$ref": "#/definitions/baseSubmissionType", + "required": [ + "clinicalImpactClassification", + "observedIn", + "conditionSet" + ], + "properties": { + "clinicalImpactClassification": { + "type": "object", + "description": "Clinical Impact classification of somatic variants", + "$ref": "#/definitions/baseClassificationType", + "required": ["clinicalImpactClassificationDescription"], + "properties": { + "clinicalImpactClassificationDescription": { + "type": "string", + "description": "The strength of clincal impact expressed in tiers.", + "enum": [ + "Tier I - Strong", + "Tier II - Potential", + "Tier III - Unknown", + "Tier IV - Benign/Likely benign" + ] + }, + "assertionTypeForClinicalImpact": { + "type": "string", + "description": "Required for variants with a 'Somatic classification of clinical impact' of Tier I or II. Optional for Tier III and IV.", + "enum": [ + "therapeutic: sensitivity/response", + "therapeutic: resistance", + "therapeutic: reduced sensitivity", + "diagnostic: supports diagnosis", + "diagnostic: excludes diagnosis", + "prognostic: better outcome", + "prognostic: poor outcome" + ] + }, + "drugForTherapeuticAssertion": { + "type": "string", + "description": "Required for variants with a 'Somatic classification of clinical impact' and therapeutic assertion type. Do not fill in this column for diagnostic or prognostic assertion types. May be the name of a specific drug, e.g. ruxolitinib, or a drug class, e.g. JAK inhibitors. Multiple terms are allowed only to represent combination therapies, e.g. cisplatin and vinorelbine for non-small cell lung cancer. Separate multiple terms with a semi-colon." + } + }, + "unevaluatedProperties": false + }, + "observedIn": { + "type": "array", + "minItems": 1, + "items": + { + "$ref": "#/definitions/baseObservationType", + "properties": { + "presenceOfSomaticVariantInNormalTissue": { + "type": "string", + "description": "Optional. Indicate whether the variant was present or absent in normal tissue, or that normal tissue was not tested.", + "enum": [ + "present", "absent", "not tested" + ] + }, + "somaticVariantAlleleFraction": { + "type": "number", + "description": "Optional. Indicate the variant allele fraction (or frequency) observed in this tumor, expressed as a float, e.g. 0.2." + } + }, + "unevaluatedProperties": false + }, + "errors": {"minItems": "Empty list of observedIn not allowed"} + }, + "conditionSet": { + "type": "object", + "description": "The condition for which the variant is classified. Detailed information about reporting condition is available at https://www.ncbi.nlm.nih.gov/clinvar/docs/faq_submitters/#pheno If multiple conditions are submitted for a variant, this indicates that the variant was interpreted for the combination of conditions in the same individual(s). i.e. this variant causes both condition A and condition B in the same individual. This scenario is most common for a new disease or syndrome that does not yet have a name and is described by several clinical features. If you want to indicate that the variant has been interpreted for more than one condition, please submit these as separate records. i.e. this variant causes condition A in some individuals and causes disease B in other individuals. Provide only one name or identifier for a condition; do not provide multiple names or identifiers for the same condition.", + "required": ["condition"], + "properties": { + "condition": { + "description": "The condition must be provided as either a database identifier or a name, but not both. A database identifier is preferred by ClinVar; a name should be provided only if there is no database identifier available.", + "$ref": "#/definitions/conditionType" + } + }, + "additionalProperties": false + } + }, + "unevaluatedProperties": false + }, + "errors": { + "minItems": "Empty list of clinicalImpactSubmission not allowed", + "maxItems": "no more than 10000 clinicalImpactSubmission allowed" + } + }, "submissionName": { "type": "string", "description": "Optional. The name for this submission. If not provided, it will be the submission id." diff --git a/clinvar_this/io/tsv.py b/clinvar_this/io/tsv.py index 892fd64..c796be1 100644 --- a/clinvar_this/io/tsv.py +++ b/clinvar_this/io/tsv.py @@ -31,9 +31,9 @@ SubmissionClinicalSignificance, SubmissionClinvarSubmission, SubmissionCondition, - SubmissionConditionSet, + SubmissionConditionSetGermline, SubmissionContainer, - SubmissionObservedIn, + SubmissionObservedInGermline, SubmissionVariant, SubmissionVariantSet, ) @@ -774,10 +774,10 @@ def record_condition_explanation( def record_condition_set( record: typing.Union[SeqVarTsvRecord, StrucVarTsvRecord] -) -> SubmissionConditionSet: +) -> SubmissionConditionSetGermline: conditions = record_conditions(record) multiple_condition_explanation = record_condition_explanation(record) - return SubmissionConditionSet( + return SubmissionConditionSetGermline( condition=conditions, multiple_condition_explanation=multiple_condition_explanation ) @@ -840,7 +840,7 @@ def record_clinical_features( local_key=record.local_key, condition_set=record_condition_set(record), observed_in=[ - SubmissionObservedIn( + SubmissionObservedInGermline( affected_status=AffectedStatus.YES, allele_origin=allele_origin, collection_method=collection_method, @@ -932,7 +932,7 @@ def record_clinical_features( local_key=record.local_key, condition_set=record_condition_set(record), observed_in=[ - SubmissionObservedIn( + SubmissionObservedInGermline( affected_status=AffectedStatus.YES, allele_origin=allele_origin, collection_method=collection_method, @@ -965,7 +965,7 @@ def record_clinical_features( ) -def format_conditions(condition_set: SubmissionConditionSet) -> typing.List[str]: +def format_conditions(condition_set: SubmissionConditionSetGermline) -> typing.List[str]: conditions = condition_set.condition fmt_conditions = [] if conditions: diff --git a/tests/clinvar_api/conftest.py b/tests/clinvar_api/conftest.py index 0a00eb1..9d0a109 100644 --- a/tests/clinvar_api/conftest.py +++ b/tests/clinvar_api/conftest.py @@ -564,3 +564,183 @@ def data_submission_snv(): } ], } + + +@pytest.fixture +def data_sample_api_submissions_sample_clinical_impact_hgvs_json(): + return { + "clinvarSubmissionReleaseStatus": "hold until published", + "assertionCriteria": {"db": "PubMed", "id": "25741868"}, + "clinvarSubmission": [ + { + "recordStatus": "novel", + "clinicalSignificance": { + "clinicalSignificanceDescription": "Pathogenic", + "dateLastEvaluated": "2018-04-28", + "comment": "This comment explains the rationale for classifying this PDE6B variant as pathogenic for Retinitis pigmentosa-40.", + "citation": [ + {"db": "PubMed", "id": "PMID:11295882"}, + {"db": "PubMed", "id": "PMID:1363786"}, + {"url": "https://yourdatabaselink.org"}, + ], + "modeOfInheritance": "Autosomal dominant inheritance", + }, + "observedIn": [ + { + "alleleOrigin": "germline", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 1, + } + ], + "variantSet": {"variant": [{"hgvs": "NM_000283.3:c.3645A>T", "gene": [{"id": 2}]}]}, + "conditionSet": {"condition": [{"db": "OMIM", "id": "613801"}]}, + } + ], + } + + +@pytest.fixture +def data_sample_api_submissions_sample_clinical_significance_hgvs_submission_json(): + return { + "clinvarSubmissionReleaseStatus": "hold until published", + "assertionCriteria": {"db": "PubMed", "id": "25741868"}, + "germlineSubmission": [ + { + "recordStatus": "novel", + "germlineClassification": { + "germlineClassificationDescription": "Pathogenic", + "dateLastEvaluated": "2018-04-28", + "comment": "This comment explains the rationale for classifying this PDE6B variant as pathogenic for Retinitis pigmentosa-40.", + "citation": [ + {"db": "PubMed", "id": "PMID:11295882"}, + {"db": "PubMed", "id": "PMID:1363786"}, + {"url": "https://yourdatabaselink.org"}, + ], + "modeOfInheritance": "Autosomal dominant inheritance", + }, + "observedIn": [ + { + "alleleOrigin": "germline", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 1, + } + ], + "variantSet": {"variant": [{"hgvs": "NM_000283.3:c.3645A>T", "gene": [{"id": 2}]}]}, + "conditionSet": {"condition": [{"db": "OMIM", "id": "613801"}]}, + } + ], + } + + +@pytest.fixture +def data_sample_api_submissions_sample_germline_hgvs_submission_json(): + return { + "submissionName": "my_oncogenicity_submission", + "assertionCriteria": {"db": "PubMed", "id": "36063163"}, + "behalfOrgID": 20000, + "oncogenicitySubmission": [ + { + "recordStatus": "novel", + "oncogenicityClassification": { + "oncogenicityClassificationDescription": "Benign", + "dateLastEvaluated": "2020-04-28", + "comment": "This comment explains the rationale for classifying this variant as Benign for breast cancer.", + "citation": [{"db": "PubMed", "id": "21084639"}], + }, + "observedIn": [ + { + "alleleOrigin": "somatic", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 24, + "presenceOfSomaticVariantInNormalTissue": "not tested", + } + ], + "variantSet": {"variant": [{"hgvs": "NM_000314.8:c.700C>T"}]}, + "conditionSet": {"condition": [{"db": "MedGen", "id": "C0007134"}]}, + }, + { + "recordStatus": "novel", + "oncogenicityClassification": { + "oncogenicityClassificationDescription": "Oncogenic", + "dateLastEvaluated": "2018-04-28", + "comment": "This comment explains the rationale for classifying this variant as oncogenic for breast cancer.", + }, + "observedIn": [ + { + "alleleOrigin": "somatic", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 1, + "presenceOfSomaticVariantInNormalTissue": "present", + "somaticVariantAlleleFraction": 20, + } + ], + "variantSet": {"variant": [{"hgvs": "NM_004333.6:c.1012A>G", "gene": [{"id": 2}]}]}, + "conditionSet": {"condition": [{"name": "breast cancer"}]}, + }, + ], + } + + +@pytest.fixture +def data_sample_api_submissions_sample_oncogenicity_hgvs_json(): + return { + "submissionName": "my_clinical_impact_submission", + "assertionCriteria": {"db": "PubMed", "id": "27993330"}, + "behalfOrgID": 20000, + "clinicalImpactSubmission": [ + { + "recordStatus": "novel", + "clinicalImpactClassification": { + "clinicalImpactClassificationDescription": "Tier I - Strong", + "assertionTypeForClinicalImpact": "therapeutic: sensitivity/response", + "drugForTherapeuticAssertion": "compound101", + "dateLastEvaluated": "2020-04-28", + "comment": "This comment explains the rationale for classifying this variant as Tier 1 - Strong for a therapeutic assertion that the variant confers sensitivity to compound 101 in renal cancer.", + "citation": [{"db": "PubMed", "id": "33767709"}], + }, + "observedIn": [ + { + "alleleOrigin": "somatic", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 24, + "clinicalFeatures": [ + { + "db": "HP", + "id": "HP:0009726", + "clinicalFeaturesAffectedStatus": "present", + } + ], + "clinicalFeaturesComment": "Renal tumors first observed in patients ranging in age from 45-68 years.", + "presenceOfSomaticVariantInNormalTissue": "not tested", + } + ], + "variantSet": {"variant": [{"hgvs": "NM_000314.8:c.700C>T"}]}, + "conditionSet": {"condition": [{"db": "MedGen", "id": "C0007134"}]}, + }, + { + "recordStatus": "novel", + "clinicalImpactClassification": { + "clinicalImpactClassificationDescription": "Tier III - Unknown", + "dateLastEvaluated": "2018-04-28", + "comment": "This comment explains the rationale for classifying this variant as Tier III - Unknown for breast cancer.", + }, + "observedIn": [ + { + "alleleOrigin": "somatic", + "affectedStatus": "yes", + "collectionMethod": "clinical testing", + "numberOfIndividuals": 1, + "presenceOfSomaticVariantInNormalTissue": "present", + "somaticVariantAlleleFraction": 43, + } + ], + "variantSet": {"variant": [{"hgvs": "NM_004333.6:c.1012A>G", "gene": [{"id": 2}]}]}, + "conditionSet": {"condition": [{"name": "breast cancer"}]}, + }, + ], + } diff --git a/tests/clinvar_api/test_models_unit.py b/tests/clinvar_api/test_models_unit.py index 85eb2db..af543e8 100644 --- a/tests/clinvar_api/test_models_unit.py +++ b/tests/clinvar_api/test_models_unit.py @@ -720,8 +720,8 @@ def test_submission_clinical_feature_to_msg(): ).to_msg() -def test_submission_observed_in_construction(): - models.SubmissionObservedIn( +def test_submission_observed_in_germline_construction(): + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -737,15 +737,32 @@ def test_submission_observed_in_construction(): number_of_individuals=1, struct_var_method_type=models.StructVarMethodType.SNP_ARRAY, ) - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, ) -def test_submission_observed_in_to_msg(): - models.SubmissionObservedIn( +def test_submission_observed_in_somatic_construction(): + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ) + + +def test_submission_observed_germline_in_to_msg(): + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -761,7 +778,24 @@ def test_submission_observed_in_to_msg(): number_of_individuals=1, struct_var_method_type=models.StructVarMethodType.SNP_ARRAY, ).to_msg() - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ).to_msg() + + +def test_submission_observed_in_somatic_to_msg(): + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ).to_msg() + models.SubmissionObservedInSomatic( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -975,28 +1009,52 @@ def test_submission_drug_response_to_msg(): ).to_msg() -def test_submission_condition_set_construction(): - models.SubmissionConditionSet( +def test_submission_condition_set_germline_construction(): + models.SubmissionConditionSetGermline( condition=[models.SubmissionCondition()], drug_response=[models.SubmissionDrugResponse()], ) - models.SubmissionConditionSet( + models.SubmissionConditionSetGermline( condition=None, drug_response=None, ) -def test_submission_condition_set_to_msg(): - models.SubmissionConditionSet( +def test_submission_condition_set_germline_to_msg(): + models.SubmissionConditionSetGermline( condition=[models.SubmissionCondition()], drug_response=[models.SubmissionDrugResponse()], ).to_msg() - models.SubmissionConditionSet( + models.SubmissionConditionSetGermline( condition=None, drug_response=None, ).to_msg() +def test_submission_condition_set_somatic_construction(): + models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=[models.SubmissionDrugResponse()], + multiple_condition_explanation=models.MultipleConditionExplanation.UNCERTAIN, + ) + models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ) + + +def test_submission_condition_set_somatic_to_msg(): + models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=[models.SubmissionDrugResponse()], + multiple_condition_explanation=models.MultipleConditionExplanation.UNCERTAIN, + ).to_msg() + models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ).to_msg() + + def test_submission_compound_heterozygote_set_variant_set_construction(): models.SubmissionCompoundHeterozygoteSetVariantSet( variant_set=models.SubmissionVariantSet(variant=[]), @@ -1084,9 +1142,9 @@ def test_submission_clinvar_submission_construction(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1134,9 +1192,9 @@ def test_submission_clinvar_submission_construction(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1151,9 +1209,9 @@ def test_submission_clinvar_submission_to_msg(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1201,9 +1259,235 @@ def test_submission_clinvar_submission_to_msg(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), + observed_in=[ + models.SubmissionObservedInGermline( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ) + ], + record_status=models.RecordStatus.NOVEL, + ).to_msg() + + +def test_somatic_clinical_impact_classification_construction(): + models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ) + + +def test_somatic_clinical_impact_classification_to_msg(): + models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ).to_msg() + + +def test_submission_clinical_impact_submission_construction(): + models.SubmissionClinicalImpactSubmission( + clinical_impact_classification=models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + + +def test_submission_clinical_impact_submission_to_msg(): + models.SubmissionClinicalImpactSubmission( + clinical_impact_classification=models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ).to_msg() + + +def test_somatic_oncogenicity_classification_construction(): + models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ) + + +def test_somatic_oncogenicity_classification_to_msg(): + models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ).to_msg() + + +def test_somatic_oncogenicity_submission_construction(): + models.SubmissionOncogenicitySubmission( + oncogenicity_classification=models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + + +def test_somatic_oncogenicity_submission_to_msg(): + models.SubmissionOncogenicitySubmission( + oncogenicity_classification=models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ).to_msg() + + +def test_germline_classification_construction(): + models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ) + + +def test_germline_classification_to_msg(): + models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ).to_msg() + + +def test_germline_submission_construction(): + models.SubmissionGermlineSubmission( + germline_classification=models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + condition_set=models.SubmissionConditionSetGermline(), + observed_in=[ + models.SubmissionObservedInGermline( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + + +def test_germline_submission_to_msg(): + models.SubmissionGermlineSubmission( + germline_classification=models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1236,9 +1520,9 @@ def test_submission_container_construction(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1250,6 +1534,116 @@ def test_submission_container_construction(): clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, submission_name="some-name", ) + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + clinical_impact_submission=[ + models.SubmissionClinicalImpactSubmission( + clinical_impact_classification=models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ) + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + oncogenicity_submission=[ + models.SubmissionOncogenicitySubmission( + oncogenicity_classification=models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ) + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + germline_submission=[ + models.SubmissionGermlineSubmission( + germline_classification=models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + condition_set=models.SubmissionConditionSetGermline(), + observed_in=[ + models.SubmissionObservedInGermline( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ) def test_submission_container_to_msg(): @@ -1275,9 +1669,9 @@ def test_submission_container_to_msg(): clinical_significance=models.SubmissionClinicalSignificance( clinical_significance_description=models.ClinicalSignificanceDescription.PATHOGENIC, ), - condition_set=models.SubmissionConditionSet(), + condition_set=models.SubmissionConditionSetGermline(), observed_in=[ - models.SubmissionObservedIn( + models.SubmissionObservedInGermline( affected_status=models.AffectedStatus.YES, allele_origin=models.AlleleOrigin.GERMLINE, collection_method=models.CollectionMethod.CLINICAL_TESTING, @@ -1289,3 +1683,113 @@ def test_submission_container_to_msg(): clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, submission_name="some-name", ).to_msg() + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + clinical_impact_submission=[ + models.SubmissionClinicalImpactSubmission( + clinical_impact_classification=models.SomaticClinicalImpactClassification( + clinical_impact_classification_description=models.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertion_type_for_clinical_impact=models.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drug_for_therapeutic_assertion=None, + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ).to_msg() + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + oncogenicity_submission=[ + models.SubmissionOncogenicitySubmission( + oncogenicity_classification=models.SomaticOncogenicityClassification( + oncogenicity_classification_description=models.OncogenicityClassificationDescription.BENIGN + ), + condition_set=models.SubmissionConditionSetSomatic( + condition=[models.SubmissionCondition()], + drug_response=None, + ), + observed_in=[ + models.SubmissionObservedInSomatic( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.SOMATIC, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + number_of_individuals=1, + struct_var_method_type=models.StructVarMethodType.PAIRED_END_MAPPING, + presence_of_somatic_variant_in_normal_tissue=models.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somatic_variant_allele_fraction=0.5, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ).to_msg() + models.SubmissionContainer( + assertion_criteria=models.SubmissionAssertionCriteria( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalf_org_id=123, + clinvar_deletion=None, + clinvar_submission_release_status=models.ReleaseStatus.PUBLIC, + submission_name="some-name", + germline_submission=[ + models.SubmissionGermlineSubmission( + germline_classification=models.GermlineClassification( + germline_classification_description=models.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + models.SubmissionCitation( + db=models.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + custom_classification_score=42.0, + date_last_evaluated="2022-01-01", + explanation_of_drug_response="some explanation", + explanation_of_other_classification="some explanation", + mode_of_inheritance=models.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + condition_set=models.SubmissionConditionSetGermline(), + observed_in=[ + models.SubmissionObservedInGermline( + affected_status=models.AffectedStatus.YES, + allele_origin=models.AlleleOrigin.GERMLINE, + collection_method=models.CollectionMethod.CLINICAL_TESTING, + ) + ], + record_status=models.RecordStatus.NOVEL, + ) + ], + ).to_msg() diff --git a/tests/clinvar_api/test_msg_real_world.py b/tests/clinvar_api/test_msg_real_world.py index d832649..dbfa4e1 100644 --- a/tests/clinvar_api/test_msg_real_world.py +++ b/tests/clinvar_api/test_msg_real_world.py @@ -41,3 +41,35 @@ def test_data_summary_response_error_all(data_summary_response_error_all): def test_data_submission_snv(data_submission_snv): assert msg.SubmissionContainer.model_validate(data_submission_snv) + + +def test_data_sample_api_submissions_sample_clinical_impact_hgvs_json( + data_sample_api_submissions_sample_clinical_impact_hgvs_json, +): + assert msg.SubmissionContainer.model_validate( + data_sample_api_submissions_sample_clinical_impact_hgvs_json + ) + + +def test_data_sample_api_submissions_sample_clinical_significance_hgvs_submission_json( + data_sample_api_submissions_sample_clinical_significance_hgvs_submission_json, +): + assert msg.SubmissionContainer.model_validate( + data_sample_api_submissions_sample_clinical_significance_hgvs_submission_json + ) + + +def test_data_sample_api_submissions_sample_germline_hgvs_submission_json( + data_sample_api_submissions_sample_germline_hgvs_submission_json, +): + assert msg.SubmissionContainer.model_validate( + data_sample_api_submissions_sample_germline_hgvs_submission_json + ) + + +def test_data_sample_api_submissions_sample_oncogenicity_hgvs_json( + data_sample_api_submissions_sample_oncogenicity_hgvs_json, +): + assert msg.SubmissionContainer.model_validate( + data_sample_api_submissions_sample_oncogenicity_hgvs_json + ) diff --git a/tests/clinvar_api/test_msg_unit.py b/tests/clinvar_api/test_msg_unit.py index 9188201..03df133 100644 --- a/tests/clinvar_api/test_msg_unit.py +++ b/tests/clinvar_api/test_msg_unit.py @@ -380,8 +380,8 @@ def test_submission_clinical_feature_construction(): ) -def test_submission_observed_in_construction(): - msg.SubmissionObservedIn( +def test_submission_observed_in_germline_construction(): + msg.SubmissionObservedInGermline( affectedStatus=msg.AffectedStatus.YES, alleleOrigin=msg.AlleleOrigin.GERMLINE, collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, @@ -397,7 +397,24 @@ def test_submission_observed_in_construction(): numberOfIndividuals=1, structVarMethodType=msg.StructVarMethodType.SNP_ARRAY, ) - msg.SubmissionObservedIn( + msg.SubmissionObservedInGermline( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.GERMLINE, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + ) + + +def test_submission_observed_in_somatic_construction(): + msg.SubmissionObservedInSomatic( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.SOMATIC, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + numberOfIndividuals=1, + structVarMethodType=msg.StructVarMethodType.PAIRED_END_MAPPING, + presenceOfSomaticVariantInNormalTissue=msg.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somaticVariantAlleleFraction=0.5, + ) + msg.SubmissionObservedInSomatic( affectedStatus=msg.AffectedStatus.YES, alleleOrigin=msg.AlleleOrigin.GERMLINE, collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, @@ -505,17 +522,30 @@ def test_submission_drug_response_construction(): ) -def test_submission_condition_set_construction(): - msg.SubmissionConditionSet( +def test_submission_condition_set_germline_construction(): + msg.SubmissionConditionSetGermline( condition=[msg.SubmissionCondition()], drugResponse=[msg.SubmissionDrugResponse()], + multipleConditionExplanation=msg.MultipleConditionExplanation.UNCERTAIN, ) - msg.SubmissionConditionSet( + msg.SubmissionConditionSetGermline( condition=None, drugResponse=None, ) +def test_submission_condition_set_somatic_construction(): + msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=[msg.SubmissionDrugResponse()], + multipleConditionExplanation=msg.MultipleConditionExplanation.UNCERTAIN, + ) + msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=None, + ) + + def test_submission_compound_heterozygote_set_variant_set_construction(): msg.SubmissionCompoundHeterozygoteSetVariantSet( variantSet=msg.SubmissionVariantSet(variant=[]), @@ -562,9 +592,9 @@ def test_submission_clinvar_submission_construction(): clinicalSignificance=msg.SubmissionClinicalSignificance( clinicalSignificanceDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, ), - conditionSet=msg.SubmissionConditionSet(), + conditionSet=msg.SubmissionConditionSetGermline(), observedIn=[ - msg.SubmissionObservedIn( + msg.SubmissionObservedInGermline( affectedStatus=msg.AffectedStatus.YES, alleleOrigin=msg.AlleleOrigin.GERMLINE, collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, @@ -612,9 +642,122 @@ def test_submission_clinvar_submission_construction(): clinicalSignificance=msg.SubmissionClinicalSignificance( clinicalSignificanceDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, ), - conditionSet=msg.SubmissionConditionSet(), + conditionSet=msg.SubmissionConditionSetGermline(), + observedIn=[ + msg.SubmissionObservedInGermline( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.GERMLINE, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + + +def test_somatic_clinical_impact_classification_construction(): + msg.SomaticClinicalImpactClassification( + clinicalImpactClassificationDescription=msg.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertionTypeForClinicalImpact=msg.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drugForTherapeuticAssertion=None, + ) + + +def test_submission_clinical_impact_submission_construction(): + msg.SubmissionClinicalImpactSubmission( + clinicalImpactClassification=msg.SomaticClinicalImpactClassification( + clinicalImpactClassificationDescription=msg.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertionTypeForClinicalImpact=msg.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drugForTherapeuticAssertion=None, + ), + conditionSet=msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=None, + ), + observedIn=[ + msg.SubmissionObservedInSomatic( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.SOMATIC, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + numberOfIndividuals=1, + structVarMethodType=msg.StructVarMethodType.PAIRED_END_MAPPING, + presenceOfSomaticVariantInNormalTissue=msg.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somaticVariantAlleleFraction=0.5, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + + +def test_somatic_oncogenicity_classification_construction(): + msg.SomaticOncogenicityClassification( + oncogenicityClassificationDescription=msg.OncogenicityClassificationDescription.BENIGN + ) + + +def test_somatic_oncogenicity_submission_construction(): + msg.SubmissionOncogenicitySubmission( + oncogenicityClassification=msg.SomaticOncogenicityClassification( + oncogenicityClassificationDescription=msg.OncogenicityClassificationDescription.BENIGN + ), + conditionSet=msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=None, + ), + observedIn=[ + msg.SubmissionObservedInSomatic( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.SOMATIC, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + numberOfIndividuals=1, + structVarMethodType=msg.StructVarMethodType.PAIRED_END_MAPPING, + presenceOfSomaticVariantInNormalTissue=msg.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somaticVariantAlleleFraction=0.5, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + + +def test_germline_classification_construction(): + msg.GermlineClassification( + germlineClassificationDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + msg.SubmissionCitation( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + customClassificationScore=42.0, + dateLastEvaluated="2022-01-01", + explanationOfDrugResponse="some explanation", + explanationOfOtherClassification="some explanation", + modeOfInheritance=msg.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ) + + +def test_germline_submission_construction(): + msg.SubmissionGermlineSubmission( + germlineClassification=msg.GermlineClassification( + germlineClassificationDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + msg.SubmissionCitation( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + customClassificationScore=42.0, + dateLastEvaluated="2022-01-01", + explanationOfDrugResponse="some explanation", + explanationOfOtherClassification="some explanation", + modeOfInheritance=msg.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + conditionSet=msg.SubmissionConditionSetGermline(), observedIn=[ - msg.SubmissionObservedIn( + msg.SubmissionObservedInGermline( affectedStatus=msg.AffectedStatus.YES, alleleOrigin=msg.AlleleOrigin.GERMLINE, collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, @@ -652,9 +795,9 @@ def test_submission_container_construction(): clinicalSignificance=msg.SubmissionClinicalSignificance( clinicalSignificanceDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, ), - conditionSet=msg.SubmissionConditionSet(), + conditionSet=msg.SubmissionConditionSetGermline(), observedIn=[ - msg.SubmissionObservedIn( + msg.SubmissionObservedInGermline( affectedStatus=msg.AffectedStatus.YES, alleleOrigin=msg.AlleleOrigin.GERMLINE, collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, @@ -665,3 +808,113 @@ def test_submission_container_construction(): ], submissionName="some-name", ) + msg.SubmissionContainer( + assertionCriteria=msg.SubmissionAssertionCriteria( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalfOrgID=123, + clinvarDeletion=None, + clinvarSubmissionReleaseStatus=msg.ReleaseStatus.PUBLIC, + submissionName="some-name", + clinicalImpactSubmission=[ + msg.SubmissionClinicalImpactSubmission( + clinicalImpactClassification=msg.SomaticClinicalImpactClassification( + clinicalImpactClassificationDescription=msg.SomaticClinicalImpactClassificationDescription.BENIGN_LIKELY_BENIGN, + assertionTypeForClinicalImpact=msg.SomaticClinicalImpactAssertionType.PROGNOSTIC_BETTER_OUTCOME, + drugForTherapeuticAssertion=None, + ), + conditionSet=msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=None, + ), + observedIn=[ + msg.SubmissionObservedInSomatic( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.SOMATIC, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + numberOfIndividuals=1, + structVarMethodType=msg.StructVarMethodType.PAIRED_END_MAPPING, + presenceOfSomaticVariantInNormalTissue=msg.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somaticVariantAlleleFraction=0.5, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + ], + ) + msg.SubmissionContainer( + assertionCriteria=msg.SubmissionAssertionCriteria( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalfOrgID=123, + clinvarDeletion=None, + clinvarSubmissionReleaseStatus=msg.ReleaseStatus.PUBLIC, + submissionName="some-name", + oncogenicitySubmission=[ + msg.SubmissionOncogenicitySubmission( + oncogenicityClassification=msg.SomaticOncogenicityClassification( + oncogenicityClassificationDescription=msg.OncogenicityClassificationDescription.BENIGN + ), + conditionSet=msg.SubmissionConditionSetSomatic( + condition=[msg.SubmissionCondition()], + drugResponse=None, + ), + observedIn=[ + msg.SubmissionObservedInSomatic( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.SOMATIC, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + numberOfIndividuals=1, + structVarMethodType=msg.StructVarMethodType.PAIRED_END_MAPPING, + presenceOfSomaticVariantInNormalTissue=msg.PresenceOfSomaticVariantInNormalTissue.ABSENT, + somaticVariantAlleleFraction=0.5, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + ], + ) + msg.SubmissionContainer( + assertionCriteria=msg.SubmissionAssertionCriteria( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ), + behalfOrgID=123, + clinvarDeletion=None, + clinvarSubmissionReleaseStatus=msg.ReleaseStatus.PUBLIC, + submissionName="some-name", + germlineSubmission=[ + msg.SubmissionGermlineSubmission( + germlineClassification=msg.GermlineClassification( + germlineClassificationDescription=msg.ClinicalSignificanceDescription.PATHOGENIC, + citation=[ + msg.SubmissionCitation( + db=msg.CitationDb.PMC, + id="PMC123", + url="https://example.com", + ) + ], + comment="some comment", + customClassificationScore=42.0, + dateLastEvaluated="2022-01-01", + explanationOfDrugResponse="some explanation", + explanationOfOtherClassification="some explanation", + modeOfInheritance=msg.ModeOfInheritance.AUTOSOMAL_DOMINANT_INHERITANCE, + ), + conditionSet=msg.SubmissionConditionSetGermline(), + observedIn=[ + msg.SubmissionObservedInGermline( + affectedStatus=msg.AffectedStatus.YES, + alleleOrigin=msg.AlleleOrigin.GERMLINE, + collectionMethod=msg.CollectionMethod.CLINICAL_TESTING, + ) + ], + recordStatus=msg.RecordStatus.NOVEL, + ) + ], + ) diff --git a/tests/clinvar_this/data/batches/seq_variant-update.payload.json b/tests/clinvar_this/data/batches/seq_variant-update.payload.json index 29a72a5..7e77ac2 100644 --- a/tests/clinvar_this/data/batches/seq_variant-update.payload.json +++ b/tests/clinvar_this/data/batches/seq_variant-update.payload.json @@ -91,6 +91,9 @@ "extra_data": null } ], + "clinical_impact_submission": null, + "germline_submission": null, + "oncogenicity_submission": null, "clinvar_submission_release_status": "public", "submission_name": null } diff --git a/tests/clinvar_this/data/batches/seq_variant.payload.json b/tests/clinvar_this/data/batches/seq_variant.payload.json index 07858d4..53c930e 100644 --- a/tests/clinvar_this/data/batches/seq_variant.payload.json +++ b/tests/clinvar_this/data/batches/seq_variant.payload.json @@ -91,6 +91,9 @@ "extra_data": null } ], + "clinical_impact_submission": null, + "germline_submission": null, + "oncogenicity_submission": null, "clinvar_submission_release_status": "public", "submission_name": null } diff --git a/tests/clinvar_this/data/batches/struc_variant-update.payload.json b/tests/clinvar_this/data/batches/struc_variant-update.payload.json index 58e14e2..53ff000 100644 --- a/tests/clinvar_this/data/batches/struc_variant-update.payload.json +++ b/tests/clinvar_this/data/batches/struc_variant-update.payload.json @@ -85,6 +85,9 @@ "extra_data": null } ], + "clinical_impact_submission": null, + "germline_submission": null, + "oncogenicity_submission": null, "clinvar_submission_release_status": "public", "submission_name": null } diff --git a/tests/clinvar_this/data/batches/struc_variant.payload.json b/tests/clinvar_this/data/batches/struc_variant.payload.json index 842687d..684eee8 100644 --- a/tests/clinvar_this/data/batches/struc_variant.payload.json +++ b/tests/clinvar_this/data/batches/struc_variant.payload.json @@ -85,6 +85,9 @@ "extra_data": null } ], + "clinical_impact_submission": null, + "germline_submission": null, + "oncogenicity_submission": null, "clinvar_submission_release_status": "public", "submission_name": null } diff --git a/tests/clinvar_this/test_io_tsv.py b/tests/clinvar_this/test_io_tsv.py index 6ce406b..3ac14c5 100644 --- a/tests/clinvar_this/test_io_tsv.py +++ b/tests/clinvar_this/test_io_tsv.py @@ -3,7 +3,7 @@ import pytest -from clinvar_api.models import SubmissionCondition, SubmissionConditionSet +from clinvar_api.models import SubmissionCondition, SubmissionConditionSetGermline from clinvar_api.msg import ( Assembly, Chromosome, @@ -170,14 +170,14 @@ class TestConditionDefinition: { "raw": "OMIM:123", "expected": ["OMIM:123"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[SubmissionCondition(db=ConditionDb.OMIM, id="123")] ), }, { "raw": "MONDO:123;OMIM:123", "expected": ["MONDO:123", "OMIM:123"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.MONDO, id="MONDO:123"), SubmissionCondition(db=ConditionDb.OMIM, id="123"), @@ -187,7 +187,7 @@ class TestConditionDefinition: { "raw": "MONDO:123 ;OMIM:123", "expected": ["MONDO:123", "OMIM:123"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.MONDO, id="MONDO:123"), SubmissionCondition(db=ConditionDb.OMIM, id="123"), @@ -197,7 +197,7 @@ class TestConditionDefinition: { "raw": "MONDO:123;OMIM:123;ORPHA:123", "expected": ["MONDO:123", "OMIM:123", "ORPHA:123"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.MONDO, id="MONDO:123"), SubmissionCondition(db=ConditionDb.OMIM, id="123"), @@ -208,7 +208,7 @@ class TestConditionDefinition: { "raw": "MONDO:123;OMIM:123;ORPHA:123;Uncertain", "expected": ["MONDO:123", "OMIM:123", "ORPHA:123", "Uncertain"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.MONDO, id="MONDO:123"), SubmissionCondition(db=ConditionDb.OMIM, id="123"), @@ -220,7 +220,7 @@ class TestConditionDefinition: { "raw": "MONDO:123;OMIM:123;ORPHA:123;Co-occurring", "expected": ["MONDO:123", "OMIM:123", "ORPHA:123", "Co-occurring"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.MONDO, id="MONDO:123"), SubmissionCondition(db=ConditionDb.OMIM, id="123"), @@ -232,7 +232,7 @@ class TestConditionDefinition: { "raw": "HP:123;HP:124;HP:125;Novel disease", "expected": ["HP:123", "HP:124", "HP:125", "Novel disease"], - "parsed": SubmissionConditionSet( + "parsed": SubmissionConditionSetGermline( condition=[ SubmissionCondition(db=ConditionDb.HP, id="HP:123"), SubmissionCondition(db=ConditionDb.HP, id="HP:124"),