From 3c3ae71752d61930909a520f03d9c7bd93883c93 Mon Sep 17 00:00:00 2001 From: Jakub Dylag <jjd1c23@soton.ac.uk> Date: Fri, 28 Mar 2025 15:11:11 +0000 Subject: [PATCH] Allow multiple files per concept set - validation passed --- acmc/phen.py | 67 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/acmc/phen.py b/acmc/phen.py index ff2edc2..4893144 100644 --- a/acmc/phen.py +++ b/acmc/phen.py @@ -514,46 +514,47 @@ def validate(phen_dir: str): # create a list of all the concept set names defined in the concept set configuration concept_set_names = [] for item in phenotype["concept_sets"]: - # if item["name"] in concept_set_names: - # validation_errors.append( - # f"Duplicate concept set defined in concept sets {item['name'] }" - # ) - # else: - concept_set_names.append(item["name"]) - - # check codes definition - for item in phenotype["concept_sets"]: - # check concepte code file exists - concept_code_file_path = concepts_path / item["file"]["path"] - if not concept_code_file_path.exists(): - validation_errors.append( - f"Coding file {str(concept_code_file_path.resolve())} does not exist" - ) - - # check concepte code file is not empty - if concept_code_file_path.stat().st_size == 0: + if item["name"] in concept_set_names: validation_errors.append( - f"Coding file {str(concept_code_file_path.resolve())} is an empty file" + f"Duplicate concept set defined in concept sets {item['name'] }" ) + else: + concept_set_names.append(item["name"]) - # check code file type is supported - if concept_code_file_path.suffix not in CODE_FILE_TYPES: - raise ValueError( - f"Unsupported filetype {concept_code_file_path.suffix}, only support csv, xlsx, xls code file types" - ) + # check codes definition + for files in phenotype["concept_sets"]: + for item in files["files"]: + # check concepte code file exists + concept_code_file_path = concepts_path / item["path"] + if not concept_code_file_path.exists(): + validation_errors.append( + f"Coding file {str(concept_code_file_path.resolve())} does not exist" + ) - # check columns specified are a supported medical coding type - for column in item["file"]["columns"]: - if column not in code_types: + # check concepte code file is not empty + if concept_code_file_path.stat().st_size == 0: validation_errors.append( - f"Column type {column} for file {concept_code_file_path} is not supported" + f"Coding file {str(concept_code_file_path.resolve())} is an empty file" ) - # check the actions are supported - if "actions" in item["file"]: - for action in item["file"]["actions"]: - if action not in COL_ACTIONS: - validation_errors.append(f"Action {action} is not supported") + # check code file type is supported + if concept_code_file_path.suffix not in CODE_FILE_TYPES: + raise ValueError( + f"Unsupported filetype {concept_code_file_path.suffix}, only support csv, xlsx, xls code file types" + ) + + # check columns specified are a supported medical coding type + for column in item["columns"]: + if column not in code_types: + validation_errors.append( + f"Column type {column} for file {concept_code_file_path} is not supported" + ) + + # check the actions are supported + if "actions" in item: + for action in item["actions"]: + if action not in COL_ACTIONS: + validation_errors.append(f"Action {action} is not supported") if len(validation_errors) > 0: _logger.error(validation_errors) -- GitLab