diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..08c2f56e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,88 @@ +name: Documentation + +on: + pull_request: + push: + branches: + - main + tags: + - "*" + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Install dependencies + run: uv sync --extra docs + + - name: Generate documentation + run: uv run python -m scripts.build_docs + + - name: Verify documentation build + run: | + uv run zensical build --clean --strict + test -f site/index.html + + publish: + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + concurrency: + group: docs-pages + cancel-in-progress: false + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Install publishing dependencies + run: | + uv sync --extra docs + # Zensical requires its mike fork, which is not published on PyPI. + uv pip install git+https://github.com/squidfunk/mike.git + + - name: Generate documentation + run: uv run python -m scripts.build_docs + + - name: Publish versioned documentation + env: + GIT_REF_NAME: ${{ github.ref_name }} + GIT_REF_TYPE: ${{ github.ref_type }} + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + if [[ "$GIT_REF_TYPE" == "branch" ]]; then + uv run mike deploy --push latest + uv run mike set-default --push latest + else + uv run mike deploy --push "$GIT_REF_NAME" + fi diff --git a/.gitignore b/.gitignore index 5f1c1695..ecf8da11 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,7 @@ notebooks/scratch/ notes lint uta_*.pgd.gz + +# Generated documentation +/docs-build/ +/site/ diff --git a/Makefile b/Makefile index 3631420d..42bd0304 100644 --- a/Makefile +++ b/Makefile @@ -97,11 +97,16 @@ format: lint: python3 -m ruff check --fix -#=> docs -- make sphinx docs -.PHONY: docs -docs: develop - # RTD makes json. Build here to ensure that it works. - make -C doc html json +#=> docs: stage and build documentation with strict checks +.PHONY: docs docs-serve +docs: + python -m scripts.build_docs + zensical build --clean --strict + +#=> docs-serve: stage documentation and start a local preview +docs-serve: + python -m scripts.build_docs + zensical serve ############################################################################ #= CLEANUP diff --git a/README.md b/README.md index 4a7af41b..494a2489 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# vrs-python +# VRS-Python **VRS-Python** provides Python language support and a reference implementation for the [GA4GH Variation Representation Specification(VRS)](https://github.com/ga4gh/vrs). +See the [**documentation**](https://ga4gh.github.io/vrs-python/latest/) for installation, usage, and API reference. + ## Information [![license](https://img.shields.io/badge/license-Apache-green)](https://github.com/ga4gh/vrs-python/blob/main/LICENSE) [![binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ga4gh/vrs-python/main?labpath=notebooks) @@ -22,326 +24,9 @@ - Algorithm for generating consistent, globally unique identifiers for variation without a central authority - Algorithm for performing fully justified allele normalization - Translating from and to other variant formats -- [Annotate VCFs with VRS](https://github.com/ga4gh/vrs-python/blob/main/docs/extras/vcf_annotator.md) +- Annotate VCFs with VRS - Convert GA4GH objects between inlined and referenced forms -## Known Issues - -**You are encouraged to** [browse issues](https://github.com/ga4gh/vrs-python/issues). -All known issues are listed there. Please report any issues you find. - -## Installing VRS-Python Locally - -### Prerequisites - -- Python >= 3.11 - - _Note: Python 3.14 is required for developers contributing to VRS-Python. The - Makefile sets up a virtual environment in `venv/3.14` and expects Python to be - available as `python3.14`._ -- libpq -- postgresql - -#### MacOS - -You can use Homebrew to install the prerequisites. See the -[Homebrew documentation](https://docs.brew.sh/Installation) for how to install. Make - sure Homebrew is up-to-date by running `brew update`. - -```shell -brew install libpq -brew install python3 -brew install postgresql@14 -``` - -#### Ubuntu - -```shell -sudo apt install gcc libpq-dev python3-dev -``` - -### Installation Steps - -#### 1. Install VRS-Python with pip - -VRS-Python is available on [PyPI](https://pypi.org/project/ga4gh.vrs/). - -```shell -pip install 'ga4gh.vrs[extras]' -``` - -The `[extras]` argument tells pip to install packages to fulfill the dependencies of the -`ga4gh.vrs.extras` package. - -#### 2. Install External Data Sources - -The `ga4gh.vrs.extras` modules are not part of the VR spec per se. They are -bundled with ga4gh.vrs for development and installation convenience. These -modules depend directly and indirectly on external data sources of sequences, -transcripts, and genome-transcript alignments. - -First, you must install a local [SeqRepo](https://github.com/biocommons/biocommons.seqrepo): - -```shell -pip install biocommons.seqrepo -export SEQREPO_VERSION=2024-12-20 # or newer if available -- check `seqrepo list-remote-instances` -sudo mkdir -p /usr/local/share/seqrepo -sudo chown $USER /usr/local/share/seqrepo -seqrepo pull -i $SEQREPO_VERSION -seqrepo update-latest -``` - -If you encounter a permission error similar to the one below: - -```shell -PermissionError: [Error 13] Permission denied: '/usr/local/share/seqrepo/2024-12-20._fkuefgd' -> '/usr/local/share/seqrepo/2024-12-20' -``` - -Try moving data manually with `sudo`: - -```shell -sudo mv /usr/local/share/seqrepo/$SEQREPO_VERSION.* /usr/local/share/seqrepo/$SEQREPO_VERSION -``` - -To make installation easy, we recommend using [Docker](https://docs.docker.com/get-started/get-docker/) -to install the other Biocommons tools - [SeqRepo REST](https://github.com/biocommons/seqrepo-rest-service) and -[UTA](https://github.com/biocommons/uta). If you would like to use local instances of UTA, -see [UTA](https://github.com/biocommons/uta) directly. We do provide some additional -setup help [here](./docs/setup_help/). - -Next, run the following commands: - -```shell -docker volume create --name=uta_vol -docker volume create --name=seqrepo_vol -docker compose up -``` - -> [!NOTE] -> You must run all Docker commands from the root of the vrs-python repository (where `docker-compose.yml` lives). See [installing for development](#installing-for-development) -> for the clone commands. -> If you use Docker Compose v1, use `docker-compose` instead of `docker compose`. -> However, we do recommend [upgrading to v2](https://docs.docker.com/compose/releases/migrate/). - -This should start three containers: - -- [seqrepo](https://github.com/biocommons/seqrepo): downloads seqrepo into a - docker volume and exits -- [seqrepo-rest-service](https://github.com/biocommons/seqrepo-rest-service): a - REST service on seqrepo (localhost:5000) -- [uta](https://github.com/biocommons/uta): a database of transcripts and - alignments (localhost:5432) - -Check that the seqrepo-rest-service and uta containers are running, by running: - -```shell -$ docker ps -CONTAINER ID IMAGE // NAMES -86e872ab0c69 biocommons/seqrepo-rest-service:latest // vrs-python_seqrepo-rest-service_1 -a40576b8cf1f biocommons/uta:uta_20241220 // vrs-python_uta_1 -``` - -Depending on your network and host, the _first_ run is likely to take 5-15 -minutes in order to download and install data. Subsequent startups should be -nearly instantaneous. - -You can test UTA and seqrepo installations like so: - -```shell -$ psql -XAt postgres://anonymous@localhost/uta -c 'select count(*) from uta_20241220.transcript' -314227 -curl 'http://127.0.0.1:5000/seqrepo/1/sequence/refseq:NM_000059.4?end=20' -AGAGGCGGAGCCGCTGTGGC -``` - -##### It doesn't work - -Here are some things to try. - -- Bring up one service at a time. For example, if you haven't download seqrepo - yet, you might see this: - - ```shell - $ docker compose up seqrepo-rest-service - Starting vrs-python_seqrepo-rest-service_1 ... done - Attaching to vrs-python_seqrepo-rest-service_1 - seqrepo-rest-service_1 | 2022-07-26 15:59:59 seqrepo_rest_service.__main__[1] INFO Using seqrepo_dir='/usr/local/share/seqrepo/2024-12-20' from command line - ⋮ - seqrepo-rest-service_1 | OSError: Unable to open SeqRepo directory /usr/local/share/seqrepo/2024-12-20 - vrs-python_seqrepo-rest-service_1 exited with code 1 - ``` - -- If you are having issues with UTA: if your machine is already running - postgresql on port 5432 (which is the - default on many systems), you may see an error message such as this: - ```shell - $ psql -XAt postgres://anonymous@localhost/uta -c 'select count(*) from uta_20241220.transcript' - psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: role "anonymous" does not exist - ``` - You can move your UTA installation to a different port as follows: - - Select a new port number for UTA, and verify that the port is available. - For example, if you have sudo privileges on your machine, you can verify - the port is available with the `lsof` command: - ``` - sudo lsof -i :[port_number] - ``` - If the port is available, the output of this command should be 0 lines long. - - Edit your docker-compose.yml file. In the lines - ``` - ports: - - 5432:5432 - ``` - replace the *first* number with a different number to specify a port on - your local machine. - ```` - ports: - - [your_port_number]:5432 - - Repeat the `docker compose up` command - - Repeat the command above to verify that there is now a docker command - listening at this port. - ``` - sudo lsof -i :[your_port_number] - ``` - This time, you should see that a docker command is using the port. - - Specify the new port in your psql command: - ```shell - $ psql -XAt postgres://anonymous@localhost/uta -p [your_port_number] -c 'select count(*) from uta_20241220.transcript' - ``` - - Set the `UTA_DB_URL` environment variable to specify your port. - ```shell - export UTA_DB_URL="postgresql://anonymous@localhost:[your_port_number]/uta/uta_20241220" - ``` - -- If you are having issues with SeqRepo, check to see if there is another - process using port 5000, and try moving to a different port: - - Follow the instructions above to see if port 5000 is already in use. - - If it is, edit your docker-compose.yml file to specify a different port. - In the lines - ``` - ports: - - 5000:5000 - ``` - replace the *first* number with a different number to specify a port on - your local machine. - ```` - ports: - - [your_port_number]:5000 - - Repeat the `docker compose up` command - - Test the SeqRepo REST API service with this new port - ```shell - curl 'http://127.0.0.1:[your_port_number]/seqrepo/1/sequence/refseq:NM_000059.4?end=20' - ``` - - Set the `GA4GH_VRS_DATAPROXY_URI` environment variable to point to - this UL: - ```shell - $ export GA4GH_VRS_DATAPROXY_URI=http://localhost:[your_port_number]/seqrepo - $ export SEQREPO_URI=http://localhost:[your_port_number] - ``` - -## VRS-Python and VRS Version Correspondence - -The ga4gh/vrs-python repo embeds the ga4gh/vrs repo as a git submodule for testing purposes. -Each ga4gh.vrs package on PyPI embeds a particular version of VRS. The -correspondences between the packages that are **currently maintained** may be summarized as: - -| vrs-python branch | vrs-python tag/version | vrs branch | vrs version | -| --- | --- | --- | --- | -| [main](https://github.com/ga4gh/vrs-python/tree/main) _(default branch)_ | 2.x | [2.x](https://github.com/ga4gh/vrs/tree/2.x) | 2.x | -| [1.x](https://github.com/ga4gh/vrs-python/tree/1.x) | 0.8.x | [1.x](https://github.com/ga4gh/vrs/tree/1.x) | 1.x | - -⚠ **Note: Only 2.x branch is being actively maintained. The 1.x branch will only be maintained for bug fixes.** - -⚠ **Developers: See the development section below for recommendations for using submodules -gracefully (and without causing problems for others!).** - -### Previous VRS-Python and VRS Version Correspondence - -The correspondences between the packages that are **no longer maintained** may be summarized as: - -| vrs-python branch | vrs-python tag/version | vrs branch | vrs version | -| --- | --- | --- | --- | -| [0.9](https://github.com/ga4gh/vrs-python/tree/0.9) | 0.9.x | [metaschema-update](https://github.com/ga4gh/vrs/tree/metaschema-update) | N/A | -| [0.7](https://github.com/ga4gh/vrs-python/tree/0.7) | 0.7.x | [1.2](https://github.com/ga4gh/vrs/tree/1.2) | 1.2.x | -| [0.6](https://github.com/ga4gh/vrs-python/tree/0.6) | 0.6.x | [1.1](https://github.com/ga4gh/vrs/tree/1.1) | 1.1.x | - -## Developers - -This section is intended for developers who contribute to VRS-Python. - -### Installing for development - -[Fork the GitHub repo](https://github.com/ga4gh/vrs-python/fork). - -Then, clone your fork and initialize a development environment: - -```shell -git clone --recurse-submodules git@github.com:YOUR_GITHUB_ID/vrs-python.git -cd vrs-python -make devready -source venv/3.14/bin/activate -``` - -This setup includes [pre-commit hooks](https://pre-commit.com/). If you create a virtual environment manually, be sure to install the hooks yourself; otherwise, commits may fail during [CI/CD checks](https://github.com/ga4gh/vrs-python/actions/workflows/python-cqa.yml): - -```shell -source venv/3.14/bin/activate -pre-commit install -``` - -If you already cloned the repo, but forgot to include `--recurse-submodules` you can run: - -```shell -git submodule update --init --recursive -``` - -#### Submodules - -vrs-python embeds vrs as a submodule, only for testing purposes. When checking out vrs-python and switching -branches, it is important to make sure that the submodule tracks vrs-python -correctly. The recommended way to do this is `git config --global submodule.recurse true`. **If you don't set submodule.recurse, developers and -reviewers must be extremely careful to not accidentally upgrade or downgrade -schemas with respect to vrs-python.** - -Alternatively, see `misc/githooks/`. - -### Testing - -This package implements typical unit tests for ga4gh.core and ga4gh.vrs. This -package also implements the compliance tests from vrs (vrs/validation) in the -tests/validation/ directory. - -To run tests: - -```shell -make test -``` - -## Running the Notebooks - -The notebooks **do not** require you to setup SeqRepo or UTA from -[Install External Data Sources](#2-install-external-data-sources). - -### Running the Notebooks on Binder - -[Binder](https://mybinder.org/) allows you to create custom computing environments that can be shared and used by many remote users. - -You can access the notebooks on Binder [here](https://mybinder.org/v2/gh/ga4gh/vrs-python/main?labpath=notebooks). - -### Running the Notebooks on the Terra platform - -[Terra](https://terra.bio) is a cloud platform for biomedical research developed by the Broad Institute, Microsoft and Verily. The platform includes preconfigured environments that provide user-friendly access to various applications commonly used in bioinformatics, including Jupyter Notebooks. - -We have created a public [`VRS-demo-notebooks`](https://app.terra.bio/#workspaces/terra-outreach/VRS-demo-notebooks) workspace in Terra that contains the demo notebooks along with instructions for running them with minimal setup. To get started, see either the [`VRS-demo-notebooks`](https://app.terra.bio/#workspaces/terra-outreach/VRS-demo-notebooks) workspace or the [`Terra.ipynb`](notebooks/Terra.ipynb) notebook in this repository. - -### Running the Notebooks with VS Code - -[VS Code](https://code.visualstudio.com/) is a code editor developed by Microsoft. It is lightweight, highly customizable, and supports a wide range of programming languages, with a robust extension system. You can download VS Code [here](https://code.visualstudio.com/Download). - -1. Open VS Code. -2. Use Extensions view (Ctrl+Shift+X or ⌘+Shift+X) to install the [Jupyter extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter). -3. Navigate to your vrs-python project folder and open it in VS Code. -4. In a notebook, click `Select Kernel` at the top right. Select the option where the path is `venv/3.14/bin/python3`. See [here](https://code.visualstudio.com/docs/datascience/jupyter-kernel-management) for more information on managing Jupyter Kernels in VS Code. -5. After selecting the kernel you can now run the notebook. - ## Security Note (from the GA4GH Security Team) A stand-alone security review has been performed on the specification itself. diff --git a/docs/api/core-models.md b/docs/api/core-models.md new file mode 100644 index 00000000..c3a8b143 --- /dev/null +++ b/docs/api/core-models.md @@ -0,0 +1,8 @@ +# Core models + +Represent shared concepts, codes, and extensions with [GKM-Core](https://github.com/ga4gh/gkm-core) models. + +::: ga4gh.core.models + options: + inherited_members: true + show_if_no_docstring: true diff --git a/docs/api/data-proxies.md b/docs/api/data-proxies.md new file mode 100644 index 00000000..f50a870d --- /dev/null +++ b/docs/api/data-proxies.md @@ -0,0 +1,9 @@ +# Data proxies + +::: ga4gh.vrs.dataproxy + +## Data proxy interface + +The data proxy interface defines sequence retrieval, alias translation, and validation. + +::: ga4gh.vrs.dataproxy._DataProxy diff --git a/docs/api/identifiers-and-digests.md b/docs/api/identifiers-and-digests.md new file mode 100644 index 00000000..f2866b08 --- /dev/null +++ b/docs/api/identifiers-and-digests.md @@ -0,0 +1,5 @@ +# Identifiers and digests + +::: ga4gh.core.identifiers + +::: ga4gh.core.digests diff --git a/docs/api/index.md b/docs/api/index.md new file mode 100644 index 00000000..a929a7cc --- /dev/null +++ b/docs/api/index.md @@ -0,0 +1,13 @@ +# API reference + +Install `ga4gh.vrs[extras]` for translation, HGVS utilities, and VCF annotation. + +- [GKM-Core models](core-models.md): Create and validate GKM-Core objects. +- [VRS models](vrs-models.md): Create and validate VRS objects. +- [Identifiers and digests](identifiers-and-digests.md): Compute identifiers and digests for VRS objects. +- [Normalization](normalization.md): Normalize equivalent allele descriptions to a consistent representation. +- [Data proxies](data-proxies.md): Retrieve sequences, translate aliases, and validate sequence data. +- [Translation and HGVS](translation-and-hgvs.md): Convert variant descriptions to and from VRS. +- [Object references and storage](object-references-and-storage.md): Replace nested objects with references, resolve references, and store objects. +- [VCF annotation](vcf-annotation.md): Annotate VCF records with VRS allele identifiers from Python. +- [VRS annotate](../extras/vrs-annotate.md): Annotate VCF files with VRS allele identifiers from the command line. diff --git a/docs/api/normalization.md b/docs/api/normalization.md new file mode 100644 index 00000000..951779a1 --- /dev/null +++ b/docs/api/normalization.md @@ -0,0 +1,6 @@ +# Normalization + +Normalize alleles before computing identifiers so equivalent indel descriptions +produce consistent results. Normalization requires [sequence data](../data-services.md). + +::: ga4gh.vrs.normalize diff --git a/docs/api/object-references-and-storage.md b/docs/api/object-references-and-storage.md new file mode 100644 index 00000000..c56a4d48 --- /dev/null +++ b/docs/api/object-references-and-storage.md @@ -0,0 +1,7 @@ +# Object references and storage + +::: ga4gh.vrs.enderef + +::: ga4gh.core.enderef + +::: ga4gh.vrs.extras.object_store diff --git a/docs/api/translation-and-hgvs.md b/docs/api/translation-and-hgvs.md new file mode 100644 index 00000000..dd58985a --- /dev/null +++ b/docs/api/translation-and-hgvs.md @@ -0,0 +1,7 @@ +# Translation and HGVS + +::: ga4gh.vrs.extras.translator + options: + inherited_members: true + +::: ga4gh.vrs.utils.hgvs_tools diff --git a/docs/api/vcf-annotation.md b/docs/api/vcf-annotation.md new file mode 100644 index 00000000..c56f21ba --- /dev/null +++ b/docs/api/vcf-annotation.md @@ -0,0 +1,3 @@ +# VCF annotation + +::: ga4gh.vrs.extras.annotator.vcf diff --git a/docs/api/vrs-models.md b/docs/api/vrs-models.md new file mode 100644 index 00000000..caecfe4f --- /dev/null +++ b/docs/api/vrs-models.md @@ -0,0 +1,8 @@ +# VRS models + +Represent variations, sequence locations, and sequence states with VRS models. + +::: ga4gh.vrs.models + options: + inherited_members: true + show_if_no_docstring: true diff --git a/docs/assets/css/extra.css b/docs/assets/css/extra.css new file mode 100644 index 00000000..234f977c --- /dev/null +++ b/docs/assets/css/extra.css @@ -0,0 +1,34 @@ +/* VRS-Python theming */ + +/* GA4GH brand palette. Dark blue carries text and UI chrome so that it remains + readable; light blue is reserved for highlights and illustrations. */ +:root, +[data-md-color-scheme="slate"] { + --md-primary-fg-color: #1b75bb; + --md-primary-fg-color--light: #4faedc; + --md-primary-fg-color--dark: #155a8f; + --md-accent-fg-color: #1b75bb; + --md-accent-fg-color--transparent: rgb(27 117 187 / 10%); +} + +[data-md-color-scheme="slate"] { + --md-accent-fg-color: #4faedc; + --md-accent-fg-color--transparent: rgb(79 174 220 / 10%); +} + +/* Render the compact GA4GH mark in white on blue header surfaces. */ +.md-header .md-logo img, +.md-nav--primary > .md-nav__title[for="__drawer"] .md-logo img { + filter: brightness(0) invert(1); +} + +/* Omit the right-hand table of contents when a page has nothing worth + navigating to — i.e. zero or one heading. The :has() test keeps the TOC only + when its list holds a second entry (a sibling top-level heading, or a nested + sub-heading under a lone one); otherwise the sidebar is hidden. + Pages with no sub-pages hide the left nav via `hide: navigation` front matter, + since Material renders the full nav tree into every page's primary sidebar and + CSS alone can't tell an empty section from a populated one. */ +.md-sidebar--secondary:not(:has(.md-nav__list .md-nav__item:nth-child(2))) { + display: none; +} diff --git a/docs/assets/images/ga4gh-favicon.svg b/docs/assets/images/ga4gh-favicon.svg new file mode 100644 index 00000000..d6f93809 --- /dev/null +++ b/docs/assets/images/ga4gh-favicon.svg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/assets/js/external-links.js b/docs/assets/js/external-links.js new file mode 100644 index 00000000..411f81ed --- /dev/null +++ b/docs/assets/js/external-links.js @@ -0,0 +1,19 @@ +(() => { + function markExternalLinks() { + for (const link of document.querySelectorAll("a[href]")) { + const url = new URL(link.href, window.location.href); + const isWebLink = url.protocol === "http:" || url.protocol === "https:"; + + if (isWebLink && url.origin !== window.location.origin) { + link.target = "_blank"; + link.rel = "noopener noreferrer"; + } + } + } + + document.addEventListener("DOMContentLoaded", markExternalLinks); + + if (typeof document$ !== "undefined") { + document$.subscribe(markExternalLinks); + } +})(); diff --git a/docs/compatibility.md b/docs/compatibility.md new file mode 100644 index 00000000..443c4617 --- /dev/null +++ b/docs/compatibility.md @@ -0,0 +1,24 @@ +# VRS Compatibility + +## Supported GKM versions + +The currently supported VRS-Python version implements the following GKM versions: + + + +## VRS release correspondence + +| vrs-python branch | vrs-python tag/version | vrs branch | vrs version | +| --- | --- | --- | --- | +| [v3](https://github.com/ga4gh/vrs-python/tree/v3) | 3.x | [2.1](https://github.com/ga4gh/vrs/tree/2.1) | 2.1.x | + +## Older versions + +These versions are no longer maintained: + +| vrs-python branch | vrs-python tag/version | vrs branch | vrs version | +| --- | --- | --- | --- | +| [1.x](https://github.com/ga4gh/vrs-python/tree/1.x) | 0.8.x | [1.x](https://github.com/ga4gh/vrs/tree/1.x) | 1.x | +| [0.9](https://github.com/ga4gh/vrs-python/tree/0.9) | 0.9.x | [metaschema-update](https://github.com/ga4gh/vrs/tree/metaschema-update) | N/A | +| [0.7](https://github.com/ga4gh/vrs-python/tree/0.7) | 0.7.x | [1.2](https://github.com/ga4gh/vrs/tree/1.2) | 1.2.x | +| [0.6](https://github.com/ga4gh/vrs-python/tree/0.6) | 0.6.x | [1.1](https://github.com/ga4gh/vrs/tree/1.1) | 1.1.x | diff --git a/docs/data-services.md b/docs/data-services.md new file mode 100644 index 00000000..ef009d6d --- /dev/null +++ b/docs/data-services.md @@ -0,0 +1,239 @@ +# Set up SeqRepo and UTA + +Some VRS operations need external data: + +- [SeqRepo](https://github.com/biocommons/biocommons.seqrepo) provides reference + sequences and aliases for validation, coordinate interpretation, and normalization. +- [UTA](https://github.com/biocommons/uta) provides transcript metadata and + alignments for HGVS interpretation and mapping. + +| Workflow | Data required | +| --- | --- | +| Model validation, serialization, identifier computation | Usually none; reference sequence validation requires SeqRepo | +| Allele normalization, SPDI/gnomAD translation, VCF annotation | Reference sequences and aliases, supplied by SeqRepo | +| HGVS transcript interpretation and mapping | Sequence data and, when transcript metadata or alignments are needed, UTA | + +## Docker Compose + +Docker Compose sets up SeqRepo REST and UTA, including the SeqRepo dataset. +You do not need a separate local SeqRepo installation for this setup. + +Install `ga4gh.vrs[extras]` (see [installation](installation.md)) and +[Docker](https://docs.docker.com/get-started/get-docker/), then clone this repository: + +```shell +git clone https://github.com/ga4gh/vrs-python.git +cd vrs-python +``` + +Run all Compose commands from the repository root, where `docker-compose.yml` +lives. Create the data volumes and start the services: + +```shell +docker volume create uta_vol +docker volume create seqrepo_vol +docker compose up +``` + +Compose starts three containers: + +| Service | Purpose | +| --- | --- | +| `seqrepo` | Downloads the `2024-12-20` dataset into `seqrepo_vol`, then exits | +| [seqrepo-rest-service](https://github.com/biocommons/seqrepo-rest-service) | Serves the downloaded sequences at `http://localhost:5000` | +| [uta](https://github.com/biocommons/uta) | Runs the `uta_20241220` transcript and alignment database on port `5432`, with data in `uta_vol` | + +- The first startup may take 5–15 minutes, depending on your network and host. +- Allow enough disk space for the datasets. Later startups reuse the downloaded data. +- If SeqRepo REST starts before the download finishes, follow the + [missing directory steps](#missing-seqrepo-directory). + +These commands use Compose v2 (`docker compose`). If you still use v1, the command +is `docker-compose`; [upgrading to v2](https://docs.docker.com/compose/releases/migrate/) +is recommended. + +### Configure Python clients + +Set these environment variables so VRS-Python can connect to the services: + +```shell +export GA4GH_VRS_DATAPROXY_URI='seqrepo+http://localhost:5000/seqrepo' +export UTA_DB_URL='postgresql://anonymous:anonymous@localhost:5432/uta/uta_20241220' +``` + +```python +from ga4gh.vrs.dataproxy import create_dataproxy + +dp = create_dataproxy() # Reads GA4GH_VRS_DATAPROXY_URI +print(dp.get_sequence("refseq:NM_000059.4", 0, 20)) +``` + +The expected sequence is `AGAGGCGGAGCCGCTGTGGC`. + +### Verify the services + +In another terminal, check that `seqrepo-rest-service` and `uta` are running: + +```shell +docker compose ps +``` + +Look for both services with status `Up` and ports `5000` and `5432` published. +The relevant columns should look similar to this (container names and elapsed +times may differ): + +```text +NAME SERVICE STATUS PORTS +vrs-python-seqrepo-rest-service-1 seqrepo-rest-service Up 2 minutes 0.0.0.0:5000->5000/tcp +vrs-python-uta-1 uta Up 2 minutes 0.0.0.0:5432->5432/tcp +``` + +The `seqrepo` download container should exit after completing its work, so it +will not appear in the default `docker compose ps` output. Use +`docker compose ps --all` to see it; a successful download shows `Exited (0)`. + +Test the two running services: + +```shell +curl --write-out '\n' 'http://localhost:5000/seqrepo/1/sequence/refseq:NM_000059.4?end=20' +``` + +The sequence request should return `AGAGGCGGAGCCGCTGTGGC`. + +Check UTA with the `psql` client: + +```shell +psql -XAt 'postgresql://anonymous:anonymous@localhost:5432/uta' \ + -c 'select count(*) from uta_20241220.transcript' +``` + +The query should return a positive transcript count, such as `329090`. + +## Local SeqRepo + +A local sequence store avoids REST requests. Use this as an alternative to the +Compose-managed SeqRepo volume. Install SeqRepo and prepare its default data +directory: + +```shell +pip install biocommons.seqrepo +sudo mkdir -p /usr/local/share/seqrepo +sudo chown "$USER" /usr/local/share/seqrepo +``` + +Choose a dataset listed by `seqrepo list-remote-instances`, then download it: + +```shell +seqrepo list-remote-instances +export SEQREPO_VERSION=2024-12-20 # Or a newer available dataset +seqrepo pull -i "$SEQREPO_VERSION" +seqrepo update-latest +export GA4GH_VRS_DATAPROXY_URI='seqrepo+file:///usr/local/share/seqrepo/latest' +``` + +See [SeqRepo's installation documentation](https://github.com/biocommons/biocommons.seqrepo) +for alternate storage locations. + +If a completed download raises a `PermissionError` when renaming its temporary +directory, move it manually. For example: + +```shell +sudo mv /usr/local/share/seqrepo/2024-12-20._fkuefgd /usr/local/share/seqrepo/2024-12-20 +seqrepo update-latest +``` + +Replace those paths with the temporary and final paths from your error message. + +## Local UTA + +To install UTA locally, follow the instructions in the +[UTA repository](https://github.com/biocommons/uta). + +## Configuration + +| Setting | Purpose | +| --- | --- | +| `GA4GH_VRS_DATAPROXY_URI` | Read automatically by `create_dataproxy()` when no explicit `uri` is supplied | +| `UTA_DB_URL` | HGVS library's UTA connection, including the schema name | +| `SEQREPO_URI` | Read by some notebooks and examples and passed as an explicit `uri`, overriding `GA4GH_VRS_DATAPROXY_URI`; uses the same `seqrepo+` format | + +Data-proxy URIs must include the `seqrepo+` provider prefix. Supported formats: + +- Local absolute path: `seqrepo+file:///usr/local/share/seqrepo/latest` +- Local relative path: `seqrepo+:../relative/path/to/seqrepo/latest` +- HTTP service: `seqrepo+http://example.org:5000/seqrepo` +- HTTPS service: `seqrepo+https://example.org/seqrepo` + +You must supply a URI or set `GA4GH_VRS_DATAPROXY_URI`. + +## Troubleshooting + +### Missing SeqRepo directory + +If `seqrepo-rest-service` exits with `OSError: Unable to open SeqRepo directory +/usr/local/share/seqrepo/2024-12-20`, check the download container's logs: + +```shell +docker compose logs seqrepo +``` + +Wait for the download to finish, then start the REST service again: + +```shell +docker compose up seqrepo-rest-service +``` + +You can start services individually this way to isolate a startup failure. To +inspect the REST service or UTA logs, run: + +```shell +docker compose logs seqrepo-rest-service uta +``` + +### Port already in use + +Another PostgreSQL server may already use port `5432`. A UTA connection error +such as `FATAL: role "anonymous" does not exist` can mean your client reached that +server. Another process may also occupy SeqRepo REST's port `5000`. + +Check the port with `sudo lsof -i :5432` or `sudo lsof -i :5000`. Choose an unused +port; `sudo lsof -i :5433`, for example, should produce no output if it is free. + +In `docker-compose.yml`, change the first number in the service's port mapping. +The first number is the host port; the second is the container port. For example, +use `5433:5432` for UTA or `5001:5000` for SeqRepo REST: + +```yaml +# Under the uta service: +ports: + - 5433:5432 + +# Under the seqrepo-rest-service service: +ports: + - 5001:5000 +``` + +Run `docker compose up` again and check the new ports with `lsof`. Update the +environment variables to use the new ports: + +```shell +export UTA_DB_URL='postgresql://anonymous:anonymous@localhost:5433/uta/uta_20241220' +export GA4GH_VRS_DATAPROXY_URI='seqrepo+http://localhost:5001/seqrepo' +export SEQREPO_URI="$GA4GH_VRS_DATAPROXY_URI" +``` + +Test using the new host ports: + +```shell +psql -XAt 'postgresql://anonymous:anonymous@localhost:5433/uta' \ + -c 'select count(*) from uta_20241220.transcript' +curl --write-out '\n' 'http://localhost:5001/seqrepo/1/sequence/refseq:NM_000059.4?end=20' +``` + +### Other connection and data errors + +- **UTA role or schema missing:** check that the URL reaches the intended UTA + container, rather than another PostgreSQL server, and names the installed schema. +- **Unknown sequence or alias:** check accession versions, assembly, and whether + the dataset contains the requested reference. +- **Invalid data-proxy scheme:** include `seqrepo+`; a bare HTTP URL is insufficient. diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 00000000..fbbf9eae --- /dev/null +++ b/docs/development.md @@ -0,0 +1,106 @@ +# Development and contributing + +## Installing for development + +Install Python 3.14, available as `python3.14`, before running `make devready`. + +[Fork the GitHub repo](https://github.com/ga4gh/vrs-python/fork), then clone your +fork and initialize a development environment: + +```shell +git clone --recurse-submodules git@github.com:YOUR_GITHUB_ID/vrs-python.git +cd vrs-python +make devready +source venv/3.14/bin/activate +``` + +`make devready` installs development dependencies and pre-commit hooks. For a +manually prepared environment, install the development dependencies: + +```shell +python -m pip install -e '.[tests,lint,docs,extras,notebooks]' +``` + +If you already cloned the repo, but forgot to include `--recurse-submodules` you can run: + +```shell +git submodule update --init --recursive +``` + +Keep the VRS submodule at the commit recorded by this repository when switching +branches. Do not update it incidentally while changing documentation or code. + +## Set up SeqRepo and UTA + +Depending on the code or notebooks you work on, you may need to configure +SeqRepo for reference sequences and UTA for transcript metadata and alignments. +See [Set up SeqRepo and UTA](data-services.md) for setup options and environment +variables. + +## Install the pre-commit hooks + +If you installed the development dependencies manually, install the hooks: + +```shell +pre-commit install +``` + +This step is already included in `make devready`. + +## Run the style checks + +After making your changes, check linting and formatting: + +```shell +python3 -m ruff check . +python3 -m ruff format --check . +``` + +## Run the tests + +Add focused tests for changed behavior, then run the test suite: + +```shell +python3 -m pytest +``` + +The test suite includes VRS compliance tests from the submodule. For direct pytest +runs, set the SeqRepo path and use recorded network responses, as CI does: + +```shell +SEQREPO_ROOT_DIR=tests/data/seqrepo/latest python3 -m pytest --vcr-record=none +``` + +## Build and preview the documentation + +Edit the documentation sources: + +- Markdown pages in `docs`. +- API docstrings in `src`. +- Notebooks in `notebooks/getting_started`. + +The build generates `docs-build` and `site`. Do not edit or commit these directories. + +Build the documentation with strict checks before opening a pull request: + +```shell +make docs +``` + +To preview the documentation locally: + +```shell +make docs-serve +``` + +Open . After editing source pages or notebooks, stop the +server and rerun the preview command to refresh the staged documentation. + +## Open a pull request + +Run the checks relevant to your changes, review the generated documentation, and +open a pull request on GitHub against `main`. Include a short summary of the change +and any relevant testing or documentation notes. + +- Use `Closes #123` to close an issue automatically when the pull request merges. +- Use `Refs #123` or link the issue in GitHub for related issues that remain open. diff --git a/docs/extras/vcf_annotator.md b/docs/extras/vcf_annotator.md deleted file mode 100644 index eced28b0..00000000 --- a/docs/extras/vcf_annotator.md +++ /dev/null @@ -1,52 +0,0 @@ -# VCF Annotator - -The [VCF Annotator tool](../../src/ga4gh/vrs/extras/annotator/vcf.py) provides a Python class for annotating VCFs with VRS Allele IDs. A [command-line interface](../../src/ga4gh/vrs/extras/annotator/cli.py) is available for accessing these functions from a shell or shell script. - -## How to use - -*Note:\ -The examples run from the root of the vrs-python directory and assumes that `input.vcf.gz` lives in the current directory* - -To see the help page: - -```commandline -vrs-annotate vcf --help -``` - -### Configuring the sequence data proxy - -Like other VRS-Python tools, the VCF annotator requires access to [sequence and identifier data services](https://vrs.ga4gh.org/en/stable/impl-guide/required_data.html#data-services), as implemented in libraries like [SeqRepo](https://github.com/biocommons/biocommons.seqrepo). By default, the CLI will attempt to connect to a [SeqRepo REST instance](https://github.com/biocommons/seqrepo-rest-service) at `http://localhost:5000/seqrepo`, but a URI can be passed with the `--dataproxy-uri` option or set with the `GA4GH_VRS_DATAPROXY_URI` environment variable (the former takes priority over the latter). - -For example, to use a local set of SeqRepo data, you can use an absolute file path: - -```commandline -vrs-annotate vcf --dataproxy-uri="seqrepo+file:///usr/local/share/seqrepo/2024-12-20/" --vcf-out=out.vcf.gz input.vcf.gz -``` - -Alternative, a relative file path: - -```commandline -vrs-annotate vcf --dataproxy-uri="seqrepo+../seqrepo/2024-12-20/" --vcf-out=out.vcf.gz input.vcf.gz -``` - -Or an alternate REST path: - -```commandline -vrs-annotate vcf --dataproxy-uri="seqrepo+http://mylabwebsite.org/seqrepo" --vcf-out=out.vcf.gz input.vcf.gz -``` - -### Other Options -`--vrs-attributes` ->Will include VRS_Start, VRS_End, VRS_State fields in the INFO field. - -`--assembly` [TEXT] ->The assembly that the `vcf-in` data uses. [default: GRCh38] - -`--skip-ref` ->Skip VRS computation for REF alleles. - -`--require-validation` ->Require validation checks to pass in order to return a VRS object - -`--help` ->Show the options available diff --git a/docs/extras/vrs-annotate.md b/docs/extras/vrs-annotate.md new file mode 100644 index 00000000..c313e8a9 --- /dev/null +++ b/docs/extras/vrs-annotate.md @@ -0,0 +1,32 @@ +# VRS annotate + +Use `vrs-annotate` to annotate input files with VRS variation objects: + +```shell +vrs-annotate --help +``` + +## VCF + +Install `ga4gh.vrs[extras]` and configure [SeqRepo](../data-services.md). +Then annotate a VCF with VRS allele identifiers: + +```shell +vrs-annotate vcf \ + --dataproxy-uri='seqrepo+http://localhost:5000/seqrepo' \ + --assembly=GRCh38 \ + --vcf-out=out.vcf.gz \ + input.vcf.gz +``` + +Set `--assembly` to the input VCF's reference assembly. Set the data-proxy URI with +`--dataproxy-uri` or `GA4GH_VRS_DATAPROXY_URI`. The command-line option overrides +the environment variable. + +For available options and defaults: + +```shell +vrs-annotate vcf --help +``` + +To annotate from Python, see the [VCF annotation API](../api/vcf-annotation.md). diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..fbc0464d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,45 @@ +# VRS-Python + +VRS-Python implements the +[GA4GH Variation Representation Specification (VRS)](https://vrs.ga4gh.org/) +in Python. It helps you represent variants consistently and compare records +across data sources using identifiers computed from their content. + +Use VRS-Python to: + +- Build and validate VRS and GKM-Core objects with Pydantic + (see [VRS compatibility](compatibility.md)). +- Normalize alleles and compute consistent GA4GH identifiers. +- Translate supported HGVS, SPDI, and gnomAD expressions to VRS. +- Annotate VCF files with VRS allele identifiers. +- Store and exchange objects using inline or referenced components. + +## Start using VRS-Python + +
+ +- **[Install](installation.md)** + + Choose the dependencies for your workflow. + +- **[Quick start](quick-start.md)** + + Build your first allele and compute its identifier. + +- **[Explore with notebooks](notebooks/index.md)** + + Work through models, sequence access, and translation examples. + +- **[API reference](api/index.md)** + + Find Python classes, functions, and their parameters. + +- **[Set up SeqRepo and UTA](data-services.md)** + + Connect sequence and transcript data for translation and normalization. + +- **[Contribute](development.md)** + + Improve the implementation, examples, and documentation. + +
diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..ab06e206 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,65 @@ +# Installation + +VRS-Python requires **Python 3.11 or later**. Install it in a virtual environment: + +```shell +python -m venv venv +source venv/bin/activate +python -m pip install ga4gh.vrs +``` + +The base package supports model validation, serialization, and identifier computation. + +## Translation, local sequence access, and VCF annotation + +Install `extras` for [SeqRepo](https://github.com/biocommons/seqrepo), +[UTA](https://github.com/biocommons/uta), +[HGVS support](https://github.com/biocommons/hgvs), and VCF annotation. + +### Prerequisites + +Install the prerequisites for your platform: + +#### macOS + +With [Homebrew](https://docs.brew.sh/Installation) installed, run: + +```shell +brew update +brew install libpq +brew install python3 +brew install postgresql@14 +``` + +#### Ubuntu + +```shell +sudo apt install gcc libpq-dev python3-dev +``` + +### Install the extras + +In your virtual environment, run: + +```shell +python -m pip install 'ga4gh.vrs[extras]' +``` + +Sequence and transcript datasets require separate setup: + +- Set up SeqRepo for allele normalization, SPDI/gnomAD translation, and VCF annotation. +- Set up UTA for HGVS workflows that need transcript metadata or alignments. +- Model construction, serialization, and identifier computation can run without + either service; reference sequence validation requires SeqRepo. + +Follow [Set up SeqRepo and UTA](data-services.md) for configuration instructions. + +## Notebooks + +The `notebooks` group includes dependencies for running the +[example notebooks](notebooks/index.md). Include `extras` for the translation and +sequence-access examples: + +```shell +python -m pip install 'ga4gh.vrs[extras,notebooks]' +``` diff --git a/docs/notebooks/index.md b/docs/notebooks/index.md new file mode 100644 index 00000000..8273bfe7 --- /dev/null +++ b/docs/notebooks/index.md @@ -0,0 +1,79 @@ +# Explore with notebooks + +The walkthroughs below are rendered examples, so you can read them directly in +your browser without installing anything. They demonstrate how to use VRS-Python +to build variation models, compute identifiers, translate variant descriptions, +and access sequence data. You can also download a notebook from its page and run +it in Jupyter. Pages show saved outputs, which may differ from a fresh run against +your installed release and configured data services. + +| Notebook | What you will learn | +| --- | --- | +| [Quick start](1_Quick_Start.md) | Translate a variant using sequence services | +| [SeqRepo data proxy](2_Exploring_the_SeqRepo_DataProxy.md) | Retrieve sequences and resolve aliases | +| [Basic models](3_Basic_Models.md) | Build alleles and compute identifiers | +| [Allele translator](4_Exploring_the_AlleleTranslator.md) | Translate supported variant nomenclatures | +| [CNV translator](5_Exploring_the_CnvTranslator.md) | Represent copy number variation | +| [Upcoming features](6_Upcoming_features.md) | Explore development examples, subject to change | +| [Uncertain HGVS ranges](7_Uncertain_Range_HGVS.md) | Work with uncertain coordinates | + +!!! note "Data access" + + Some notebooks use public demonstration endpoints for sequence and transcript + data. These endpoints are intended for exploring the examples. For heavy + workloads or production use, we recommend running your own local services. + Follow [SeqRepo and UTA](../data-services.md) to set them up, then update the + notebooks to use your endpoints. Inspect setup cells before running them, + since they may override environment variables you set in the shell. + +## Run the notebooks with MyBinder + +[Binder](https://mybinder.org) provides a ready-to-use computing environment for running +the notebooks directly in your browser, with no local installation required. + +You can launch the notebooks on Binder [here](https://mybinder.org/v2/gh/ga4gh/vrs-python/v3?labpath=notebooks). + +Once launched, select `VRS_kernel` as the notebook kernel. + +## Run the notebooks locally + +Clone the [VRS-Python repository](https://github.com/ga4gh/vrs-python), then follow the +[Installation steps](../installation.md) to create the virtual environment (`venv`) +and activate it. + +!!! note "Notebook dependency" + + If you did not install the `notebooks` optional dependency during setup, + run this command from the root of the cloned project (`vrs-python/`), + with the virtual environment activated: + + ```shell + python3 -m pip install "ga4gh.vrs[extras,notebooks]" + ``` + +### Open a notebook + +We recommend either of the following options for opening a notebook. + +#### JupyterLab + +1. In the terminal, activate the project's `venv` virtual environment: + + source venv/bin/activate + +2. In the activated virtual environment, start [JupyterLab](https://docs.jupyter.org/en/latest/): + + python3 -m jupyterlab + +3. JupyterLab usually opens automatically in a new browser window. If it does not, open + the URL shown in the terminal. +4. Open a notebook from the `notebooks/` directory. + +#### VS Code + +1. Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + and [Jupyter extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter). +2. Open the project root in VS Code and open a notebook from the + `notebooks/` directory. +3. Select **Select Kernel** in the upper-right corner and choose the Python + interpreter from the repository's `venv` virtual environment. diff --git a/docs/quick-start.md b/docs/quick-start.md new file mode 100644 index 00000000..456e8e68 --- /dev/null +++ b/docs/quick-start.md @@ -0,0 +1,151 @@ +# Quick start + +Build a VRS allele, compute its identifier, and translate between HGVS and VRS. + +- **Build and identify:** uses SeqRepo to resolve a reference sequence accession. +- **Translate HGVS:** also configures UTA for transcript metadata and alignments. + +Identifier computation itself does not require an external service. + +## Build and identify an allele + +Before running this example: + +1. Install [extras](installation.md#install-the-extras). +2. Start [SeqRepo](data-services.md#docker-compose). + +Create an allele for `NC_000019.10:g.44908684T>C`: + +```python +from ga4gh.core import ga4gh_identify +from ga4gh.vrs import models +from ga4gh.vrs.dataproxy import create_dataproxy + +dp = create_dataproxy("seqrepo+http://localhost:5000/seqrepo") + +# Resolve the RefSeq accession to a RefGet accession. +refget_accession = dp.derive_refget_accession("NC_000019.10") +if refget_accession is None: + raise ValueError("NC_000019.10 was not found in the SeqRepo dataset") + +allele = models.Allele( + # Reference sequence and interval to replace. + location=models.SequenceLocation( + sequenceReference=models.SequenceReference( + refgetAccession=refget_accession + ), + # Zero-based, inter-residue coordinates spanning residue 44908684. + start=44908683, + end=44908684, + ), + state=models.LiteralSequenceExpression(sequence="C"), # Replacement sequence. +) +``` + +Compute the identifier and print the allele as JSON: + +```python +identifier = ga4gh_identify(allele) +print(identifier) +print(allele.model_dump_json(exclude_none=True, indent=2)) +``` + +The identifier is: + +```text +ga4gh:VA.NsWfIPdbQ9LWo4Z5f9lIhMW87kZCtrEc +``` + +In the JSON, `id` is the GA4GH identifier, `digest` is its digest component, +and `type` names the VRS object type: + +```json +{ + "id": "ga4gh:VA.NsWfIPdbQ9LWo4Z5f9lIhMW87kZCtrEc", + "type": "Allele", + "digest": "NsWfIPdbQ9LWo4Z5f9lIhMW87kZCtrEc", + "location": { + "type": "SequenceLocation", + "digest": "bqt0x0LbTvEpKXw2x7cUfww7mI_Q_pZJ", + "sequenceReference": { + "type": "SequenceReference", + "refgetAccession": "SQ.IIB53T8CNeJJdUqzn9V_JnRtQadwWCbl" + }, + "start": 44908683, + "end": 44908684 + }, + "state": { + "type": "LiteralSequenceExpression", + "sequence": "C" + } +} +``` + +## Translate HGVS to VRS + +Start [UTA](data-services.md#docker-compose) before running this example. + +Configure UTA and create a translator with the data proxy from above: + +```python +import os + +os.environ["UTA_DB_URL"] = "postgresql://anonymous:anonymous@localhost:5432/uta/uta_20241220" + +from ga4gh.vrs.extras.translator import AlleleTranslator + +translator = AlleleTranslator(dp) +``` + +Translate the same HGVS expression. By default, translation +[normalizes the allele](api/normalization.md) and computes its identifier: + +```python +allele = translator.to_vrs("NC_000019.10:g.44908684T>C", fmt="hgvs") +print(allele.model_dump_json(exclude_none=True, indent=2)) +``` + +The allele and its identifier match the first example. Translation also assigns +an `id` to the location: + +```json +{ + "id": "ga4gh:VA.NsWfIPdbQ9LWo4Z5f9lIhMW87kZCtrEc", + "type": "Allele", + "digest": "NsWfIPdbQ9LWo4Z5f9lIhMW87kZCtrEc", + "location": { + "id": "ga4gh:SL.bqt0x0LbTvEpKXw2x7cUfww7mI_Q_pZJ", + "type": "SequenceLocation", + "digest": "bqt0x0LbTvEpKXw2x7cUfww7mI_Q_pZJ", + "sequenceReference": { + "type": "SequenceReference", + "refgetAccession": "SQ.IIB53T8CNeJJdUqzn9V_JnRtQadwWCbl" + }, + "start": 44908683, + "end": 44908684 + }, + "state": { + "type": "LiteralSequenceExpression", + "sequence": "C" + } +} +``` + +## Translate back to HGVS + +`from_vrs` returns a list because a sequence can have multiple accessions. +By default, it uses RefSeq accessions in your SeqRepo dataset: + +```python +hgvs_expressions = translator.from_vrs(allele, fmt="hgvs") +print(hgvs_expressions) +``` + +The result includes the original expression; other entries depend on your dataset: + +```text +['NC_000019.10:g.44908684T>C'] +``` + +See the [translation API](api/translation-and-hgvs.md) for options or +[explore the notebooks](notebooks/index.md) for more examples. diff --git a/docs/setup_help/m1_mac_setup.md b/docs/setup_help/m1_mac_setup.md deleted file mode 100644 index 0b354cb6..00000000 --- a/docs/setup_help/m1_mac_setup.md +++ /dev/null @@ -1,49 +0,0 @@ -#Notes from Wes Goar on setup of vrs-python on a m1 mac -- date: 20220328 -- macOS version: 12.3 -- python version: 3.9.11 - -##Notes -- I installed seqrepo before trying this setup. -- I had already installed xcode and homebrew on my machine. -- This installation assumes you are using zsh. Please change the commands to fit your environment of choice. - -###Steps -1. brew install openssl -2. add the following statement in your .zshrc: -```shell -export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH" -``` - -3. Run brew info openssl to ascertain the correct environment path to put into the export statements (add the following statements, but follow your info, into your .zshenv:) -```shell -export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib" -export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" -export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig" -``` - -4. source ~/.zshrc -5. source ~/.zshenv -6. brew install libpq -7. add the following statement in your .zshrc: -```shell -export PATH="/opt/homebrew/opt/libpq/bin:$PATH" -``` -8. Run brew info libpq to ascertain the correct environment path to append to the appropriate flags (add the following statements, but follow your info, into your .zshenv:) - -```shell -export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/libpq/lib" -export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/libpq/include" -export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig:/opt/homebrew/opt/libpq/lib/pkgconfig" -``` - -9. source ~/.zshenv -10. brew install postgres -11. add the following statement in your .zshrc: export PATH="/opt/homebrew/opt/postgresql@14/bin:$PATH" - ###Make sure that you update the @14 with your own version -12. source ~/.zshrc -13. Install UTA (/docs/setup_help/uta_installation.md) -14. Run the make devready command: - 1. `make devready` -15. Run the make test command: - 1. `make test` diff --git a/docs/setup_help/uta_installation.md b/docs/setup_help/uta_installation.md deleted file mode 100644 index e7aee780..00000000 --- a/docs/setup_help/uta_installation.md +++ /dev/null @@ -1,33 +0,0 @@ -1. Switch to your admin account #Skip if your user already has sudo permissions - 1. `su wag002adm` # replace with your admin account name -2. Start postgres - 1. `pg_ctl -D /opt/homebrew/var/postgres start` - 2. `ps aux | grep postgres` #to make sure that this process is running -3. Start psql and open database postgres, which is the database postgres uses itself to store roles, permissions, and structure: - 1. `psql postgres` -4. Create roles for the application, give login and CREATEDB permissions: - 1. `CREATE ROLE uta_admin WITH LOGIN CREATEDB;` - 2. `CREATE ROLE anonymous WITH LOGIN CREATEDB;` -5. List the users using the command - 1. `\du` -6. Create the UTA Database object - 1. `CREATE DATABASE uta;` -7. Grant privileges to manage the database to uta_admin - 1. `GRANT ALL PRIVILEGES ON DATABASE uta TO uta_admin;` -8. Exit postgres - 1. `\q` -9. Download the UTA database and place it in the uta database object that you created before (**This step takes around 5 hours**). - 1. `export UTA_VERSION=uta_20241220.pgd.gz\ncurl -O http://dl.biocommons.org/uta/$UTA_VERSION\ngzip -cdq ${UTA_VERSION} | psql -h localhost -U uta_admin --echo-errors --single-transaction -v ON_ERROR_STOP=1 -d uta -p 5432` -10. Set your UTA path - 1. `export UTA_DB_URL=postgresql://uta_admin@localhost:5432/uta/uta_20241220` -###Optional installation step -11. If you wanted to wait for the 5 hour update till later please follow these steps instead: -12. Download the UTA database and place it in the uta database object that you created before. - 1. `export UTA_VERSION=uta_20241220.pgd.gz -curl -O http://dl.biocommons.org/uta/$UTA_VERSION -gzip -cdq ${UTA_VERSION} | grep -v "^REFRESH MATERIALIZED VIEW" | psql -h localhost -U uta_admin --echo-errors --single-transaction -v ON_ERROR_STOP=1 -d uta -p 5432` -13. Run the refresh materialized view commands - 1. `REFRESH MATERIALIZED VIEW uta_20241220.exon_set_exons_fp_mv;` - 2. `REFRESH MATERIALIZED VIEW uta_20241220.tx_exon_set_summary_mv;` - 3. `REFRESH MATERIALIZED VIEW uta_20241220.tx_def_summary_mv;` - 4. `REFRESH MATERIALIZED VIEW uta_20241220.tx_similarity_mv;` #**This step will take 5 or more hours** diff --git a/pyproject.toml b/pyproject.toml index 365f697b..75556c7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,8 +65,9 @@ lint = [ "ruff==0.9.4", ] docs = [ - "sphinx", - "sphinx_rtd_theme", + "zensical==0.0.59", + "mkdocstrings-python", + "nbconvert>=7,<8", ] notebooks = [ "jupyter", @@ -75,7 +76,7 @@ notebooks = [ [project.urls] Homepage = "https://github.com/ga4gh/vrs-python" -Documentation = "https://github.com/ga4gh/vrs-python" +Documentation = "https://ga4gh.github.io/vrs-python/latest/" Changelog = "https://github.com/ga4gh/vrs-python/releases" Source = "https://github.com/ga4gh/vrs-python" "Bug Tracker" = "https://github.com/ga4gh/vrs-python/issues" diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 00000000..06f551ae --- /dev/null +++ b/scripts/__init__.py @@ -0,0 +1 @@ +"""Documentation build utilities.""" diff --git a/scripts/build_docs.py b/scripts/build_docs.py new file mode 100644 index 00000000..85cde510 --- /dev/null +++ b/scripts/build_docs.py @@ -0,0 +1,94 @@ +"""Stage authored pages, supported versions, and notebooks for Zensical.""" + +import json +import re +from pathlib import Path +from shutil import copy2, copytree, rmtree + +from nbconvert import MarkdownExporter + +from ga4gh.core.version import CORE_VERSION +from ga4gh.vrs.version import VRS_VERSION + +ROOT = Path(__file__).resolve().parents[1] + + +def output_language(text: str, default: str = "text") -> str: + """Select JSON highlighting for JSON values, otherwise use the fallback. + + :param text: Saved notebook output. + :param default: Language for non-JSON output. + :return: Code-fence language. + """ + try: + json.loads(text) + except (ValueError, TypeError): + return default + return "json" + + +def update_supported_versions(path: Path) -> None: + """Replace the supported-versions marker with the installed versions. + + :param path: Staged compatibility page. + """ + table = ( + "| Standard | Supported version |\n| --- | --- |\n" + f"| VRS | {VRS_VERSION} |\n| GKM-Core | {CORE_VERSION} |" + ) + content = path.read_text(encoding="utf-8") + path.write_text( + content.replace("", table), encoding="utf-8" + ) + + +def stage_notebook(source: Path, destination: Path, exporter: MarkdownExporter) -> None: + """Write a notebook's rendered page, source, and saved output files. + + :param source: Notebook within the repository. + :param destination: Staged notebook directory. + :param exporter: Markdown exporter using saved notebook outputs. + """ + body, resources = exporter.from_filename(str(source)) + body = body.replace("](README.md)", "](index.md)") + # Notebook links should open the corresponding rendered page. + body = re.sub(r"\]\(([^:)]+)\.ipynb(#[^)]*)?\)", r"](\1.md\2)", body) + + notice = ( + '!!! info "Notebook source"\n\n' + f" Rendered from [{source.relative_to(ROOT)}]({source.name}).\n\n" + ) + if "Upcoming" in source.name: + notice += ( + '!!! warning "Exploratory material"\n\n' + " This notebook describes upcoming features, not a guarantee of " + "support in the current release.\n\n" + ) + + (destination / f"{source.stem}.md").write_text(notice + body, encoding="utf-8") + copy2(source, destination / source.name) + for name, data in resources.get("outputs", {}).items(): + target = destination / name + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(data) + + +def main() -> None: + """Rebuild docs-build from source without executing notebooks.""" + output = ROOT / "docs-build" + if output.exists(): + rmtree(output) + copytree(ROOT / "docs", output) + update_supported_versions(output / "compatibility.md") + + exporter = MarkdownExporter( + extra_template_basedirs=[str(ROOT / "scripts/templates")], + template_file=str(ROOT / "scripts/templates/notebook.md.j2"), + filters={"output_language": output_language}, + ) + for source in sorted((ROOT / "notebooks/getting_started").glob("*.ipynb")): + stage_notebook(source, output / "notebooks", exporter) + + +if __name__ == "__main__": + main() diff --git a/scripts/templates/notebook.md.j2 b/scripts/templates/notebook.md.j2 new file mode 100644 index 00000000..4ad6df59 --- /dev/null +++ b/scripts/templates/notebook.md.j2 @@ -0,0 +1,31 @@ +{% extends 'markdown/index.md.j2' %} + +{% block input %} +````python{% if cell.execution_count is not none %} title="In [{{ cell.execution_count }}]"{% endif %} +{{ cell.source }} +```` +{% endblock input %} + +{% block stream %} +**Output:** + +````{{ output.text | output_language }} +{{ output.text | strip_ansi | trim }} +```` +{% endblock stream %} + +{% block data_text scoped %} +**Output:** + +````{{ output.data['text/plain'] | output_language('python') }} +{{ output.data['text/plain'] | strip_ansi | trim }} +```` +{% endblock data_text %} + +{% block error %} +**Output:** + +````text +{{ output.traceback | join('\n') | strip_ansi }} +```` +{% endblock error %} diff --git a/src/ga4gh/core/digests.py b/src/ga4gh/core/digests.py index 1ffbe2d4..3fe40580 100644 --- a/src/ga4gh/core/digests.py +++ b/src/ga4gh/core/digests.py @@ -21,11 +21,11 @@ def sha512t24u(blob: bytes) -> str: For example: - >>> sha512t24u(b"") - 'z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXc' + >>> sha512t24u(b"") + 'z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXc' - >>> sha512t24u(b"ACGT") - 'aKF498dAxcJAqme6QYQ7EZ07-fiw8Kw2' + >>> sha512t24u(b"ACGT") + 'aKF498dAxcJAqme6QYQ7EZ07-fiw8Kw2' :param blob: Binary data to digest. :return: URL-safe base64 encoding of the first 24 digest bytes. diff --git a/src/ga4gh/core/identifiers.py b/src/ga4gh/core/identifiers.py index a36b747e..3bb68d3a 100644 --- a/src/ga4gh/core/identifiers.py +++ b/src/ga4gh/core/identifiers.py @@ -144,14 +144,16 @@ def __exit__( def is_ga4gh_identifier(ir: object) -> bool: """Check whether a value starts with the GA4GH namespace prefix - >>> is_ga4gh_identifier("ga4gh:SQ.0123abcd") - True + For example: - >>> is_ga4gh_identifier("refseq:NM_01234.5") - False + >>> is_ga4gh_identifier("ga4gh:SQ.0123abcd") + True - >>> is_ga4gh_identifier(None) - False + >>> is_ga4gh_identifier("refseq:NM_01234.5") + False + + >>> is_ga4gh_identifier(None) + False :param ir: Value or root model to inspect. :return: Whether the value has the GA4GH namespace prefix. @@ -182,17 +184,19 @@ def ga4gh_identify( updates; it does not override the context policy. Accepts a supported PrevVrsVersion member or its string value. Raises ValueError for other version values. - >>> from ga4gh.core import ga4gh_identify - >>> import ga4gh.vrs - >>> location = ga4gh.vrs.models.SequenceLocation( - ... start=44908821, - ... end=44908822, - ... sequenceReference=ga4gh.vrs.models.SequenceReference( - ... refgetAccession="SQ.F-LrLMe1SRpfUZHkQmvkVKFEGaoDeHul" - ... ), - ... ) - >>> ga4gh_identify(location) - 'ga4gh:SL.4t6JnYWqHwYw9WzBT_lmWBb3tLQNalkT' + For example: + + >>> from ga4gh.core import ga4gh_identify + >>> import ga4gh.vrs + >>> location = ga4gh.vrs.models.SequenceLocation( + ... start=44908821, + ... end=44908822, + ... sequenceReference=ga4gh.vrs.models.SequenceReference( + ... refgetAccession="SQ.F-LrLMe1SRpfUZHkQmvkVKFEGaoDeHul" + ... ), + ... ) + >>> ga4gh_identify(location) + 'ga4gh:SL.4t6JnYWqHwYw9WzBT_lmWBb3tLQNalkT' :param vro: GA4GH model implementing is_ga4gh_identifiable and the digest and identifier methods used for identifiable objects. @@ -236,17 +240,19 @@ def ga4gh_digest( supported PrevVrsVersion member or its string value. Raises ValueError for other version values. - >>> from ga4gh.core import ga4gh_digest - >>> import ga4gh.vrs - >>> location = ga4gh.vrs.models.SequenceLocation( - ... start=44908821, - ... end=44908822, - ... sequenceReference=ga4gh.vrs.models.SequenceReference( - ... refgetAccession="SQ.F-LrLMe1SRpfUZHkQmvkVKFEGaoDeHul" - ... ), - ... ) - >>> ga4gh_digest(location) - '4t6JnYWqHwYw9WzBT_lmWBb3tLQNalkT' + For example: + + >>> from ga4gh.core import ga4gh_digest + >>> import ga4gh.vrs + >>> location = ga4gh.vrs.models.SequenceLocation( + ... start=44908821, + ... end=44908822, + ... sequenceReference=ga4gh.vrs.models.SequenceReference( + ... refgetAccession="SQ.F-LrLMe1SRpfUZHkQmvkVKFEGaoDeHul" + ... ), + ... ) + >>> ga4gh_digest(location) + '4t6JnYWqHwYw9WzBT_lmWBb3tLQNalkT' :param vro: GA4GH model implementing is_ga4gh_identifiable and the digest and identifier methods used for identifiable objects. diff --git a/src/ga4gh/vrs/dataproxy.py b/src/ga4gh/vrs/dataproxy.py index 04ca6b8f..24ae9303 100644 --- a/src/ga4gh/vrs/dataproxy.py +++ b/src/ga4gh/vrs/dataproxy.py @@ -61,8 +61,10 @@ def get_sequence( If the given sequence does not exist, KeyError is raised. If start is after end, DataProxyValidationError may be raised. - >>> dp.get_sequence("NM_000551.3", 0, 10) - 'CCTCGCCTCC' + For example: + + >>> dp.get_sequence("NM_000551.3", 0, 10) + 'CCTCGCCTCC' :param identifier: Sequence identifier to resolve. :param start: Zero-based inclusive start, or None for the sequence start. @@ -78,16 +80,18 @@ def get_metadata(self, identifier: str) -> dict: If the given sequence does not exist, KeyError is raised. - >>> dp.get_metadata("NM_000551.3") - {'added': '2016-08-24T05:03:11Z', - 'aliases': ['MD5:215137b1973c1a5afcf86be7d999574a', - 'RefSeq:NM_000551.3', - 'SEGUID:T12L0p2X5E8DbnL0+SwI4Wc1S6g', - 'SHA1:4f5d8bd29d97e44f036e72f4f92c08e167354ba8', - 'ga4gh:SQ.v_QTc1p-MUYdgrRv4LMT6ByXIOsdw3C_', - 'gi:319655736'], - 'alphabet': 'ACGT', - 'length': 4560} + For example: + + >>> dp.get_metadata("NM_000551.3") + {'added': '2016-08-24T05:03:11Z', + 'aliases': ['MD5:215137b1973c1a5afcf86be7d999574a', + 'RefSeq:NM_000551.3', + 'SEGUID:T12L0p2X5E8DbnL0+SwI4Wc1S6g', + 'SHA1:4f5d8bd29d97e44f036e72f4f92c08e167354ba8', + 'ga4gh:SQ.v_QTc1p-MUYdgrRv4LMT6ByXIOsdw3C_', + 'gi:319655736'], + 'alphabet': 'ACGT', + 'length': 4560} :param identifier: Sequence identifier to resolve. :return: Sequence metadata, including length and aliases. @@ -489,9 +493,11 @@ def __getitem__(self, key: int | slice) -> str: def _isoformat(o: datetime.datetime) -> str: """Convert datetime.datetime to iso formatted timestamp - >>> dt = datetime.datetime(2019, 10, 15, 10, 23, 41, 115927) - >>> _isoformat(dt) - '2019-10-15T10:23:41.115927Z' + For example: + + >>> dt = datetime.datetime(2019, 10, 15, 10, 23, 41, 115927) + >>> _isoformat(dt) + '2019-10-15T10:23:41.115927Z' :param o: date object to format :return: ISO8601-formatted string equivalent diff --git a/src/ga4gh/vrs/extras/translator.py b/src/ga4gh/vrs/extras/translator.py index a3e3aa58..b23ffb6a 100644 --- a/src/ga4gh/vrs/extras/translator.py +++ b/src/ga4gh/vrs/extras/translator.py @@ -329,11 +329,11 @@ def from_gnomad( With ``tlr`` configured for the reference sequence, disable normalization to inspect the input coordinates and alternate sequence: - >>> a = tlr.from_gnomad("1-55516888-G-GA", do_normalize=False) - >>> a.location.start, a.location.end - (55516887, 55516888) - >>> a.state.sequence.root - 'GA' + >>> a = tlr.from_gnomad("1-55516888-G-GA", do_normalize=False) + >>> a.location.start, a.location.end + (55516887, 55516888) + >>> a.state.sequence.root + 'GA' """ if not isinstance(gnomad_expr, str): @@ -433,11 +433,11 @@ def from_spdi( With ``tlr`` configured for the reference sequence, disable normalization to inspect the input coordinates and alternate sequence: - >>> a = tlr.from_spdi("NC_000013.11:32936731:1:C", do_normalize=False) - >>> a.location.start, a.location.end - (32936731, 32936732) - >>> a.state.sequence.root - 'C' + >>> a = tlr.from_spdi("NC_000013.11:32936731:1:C", do_normalize=False) + >>> a.location.start, a.location.end + (32936731, 32936732) + >>> a.state.sequence.root + 'C' """ if not isinstance(spdi_expr, str): diff --git a/zensical.toml b/zensical.toml new file mode 100644 index 00000000..1c4cfe19 --- /dev/null +++ b/zensical.toml @@ -0,0 +1,115 @@ +[project] +site_name = "VRS-Python" +site_description = "Represent, normalize, and identify genomic variation in Python" +site_url = "https://ga4gh.github.io/vrs-python/" +repo_url = "https://github.com/ga4gh/vrs-python" +repo_name = "ga4gh/vrs-python" +edit_uri = "edit/main/docs/" +docs_dir = "docs-build" +extra_css = ["assets/css/extra.css"] +extra_javascript = ["assets/js/external-links.js"] +strict = true +nav = [ + { Home = "index.md" }, + { Installation = "installation.md" }, + { "Quick start" = "quick-start.md" }, + { "Set up SeqRepo and UTA" = "data-services.md" }, + { "VRS annotate" = "extras/vrs-annotate.md" }, + { "Explore with notebooks" = [ + "notebooks/index.md", + { "Quick start" = "notebooks/1_Quick_Start.md" }, + { "Sequence access" = "notebooks/2_Exploring_the_SeqRepo_DataProxy.md" }, + { "Models" = "notebooks/3_Basic_Models.md" }, + { "Allele translation" = "notebooks/4_Exploring_the_AlleleTranslator.md" }, + { "Copy number translation" = "notebooks/5_Exploring_the_CnvTranslator.md" }, + { "Upcoming features" = "notebooks/6_Upcoming_features.md" }, + { "Uncertain HGVS ranges" = "notebooks/7_Uncertain_Range_HGVS.md" }, + ] }, + { "API reference" = [ + "api/index.md", + { "GKM-Core models" = "api/core-models.md" }, + { "VRS models" = "api/vrs-models.md" }, + { "Identifiers and digests" = "api/identifiers-and-digests.md" }, + { Normalization = "api/normalization.md" }, + { "Data proxies" = "api/data-proxies.md" }, + { "Translation and HGVS" = "api/translation-and-hgvs.md" }, + { "Object references and storage" = "api/object-references-and-storage.md" }, + { "VCF annotation" = "api/vcf-annotation.md" }, + ] }, + { "VRS compatibility" = "compatibility.md" }, + { "Development and contributing" = "development.md" }, +] + +[project.extra.version] +provider = "mike" +default = "latest" + +[project.theme] +variant = "classic" +logo = "assets/images/ga4gh-favicon.svg" +favicon = "assets/images/ga4gh-favicon.svg" +features = [ + "navigation.indexes", + "navigation.top", + "toc.follow", + "content.action.edit", + "content.code.copy", + "content.tabs.link", + "search.suggest", + "search.highlight", +] + +# Palette toggle for automatic mode +[[project.theme.palette]] +media = "(prefers-color-scheme)" +toggle.icon = "lucide/sun-moon" +toggle.name = "Switch to light mode" + +# Palette toggle for light mode +[[project.theme.palette]] +media = "(prefers-color-scheme: light)" +scheme = "default" +primary = "custom" +accent = "custom" +toggle.icon = "lucide/sun" +toggle.name = "Switch to dark mode" + +# Palette toggle for dark mode +[[project.theme.palette]] +media = "(prefers-color-scheme: dark)" +scheme = "slate" +primary = "custom" +accent = "custom" +toggle.icon = "lucide/moon" +toggle.name = "Switch to system preference" + +[project.plugins.search] + +[project.plugins.mkdocstrings.handlers.python] +paths = ["src"] +options.docstring_style = "sphinx" +options.filters = ["!^_[^_]"] +options.inherited_members = false +options.merge_init_into_class = true +options.members_order = "source" +options.separate_signature = true +options.show_signature_annotations = true +options.show_source = false +options.show_symbol_type_heading = true +options.show_symbol_type_toc = true +options.signature_crossrefs = true + +[project.markdown_extensions] +admonition = {} +attr_list = {} +md_in_html = {} +pymdownx.details = {} +pymdownx.superfences = {} +tables = {} +pymdownx.inlinehilite = {} +pymdownx.highlight.anchor_linenums = true +pymdownx.tabbed.alternate_style = true +pymdownx.emoji.emoji_index = "zensical.extensions.emoji.twemoji" +pymdownx.emoji.emoji_generator = "zensical.extensions.emoji.to_svg" +pymdownx.snippets.base_path = ["."] +pymdownx.snippets.check_paths = true