From dc5003ed9520d8baa8fcc524b62aea9adeb90cf5 Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Thu, 13 Aug 2026 10:25:54 -0400 Subject: [PATCH 1/3] fix: oncogenicity evidence lines should accept null evidence outcomes close #70 --- src/ga4gh/va_spec/ccv_2022/models.py | 11 +++++++---- tests/validation/test_va_spec_models.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/ga4gh/va_spec/ccv_2022/models.py b/src/ga4gh/va_spec/ccv_2022/models.py index 40bb4df..aff91a6 100644 --- a/src/ga4gh/va_spec/ccv_2022/models.py +++ b/src/ga4gh/va_spec/ccv_2022/models.py @@ -234,11 +234,14 @@ def validate_model(self) -> Self: ``directionOfEvidenceProvided`` is neutral """ self._validate_direction_of_evidence_provided() - self._validate_evidence_outcome(SYSTEM, CCV_CODE_PATTERN, is_required=True) + self._validate_evidence_outcome(SYSTEM, CCV_CODE_PATTERN, is_required=False) self._validate_criterion_specified_by() - self._validate_method_type_evidence_outcome( - self.specifiedBy.methodType, self.evidenceOutcome.primaryCoding.code.root - ) + + if self.evidenceOutcome: + self._validate_method_type_evidence_outcome( + self.specifiedBy.methodType, + self.evidenceOutcome.primaryCoding.code.root, + ) return self diff --git a/tests/validation/test_va_spec_models.py b/tests/validation/test_va_spec_models.py index 221cfe9..7856360 100644 --- a/tests/validation/test_va_spec_models.py +++ b/tests/validation/test_va_spec_models.py @@ -21,6 +21,7 @@ ExperimentalVariantFunctionalImpactStudyResult, ) from ga4gh.va_spec.base.core import ( + Direction, EvidenceLine, Method, Statement, @@ -611,6 +612,27 @@ def test_variant_onco_el(): VariantOncogenicityEvidenceLine(**invalid_params) +def test_variant_onco_el_no_evidence_outcome(): + """Test that VariantOncogenicityEvidenceLine validates without evidence + outcome + """ + assert VariantOncogenicityEvidenceLine( + type="EvidenceLine", + specifiedBy={ + "type": "Method", + "reportedIn": { + "type": "Document", + "pmid": "35101336", + "name": "ClinGen/CGC/VICC Guidelines for Oncogenicity, 2022", + }, + "methodType": "functional_assay", + }, + directionOfEvidenceProvided=Direction.NEUTRAL, + scoreOfEvidenceProvided=0, + evidenceOutcome=None, + ) + + def test_aac_statement(): """Test that AMP/ASCO/CAP statement model validators work correctly""" prop = { From a2d473a52300cacf7d536827d97070f8eb83a862 Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Thu, 13 Aug 2026 10:51:59 -0400 Subject: [PATCH 2/3] handle invalid method type if no evidence outcome --- src/ga4gh/va_spec/base/validators.py | 6 ++++-- src/ga4gh/va_spec/ccv_2022/models.py | 13 ++++++++----- tests/validation/test_va_spec_models.py | 13 ++++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/ga4gh/va_spec/base/validators.py b/src/ga4gh/va_spec/base/validators.py index 53a31d9..beda255 100644 --- a/src/ga4gh/va_spec/base/validators.py +++ b/src/ga4gh/va_spec/base/validators.py @@ -114,7 +114,7 @@ def _get_base_criterion_from_code(cls, evidence_outcome_code: str) -> CriterionT def _validate_method_type_evidence_outcome( cls, method_type: str, - evidence_outcome_code: str, + evidence_outcome_code: str | None, ) -> None: """Validate that ``evidenceOutcome`` is compatible with a method type. @@ -122,11 +122,13 @@ def _validate_method_type_evidence_outcome( :param evidence_outcome_code: Evidence outcome to validate. :raises ValueError: If the evidence outcome criterion is invalid or is not valid for the specified method type. - :return: None. """ parsed_method_type = cls.MethodType(method_type) allowed_criteria = cls.ALLOWED_CRITERIA_BY_METHOD_TYPE[parsed_method_type] + if not evidence_outcome_code: + return + criterion = cls._get_base_criterion_from_code(evidence_outcome_code) if criterion not in allowed_criteria: diff --git a/src/ga4gh/va_spec/ccv_2022/models.py b/src/ga4gh/va_spec/ccv_2022/models.py index aff91a6..039917b 100644 --- a/src/ga4gh/va_spec/ccv_2022/models.py +++ b/src/ga4gh/va_spec/ccv_2022/models.py @@ -237,11 +237,14 @@ def validate_model(self) -> Self: self._validate_evidence_outcome(SYSTEM, CCV_CODE_PATTERN, is_required=False) self._validate_criterion_specified_by() - if self.evidenceOutcome: - self._validate_method_type_evidence_outcome( - self.specifiedBy.methodType, - self.evidenceOutcome.primaryCoding.code.root, - ) + evidence_outcome = ( + self.evidenceOutcome.primaryCoding.code.root + if self.evidenceOutcome + else None + ) + self._validate_method_type_evidence_outcome( + self.specifiedBy.methodType, evidence_outcome + ) return self diff --git a/tests/validation/test_va_spec_models.py b/tests/validation/test_va_spec_models.py index 7856360..aca24af 100644 --- a/tests/validation/test_va_spec_models.py +++ b/tests/validation/test_va_spec_models.py @@ -616,7 +616,7 @@ def test_variant_onco_el_no_evidence_outcome(): """Test that VariantOncogenicityEvidenceLine validates without evidence outcome """ - assert VariantOncogenicityEvidenceLine( + valid = VariantOncogenicityEvidenceLine( type="EvidenceLine", specifiedBy={ "type": "Method", @@ -632,6 +632,17 @@ def test_variant_onco_el_no_evidence_outcome(): evidenceOutcome=None, ) + assert valid + + invalid = valid.model_dump() + invalid["specifiedBy"]["methodType"] = "dummy" + + with pytest.raises( + ValueError, + match="'dummy' is not a valid VariantOncogenicityEvidenceLine.MethodType", + ): + VariantOncogenicityEvidenceLine.model_validate(invalid) + def test_aac_statement(): """Test that AMP/ASCO/CAP statement model validators work correctly""" From b4f9fa930013ef704cfb7112256e68e293d8515e Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Thu, 13 Aug 2026 10:54:03 -0400 Subject: [PATCH 3/3] update docs --- src/ga4gh/va_spec/base/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ga4gh/va_spec/base/validators.py b/src/ga4gh/va_spec/base/validators.py index beda255..080af60 100644 --- a/src/ga4gh/va_spec/base/validators.py +++ b/src/ga4gh/va_spec/base/validators.py @@ -121,7 +121,7 @@ def _validate_method_type_evidence_outcome( :param method_type: Method type value from ``specifiedBy.methodType``. :param evidence_outcome_code: Evidence outcome to validate. :raises ValueError: If the evidence outcome criterion is invalid or is - not valid for the specified method type. + not valid for the specified method type, or if method type is invalid """ parsed_method_type = cls.MethodType(method_type) allowed_criteria = cls.ALLOWED_CRITERIA_BY_METHOD_TYPE[parsed_method_type]