diff --git a/README.md b/README.md index 6e4363ea6693cde23a7828610b1ca78fe0a76587..4ebc592a32012598ccfb4854a5ae3bcc1abd7061 100644 --- a/README.md +++ b/README.md @@ -151,26 +151,36 @@ Follow these steps to initialize and manage a phenotype using `acmc`. In this ex acmc phen init ``` +**Expected Output:** + +```bash +[INFO] - Initialising Phenotype in directory: <path>/concepts-processing/workspace/phen +[INFO] - Creating phen directory structure and config files +[INFO] - Phenotype initialised successfully +``` + 2. **Copy example medical code lists to the phenotype codes directory** From the command prompt, copy medical code lists `/examples/codes`to the phenotype code directory: - - [Download `res176-abdominal-pain.csv`](.//examples/codes/clinical-codes-org/Symptom%20code%20lists/Abdominal%20pain/res176-abdominal-pain.csv) - - Alternatively, place your code lists in `./workspace/phen/codes`. ```bash cp -r ./examples/codes/* ./workspace/phen/codes ``` + - [Download `res176-abdominal-pain.csv`](.//examples/codes/clinical-codes-org/Symptom%20code%20lists/Abdominal%20pain/res176-abdominal-pain.csv) + - Alternatively, place your code lists in `./workspace/phen/codes`. + 3. **Copy the example phenotype configuration file to the phenotype directory** From the command prompt, copy example phenotype configuration files `/examples/config.json` to the phenotype directory: - - [Download `config.json`](./examples/config.json) - - Alternatively, place your own `config.json` file in `./workspace/phen`. ```bash cp -r ./examples/config.json ./workspace/phen ``` + - [Download `config.json`](./examples/config.json) + - Alternatively, place your own `config.json` file in `./workspace/phen`. + 4. **Validate the phenotype configuration** Use the followijng `acmc` command to validate the phenotype configuration to ensure it's correct: @@ -179,15 +189,35 @@ cp -r ./examples/config.json ./workspace/phen acmc phen validate ``` -Expected Output: +**Expected Output:** + +```bash +[INFO] - Validating phenotype: <path>/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +``` + +5. **Generate phenotype in Read2 code format** + + Use the following `acmc` command to generate the phenotype in `read2` format: + +```bash +acmc phen map -t read2 +``` -Once the command is executed, you should see output similar to this: +**Expected Output:** ```bash +[INFO] - Processing phenotype: <path>/concepts-processing/workspace/phen [INFO] - Validating phenotype: <path>/concepts-processing/workspace/phen [INFO] - Phenotype validated successfully +[INFO] - Processing read2 codes... +[INFO] - Converting to target code type read2 +[INFO] - Saved mapped concepts to <path>/concepts-processing/workspace/phen/map/read2.csv +[INFO] - Phenotype processed successfully ``` +The concept sets translating read2 to the acmc normalised CSV format will be stored in `./workspace/phen/concept-set/snomed/` in, e.g. `./workspace/phen/concept-set/read2/ABDO_PAIN.csv`. + 6. **Publish phenotype at an initial version** Use the following `acmc` command to publish the phenotype at an initial version: @@ -196,6 +226,15 @@ Once the command is executed, you should see output similar to this: acmc phen publish ``` +**Expected Output:** + +```bash +[INFO] - Validating phenotype: /home/mjbonifa/datahdd/brcbat/derived_datasets/mjbonifa/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +[INFO] - New version: v1.0.3 +[INFO] - Phenotype published successfully +``` + 7. **Generate phenotype in SNOWMED code format** Generate the phenotype in `snomed` format: @@ -204,6 +243,20 @@ Generate the phenotype in `snomed` format: acmc phen map -t snomed ``` +**Expected Output:** + +```bash +[INFO] - Processing phenotype: <path>/concepts-processing/workspace/phen +[INFO] - Validating phenotype: <path>/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +[INFO] - Processing read2 codes... +[INFO] - Converting to target code type snomed +[INFO] - Saved mapped concepts to <path>/concepts-processing/workspace/phen/map/snomed.csv +[INFO] - Phenotype processed successfully +``` + +The concept sets translating read2 to snomed will be stored in acmc CSV format in `./workspace/phen/concept-set/snomed/`, e.g. `./workspace/phen/concept-set/snomed/ABDO_PAIN.csv` + 8. **Get a copy of the previous version from the repo** Use the following `acmc` command to retrieve a copy of the previous version (`v1.0.3`) from the repository: @@ -212,14 +265,38 @@ acmc phen map -t snomed acmc phen copy -v v1.0.3 ``` +**Expected Output:** + +```bash +[INFO] - Validating phenotype: <path>/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +[INFO] - Copying repo <path>/concepts-processing/workspace/phen to <path>/concepts-processing/workspace/v1.0.3 +[INFO] - Checking out version v1.0.3... +[INFO] - Phenotype copied successfully +``` + +A copy of the phenotype will be created in the directory `./workspace/v1.0.3` + 9. **Compare the previous version `v1.0.3` with the latest version** - Use the following `acmc` command to compare the previous version (`v1.0.3`) with the latest version in the repository: + Use the following `acmc` command to compare the previous version `v1.0.3` with the latest version in the repository: ```bash acmc phen diff -old ./workspace/v1.0.3/ ``` +**Expected Output:** + +```bash +[INFO] - Validating phenotype: ./workspace/v1.0.3/ +[INFO] - Phenotype validated successfully +[INFO] - Validating phenotype: <path>/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +[INFO] - Phenotypes diff'd successfully +``` + +A report comparing the phenotype versions will be created in the workspace called './workspace/phen/v1.0.3_diff.md' + 10. **Publish the phenotype at the next version** Use the following `acmc` command to publish the phenotype at the next version: @@ -228,6 +305,14 @@ acmc phen diff -old ./workspace/v1.0.3/ acmc phen publish ``` +**Expected Output:** + +```bash +[INFO] - Validating phenotype: /home/mjbonifa/datahdd/brcbat/derived_datasets/mjbonifa/concepts-processing/workspace/phen +[INFO] - Phenotype validated successfully +[INFO] - New version: v1.0.4 +[INFO] - Phenotype published successfully +``` ## Usage The `acmc` command-line tool provides various commands to interact with TRUD, OMOP, and Phenotype data. Below are the usage details for each command. diff --git a/acmc/phen.py b/acmc/phen.py index f36d64c42946ffa89943b559daceb1a1c8714fcf..e1ba3d6f64b162eab8e4a02136afc2079a6690f1 100644 --- a/acmc/phen.py +++ b/acmc/phen.py @@ -80,7 +80,7 @@ def init(phen_dir, remote_url): # check if directory already exists and ask user if they want to recreate it configure = False if phen_path.exists() and phen_path.is_dir(): # Check if it exists and is a directory - user_input = input(f"The phen directory '{phen_path}' already exists. Do you want to reinitialise? (yes/no): ").strip().lower() + user_input = input(f"The phen directory already exists. Do you want to reinitialise? (yes/no): ").strip().lower() if user_input in ['yes', 'y']: shutil.rmtree(phen_path) configure = True; @@ -599,7 +599,7 @@ def publish(phen_dir): # set version and write to config file so consistent with repo version next_minor_version = commit_count + 1 version = f"v{major_version}.{next_minor_version}" - logger.info(f"New version: {version}") + logger.debug(f"New version: {version}") config['concept_sets']['version'] = version with open(config_path, "w", encoding="utf-8") as f: json.dump(config, f, indent=4) @@ -613,7 +613,7 @@ def publish(phen_dir): if version in repo.tags: raise Exception (f"Tag {version} already exists in repo {phen_path}") repo.create_tag(version, message=f"Release {version}") - logger.info(f"Created tag: {version}") + logger.info(f"New version: {version}") # push to origin if a remote repo try: