diff --git a/docs/api.md b/docs/api.md deleted file mode 100644 index fe7f6fdd1561d82e13f11d38fbb842b5dcbcb87e..0000000000000000000000000000000000000000 --- a/docs/api.md +++ /dev/null @@ -1,540 +0,0 @@ -<a id="__init__"></a> - -# \_\_init\_\_ - -<a id="__main__"></a> - -# \_\_main\_\_ - -<a id="util"></a> - -# util - -<a id="logging_config"></a> - -# logging\_config - -<a id="logging_config.setup_logger"></a> - -#### setup\_logger - -```python -def setup_logger(log_level: int = logging.INFO) -``` - -Sets up logger as a singleton outputing to file and sysout syserr - -<a id="logging_config.set_log_level"></a> - -#### set\_log\_level - -```python -def set_log_level(log_level: int) -``` - -Sets the log level for the acmc logger - -<a id="main"></a> - -# main - -<a id="main.trud_install"></a> - -#### trud\_install - -```python -def trud_install(args: argparse.Namespace) -``` - -Handle the `trud install` command. - -<a id="main.omop_install"></a> - -#### omop\_install - -```python -def omop_install(args: argparse.Namespace) -``` - -Handle the `omop install` command. - -<a id="main.omop_clear"></a> - -#### omop\_clear - -```python -def omop_clear(args: argparse.Namespace) -``` - -Handle the `omop clear` command. - -<a id="main.omop_delete"></a> - -#### omop\_delete - -```python -def omop_delete(args: argparse.Namespace) -``` - -Handle the `omop delete` command. - -<a id="main.phen_init"></a> - -#### phen\_init - -```python -def phen_init(args: argparse.Namespace) -``` - -Handle the `phen init` command. - -<a id="main.phen_fork"></a> - -#### phen\_fork - -```python -def phen_fork(args: argparse.Namespace) -``` - -Handle the `phen fork` command. - -<a id="main.phen_validate"></a> - -#### phen\_validate - -```python -def phen_validate(args: argparse.Namespace) -``` - -Handle the `phen validate` command. - -<a id="main.phen_map"></a> - -#### phen\_map - -```python -def phen_map(args: argparse.Namespace) -``` - -Handle the `phen map` command. - -<a id="main.phen_export"></a> - -#### phen\_export - -```python -def phen_export(args: argparse.Namespace) -``` - -Handle the `phen copy` command. - -<a id="main.phen_publish"></a> - -#### phen\_publish - -```python -def phen_publish(args: argparse.Namespace) -``` - -Handle the `phen publish` command. - -<a id="main.phen_copy"></a> - -#### phen\_copy - -```python -def phen_copy(args: argparse.Namespace) -``` - -Handle the `phen copy` command. - -<a id="main.phen_diff"></a> - -#### phen\_diff - -```python -def phen_diff(args: argparse.Namespace) -``` - -Handle the `phen diff` command. - -<a id="omop"></a> - -# omop - -OMOP Module -================ -This module provides functionality to manage OMOP vocabularies. - -<a id="omop.install"></a> - -#### install - -```python -def install(omop_zip_file: str, version: str) -``` - -Installs the OMOP release csv files in a file-based sql database - -<a id="omop.write_version_file"></a> - -#### write\_version\_file - -```python -def write_version_file(version: str) -``` - -Writes the OMOP vocaburaries and version to a file - -<a id="omop.clear"></a> - -#### clear - -```python -def clear(db_path: Path) -``` - -Clears the OMOP sql database - -<a id="omop.delete"></a> - -#### delete - -```python -def delete(db_path: Path) -``` - -Deletes the OMOP sql database - -<a id="parse"></a> - -# parse - -<a id="parse.CodesError"></a> - -## CodesError Objects - -```python -class CodesError() -``` - -A class used in InvalidCodesException to report an error if a code parser check fails - -<a id="parse.InvalidCodesException"></a> - -## InvalidCodesException Objects - -```python -class InvalidCodesException(Exception) -``` - -Custom exception class raised when invalid codes are found that cannot be resolved by processing - -<a id="parse.Proto"></a> - -## Proto Objects - -```python -class Proto() -``` - -Define checks as list of 3 tuple: (Message, Condition, Process) -- Message = The name of the condition (what is printed and logged) -- Condition = True if Passed, and False if Failed -- Process = Aims to resolve all issues that stop condition from passing (Do not change index!) - -<a id="parse.Proto.raise_exception"></a> - -#### raise\_exception - -```python -def raise_exception(ex: Exception) -``` - -Raises an exception inside a lambda function. Python does not allow using raise statement inside lambda because lambda can only contain expressions, not statements. Using raise_exception not raise_ as it's more explict - -<a id="parse.Proto.process"></a> - -#### process - -```python -def process(codes: pd.DataFrame, - codes_file: Path) -> Tuple[pd.DataFrame, list] -``` - -identify issues that do not pass and fix them with define/d process - -<a id="parse.Proto.verify"></a> - -#### verify - -```python -def verify(codes: pd.DataFrame, codes_file: Path) -``` - -verify codes in codes file - -<a id="parse.Read2"></a> - -## Read2 Objects - -```python -class Read2(Proto) -``` - -This Read2 class extends Proto, adding custom validation checks for a dataset of "Read2" codes. It ensures that the dataset is loaded, validates the codes based on several rules, and applies corrections or logs errors when necessary. - -<a id="parse.CodeTypeParser"></a> - -## CodeTypeParser Objects - -```python -class CodeTypeParser() -``` - -A class used in InvalidCodesException to report an error if a code parser check fails - -<a id="phen"></a> - -# phen - -Phenotype Module -================ -This module provides functionality for managing phenotypes. - -<a id="phen.PhenValidationException"></a> - -## PhenValidationException Objects - -```python -class PhenValidationException(Exception) -``` - -Custom exception class raised when validation errors in phenotype configuration file - -<a id="phen.construct_git_url"></a> - -#### construct\_git\_url - -```python -def construct_git_url(remote_url: str) -``` - -Constructs a git url for github or gitlab including a PAT token environment variable - -<a id="phen.create_empty_git_dir"></a> - -#### create\_empty\_git\_dir - -```python -def create_empty_git_dir(path: Path) -``` - -Creates a directory with a .gitkeep file so that it's tracked in git - -<a id="phen.check_delete_dir"></a> - -#### check\_delete\_dir - -```python -def check_delete_dir(path: Path, msg: str) -> bool -``` - -Checks on the command line if a user wants to delete a directory - -**Arguments**: - -- `path` _Path_ - path of the directory to be deleted -- `msg` _str_ - message to be displayed to the user - - -**Returns**: - -- `Boolean` - True if deleted - -<a id="phen.fork"></a> - -#### fork - -```python -def fork(phen_dir: str, upstream_url: str, upstream_version: str, - new_origin_url: str) -``` - -Forks an upstream phenotype in a remote repo at a specific version to a local director, and optionally sets to a new remote origin" - -**Arguments**: - -- `phen_dir` _str_ - local directory path where the upstream repo is to be cloned -- `upstream_url` _str_ - url to the upstream repo -- `upstream_version` _str_ - version in the upstream repo to clone -- `new_origin_url` _str, optional_ - url of the remote repo to set as the new origin. Defaults to None. - - -**Raises**: - -- `ValueError` - if the specified version is not in the upstream repo -- `ValueError` - if the upstream repo is not a valid phenotype repo -- `ValueError` - if there's any other problems with Git - -<a id="phen.init"></a> - -#### init - -```python -def init(phen_dir: str, remote_url: str) -``` - -Initial phenotype directory as git repo with standard structure - -<a id="phen.validate"></a> - -#### validate - -```python -def validate(phen_dir: str) -``` - -Validates the phenotype directory is a git repo with standard structure - -<a id="phen.read_table_file"></a> - -#### read\_table\_file - -```python -def read_table_file(path: Path, excel_sheet: str = "") -``` - -Load Code List File - -<a id="phen.preprocess_source_concepts"></a> - -#### preprocess\_source\_concepts - -```python -def preprocess_source_concepts( - df: pd.DataFrame, concept_set: dict, - code_file_path: Path) -> Tuple[pd.DataFrame, list] -``` - -Parses each column individually - Order and length will not be preserved! - -<a id="phen.translate_codes"></a> - -#### translate\_codes - -```python -def translate_codes(source_df: pd.DataFrame, target_code_type: str, - concept_name: str) -> pd.DataFrame -``` - -Translates each source code type the source coding list into a target type and returns all conversions as a concept set - -<a id="phen.publish"></a> - -#### publish - -```python -def publish(phen_dir: str, - msg: str, - remote_url: str, - increment: str = DEFAULT_VERSION_INC) -``` - -Publishes updates to the phenotype by commiting all changes to the repo directory - -<a id="phen.export"></a> - -#### export - -```python -def export(phen_dir: str, version: str) -``` - -Exports a phen repo at a specific tagged version into a target directory - -<a id="phen.copy"></a> - -#### copy - -```python -def copy(phen_dir: str, target_dir: str, version: str) -``` - -Copys a phen repo at a specific tagged version into a target directory - -<a id="phen.extract_concepts"></a> - -#### extract\_concepts - -```python -def extract_concepts(config_data: dict) -> Tuple[dict, Set[str]] -``` - -Extracts concepts as {name: file_path} dictionary and a name set. - -<a id="phen.extract_clean_deepdiff_keys"></a> - -#### extract\_clean\_deepdiff\_keys - -```python -def extract_clean_deepdiff_keys(diff: dict, key_type: str) -> Set[Any] -``` - -Extracts clean keys from a DeepDiff dictionary. - -**Arguments**: - -- `diff`: DeepDiff result dictionary -- `key_type`: The type of change to extract (e.g., "dictionary_item_added", "dictionary_item_removed") - -**Returns**: - -A set of clean key names - -<a id="phen.diff_phen"></a> - -#### diff\_phen - -```python -def diff_phen(new_phen_path: Path, new_version: str, old_phen_path: Path, - old_version: str, report_path: Path) -``` - -Compare the differences between two versions of a phenotype - -<a id="trud"></a> - -# trud - -<a id="trud.get_releases"></a> - -#### get\_releases - -```python -def get_releases(item_id: str, API_KEY: str, latest=False) -> list -``` - -Retrieve release information for an item from the TRUD API. - -<a id="trud.download_release_file"></a> - -#### download\_release\_file - -```python -def download_release_file(item_id: str, release_ordinal: str, release: dict, - file_json_prefix: str) -> Path -``` - -Download specified file type for a given release of an item. - -<a id="trud.create_map_directories"></a> - -#### create\_map\_directories - -```python -def create_map_directories() -``` - -Create map directories. - diff --git a/docs/index.md b/docs/index.md index ef5cc82be542d91f863ef52eb116feabbcc34cbe..0a6d9d81730213ad065f456c75642fe484cbceed 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,7 +9,7 @@ - [Example 1 - Basic local phenotype](./tutorials/example1.md) - [Example 2 - More complex local phenotype](./tutorials/example2.md) - [Example 3 - Using a remote git repository](./tutorials/example3.md) - - [API Reference](./api.md) + - [API Reference](./api/acmc.html) - [Change Log](./changelog.md) - [Troubleshooting](./troubleshooting.md) diff --git a/mkdocs.yml b/mkdocs.yml index d2b555a075380b07bfbdb69dca3f85d3ecd1a23b..5a7d0497d1ac989a5abe3752e0c9a3971790cf9b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -6,8 +6,16 @@ theme: nav: - Home: index.md - - API: - - acmc: api/acmc.html + - Installation: installation.md + - User Guide: user-guide.md + - Usage: usage.md + - Tutorial 1 Basic local phenotype: tutorials/example1.md + - Tutorial 2 More complex local phenotype: tutorials/example2.md + - Tutorial 3 Using a remote git repository: tutorials/example3.md + - API Reference: + - acmc: api/acmc.html + - Change Log: changelog.md + - Troubleshooting: troubleshooting.md markdown_extensions: - toc: