From 3b7281fa2008ce85c9a4a164dab19ca19edd0c8a Mon Sep 17 00:00:00 2001 From: Jakub Dylag <jjd1c23@soton.ac.uk> Date: Fri, 7 Feb 2025 00:56:34 +0000 Subject: [PATCH] Run scripts from command line --- medcoder/main.py | 9 ++++++--- medcoder/parse.py | 16 ++++++++-------- medcoder/trud_api.py | 12 ++++++------ pyproject.toml | 7 ++++++- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/medcoder/main.py b/medcoder/main.py index ab32f81..f1868c2 100644 --- a/medcoder/main.py +++ b/medcoder/main.py @@ -291,8 +291,7 @@ def run_all(mapping_file, target_code_type, error_df = error_df.sort_values(by=["SOURCE", "VOCABULARY", "CONCEPT"]) error_df.to_csv(log_errors_path, index=False) - -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser(description="Script preprocess code lists and to map to given concept/phenotype", formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -332,4 +331,8 @@ if __name__ == '__main__': if not config["error_log"] == None: params["log_errors_path"] = config["error_log"] - run_all(**params) \ No newline at end of file + run_all(**params) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/medcoder/parse.py b/medcoder/parse.py index a509369..8a567cf 100644 --- a/medcoder/parse.py +++ b/medcoder/parse.py @@ -197,15 +197,15 @@ class Icd10_code(Proto_code): file_path=self.file_path, cause="QA In Database"), ) -# ( -# "ICD10 Regex", -# lambda codes : codes.str.match("[a-zA-Z][0-9][0-9]\.?[a-zA-Z0-9]*$"), #Alpha, Num, Num , Dot?, 4xAlphNum* -# lambda codes : log_invalid_code(codes, -# codes.str.match("[a-zA-Z][0-9][0-9]\.?[a-zA-Z0-9]*$"), #Log non-matching rows -# code_type="icd10_code", -# file_path=self.file_path), + # ( + # "ICD10 Regex", + # lambda codes : codes.str.match("[a-zA-Z][0-9][0-9]\.?[a-zA-Z0-9]*$"), #Alpha, Num, Num , Dot?, 4xAlphNum* + # lambda codes : log_invalid_code(codes, + # codes.str.match("[a-zA-Z][0-9][0-9]\.?[a-zA-Z0-9]*$"), #Log non-matching rows + # code_type="icd10_code", + # file_path=self.file_path), -# ) + # ) ] def trim_icd10(codes): diff --git a/medcoder/trud_api.py b/medcoder/trud_api.py index a7eade3..e4e5488 100644 --- a/medcoder/trud_api.py +++ b/medcoder/trud_api.py @@ -206,12 +206,12 @@ def main(): formatter_class=argparse.ArgumentDefaultsHelpFormatter ) parser.add_argument("--key", type=str, help="TRUD API Key") -# parser.add_argument("item_ids", nargs="+", help="Item IDs to download releases for.") -# parser.add_argument("-l", "--latest", action="store_true", help="Download only the latest release") -# parser.add_argument("-c", "--checksum", action="store_true", help="Also download the checksum file") -# parser.add_argument("-s", "--signature", action="store_true", help="Also download the signature file") -# parser.add_argument("-p", "--public_key", action="store_true", help="Also download the public key file") - + # parser.add_argument("item_ids", nargs="+", help="Item IDs to download releases for.") + # parser.add_argument("-l", "--latest", action="store_true", help="Download only the latest release") + # parser.add_argument("-c", "--checksum", action="store_true", help="Also download the checksum file") + # parser.add_argument("-s", "--signature", action="store_true", help="Also download the signature file") + # parser.add_argument("-p", "--public_key", action="store_true", help="Also download the public key file") + args = parser.parse_args() items_latest = True diff --git a/pyproject.toml b/pyproject.toml index 060d7aa..40bff1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,4 +12,9 @@ license = { file = "LICENSE" } dependencies = [ "pandas", "numpy" -] \ No newline at end of file +] + +[project.scripts] +medcoder = "medcoder.main:main" +medcoder_install_trud = "medcoder.trud_api:main" +medcoder_install_omop = "medcoder.omop_api:main" \ No newline at end of file -- GitLab