From c150b5e87d7124538ba0ae8b7419725ce20e9b66 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Tue, 20 Sep 2022 10:57:33 +0200 Subject: [PATCH] Fixing ClinVar submission XML generation (#677) Closes: #677 Related-Issue: #677 Projected-Results-Impact: none --- HISTORY.rst | 2 ++ clinvar_export/clinvar_xml.py | 3 ++- clinvar_export/views_ajax.py | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d5d1021e5..0d817d305 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ End-User Summary **This will require an import of the updated Clinvar ``20210728c`` data (#296).** - Warning in the case of truncated displayed results (#641). - Improving Clinvar record aggregation (#640). +- Fixing ClinVar submission XML generation (#677). Full Change List ================ @@ -28,6 +29,7 @@ Full Change List **This will require an import of the updated Clinvar ``20210728c`` data (#296).** - Improving Clinvar record aggregation (#640). - Fixing Docker builds (#660). +- Fixing ClinVar submission XML generation (#677). ----------------- v1.2.2 (anthenea) diff --git a/clinvar_export/clinvar_xml.py b/clinvar_export/clinvar_xml.py index 7fd07ec9d..183356095 100644 --- a/clinvar_export/clinvar_xml.py +++ b/clinvar_export/clinvar_xml.py @@ -223,7 +223,8 @@ def build_xref(term_id): self.em("ElementValueType", "Preferred", **{"val_type": "name"}), self.em("ElementValue", phenotype["term_name"]), ), - self.em("XRef", **{"db": "HP", "id": phenotype["term_id"],}), + self.em("XRef", **{"db": "HP", "id": phenotype["term_id"],},), + **{"ClinicalFeaturesAffectedStatus": "present",}, ) for phenotype in submission_individual.phenotypes ], diff --git a/clinvar_export/views_ajax.py b/clinvar_export/views_ajax.py index 210291b7a..e11a5e601 100644 --- a/clinvar_export/views_ajax.py +++ b/clinvar_export/views_ajax.py @@ -258,10 +258,20 @@ def get(self, request, *args, **kwargs): "valid": True, } else: - result = { - "valid": False, - "details": "\n".join(e.message for e in schema.error_log), - } + ignored_message = ( + "Element 'Trait', attribute 'ClinicalFeaturesAffectedStatus': The attribute " + "'ClinicalFeaturesAffectedStatus' is not allowed." + ) + filtered_es = [e for e in schema.error_log if e.message != ignored_message] + if filtered_es: + result = { + "valid": False, + "details": "\n".join(e.message for e in filtered_es), + } + else: + result = { + "valid": True, + } return JsonResponse(result) def _get_schema(self, root):