Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add docs #169

Merged
merged 14 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "3.11"

python:
install:
- method: pip
path: .
extra_requirements:
- docs

sphinx:
configuration: docs/source/conf.py
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

MIT License

Copyright (c) 2021-2023 VICC
Copyright (c) 2021-2024 VICC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
7 changes: 7 additions & 0 deletions docs/source/_templates/module_summary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ fullname | underline }}

.. automodule:: {{ fullname }}
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog
---------

.. changelog::
:changelog-url: https://fusor.readthedocs.io/en/stable/#changelog
:github: https://github.com/cancervariants/fusor/releases/
:pypi: https://pypi.org/project/fusor/
79 changes: 79 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "FUSOR"
copyright = "2024, Wagner Lab"
author = "Wagner Lab"
html_title = "FUSOR"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.linkcode",
"sphinx_copybutton",
"sphinx.ext.autosummary",
"sphinx_github_changelog",
]

templates_path = ["_templates"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "furo"
html_static_path = []
html_css_files = [
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/fontawesome.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/solid.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/brands.min.css",
]
html_theme_options = {
"footer_icons": [
{
"name": "GitHub",
"url": "https://github.com/cancervariants/fusor",
"html": "",
"class": "fa-brands fa-solid fa-github",
},
{
"name": "Wagner Lab",
"url": "https://www.nationwidechildrens.org/specialties/institute-for-genomic-medicine/research-labs/wagner-lab",
"html": "",
"class": "fa-solid fa-house",
}
],
}
# -- autodoc things ----------------------------------------------------------
import os
import sys

sys.path.insert(0, os.path.abspath("../../"))
autodoc_preserve_defaults = True

# -- get version -------------------------------------------------------------
from importlib.metadata import version

release = version = version("fusor")

# -- linkcode ----------------------------------------------------------------
def linkcode_resolve(domain, info):
if domain != "py":
return None
if not info["module"]:
return None
filename = info["module"].replace(".", "/")
return f"https://github.com/cancervariants/fusor/blob/main/src/{filename}.py"


# -- code block style --------------------------------------------------------
pygments_style = "default"
pygements_dark_style = "monokai"
56 changes: 56 additions & 0 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _contributing:

Contributing
============

Bug reports and feature requests
--------------------------------

Bugs and new feature requests can be submitted to the `issue tracker on GitHub <https://github.com/cancervariants/fusor/issues>`_. See `this StackOverflow post <https://stackoverflow.com/help/minimal-reproducible-example>`_ for tips on how to craft a helpful bug report.

Development setup
-----------------

Clone the repository: ::

git clone https://github.com/cancervariants/fusor
cd fusor

Then initialize a virtual environment: ::

python3 -m virtualenv venv
source venv/bin/activate
python3 -m pip install -e '.[dev,tests,docs]'

We use `pre-commit <https://pre-commit.com/#usage>`_ to run conformance tests before commits. This provides checks for:

* Code format and style
* Added large files
* AWS credentials
* Private keys

Before your first commit, run: ::

pre-commit install

Style
-----

Code style is managed by `Ruff <https://github.com/astral-sh/ruff>`_, and should be checked via pre-commit hook before commits. Final QC is applied with GitHub Actions to every pull request.

Tests
-----

Tests are executed with `pytest <https://docs.pytest.org/en/7.1.x/getting-started.html>`_: ::

pytest

Documentation
-------------

The documentation is built with Sphinx, which is included as part of the ``docs`` dependency group. Navigate to the ``docs/`` subdirectory and use ``make`` to build the HTML version: ::

cd docs
make html

See the `Sphinx documentation <https://www.sphinx-doc.org/en/master/>`_ for more information.
30 changes: 30 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FUSOR |version|
=========================

.. image:: https://img.shields.io/pypi/v/fusor.svg
:alt: PyPI version
:target: https://pypi.python.org/pypi/fusor

.. image:: https://img.shields.io/pypi/l/fusor.svg
:alt: License
:target: https://github.com/cancervariants/fusor/blob/main/LICENSE

.. image:: https://img.shields.io/pypi/pyversions/fusor?color=gr
:alt: PyPI - supported Python versions

.. image:: https://github.com/cancervariants/fusor/actions/workflows/checks.yaml/badge.svg
:alt: tests status
:target: https://github.com/cancervariants/fusor/actions/workflows/checks.yaml

TODO

.. toctree::
:hidden:
:maxdepth: 2

Installation<install>
Usage<usage>
API Reference<reference/index>
Changelog<changelog>
Contributing<contributing>
License<license>
56 changes: 56 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _install:

Installation
============

Prerequisites
-------------

* Python 3.10+
* A UNIX-like environment (e.g. MacOS, WSL, Ubuntu)
* A recent version of PostgreSQL (ideally at least 11+)
* A modern Java runtime (if using DynamoDB for the Gene Normalizer database)

Library installation
--------------------

Install ``FUSOR`` from `PyPI <https://pypi.org/project/fusor/>`_:

.. code-block:: shell

pip install fusor

Data setup
----------

Universal Transcript Archive (UTA)
++++++++++++++++++++++++++++++++++

The `UTA <https://github.com/biocommons/uta>`_ is a dataset of genome-transcript aligned data supplied as a PostgreSQL database. Access in FUSOR is supplied by way of ``Cool-Seq-Tool``; see the `Cool-Seq-Tool UTA docs <https://coolseqtool.readthedocs.io/stable/install.html#set-up-uta>`_ for some opinionated setup instructions.

At runtime, UTA connection information can be relayed to FUSOR (by way of Cool-Seq-Tool) either as an initialization argument or via the environment variable ``UTA_DB_URL``. By default, it is set to ``postgresql://uta_admin:uta@localhost:5432/uta/uta_20210129b``. See the `Cool-Seq-Tool configuration docs <https://coolseqtool.readthedocs.io/stable/usage.html#environment-configuration>`_ for more info.

SeqRepo
+++++++

`SeqRepo <https://github.com/biocommons/biocommons.seqrepo>`_ is a controlled dataset of biological sequences. As with UTA, access in FUSOR is given via `Cool-Seq-Tool`, which provides `documentation <https://coolseqtool.readthedocs.io/stable/install.html#set-up-seqrepo>`_ on getting it set up.

At runtime, the file location of the SeqRepo instance directory can be defined (by way of Cool-Seq-Tool) either as an initialization argument or via the environment variable ``SEQREPO_ROOT_DIR``. By default, it's expected to be ``/usr/local/share/seqrepo/latest``. See the `Cool-Seq-Tool configuration docs <https://coolseqtool.readthedocs.io/stable/usage.html#environment-configuration>`_ for more info.

Gene Normalizer
+++++++++++++++

Finally, ``FUSOR`` uses the `Gene Normalizer <https://github.com/cancervariants/gene-normalization>`_ to ground gene terms. See the `Gene Normalizer documentation <https://gene-normalizer.readthedocs.io/stable/install.html>`_ for setup instructions.

Connection information for the normalizer database can be set using the environment variable ``GENE_NORM_DB_URL``. See the `Gene Normalizer docs <https://gene-normalizer.readthedocs.io/stable/reference/api/database/gene.database.database.html#gene.database.database.create_db>`_ for more information on connection configuration.

Check data availability
+++++++++++++++++++++++

Use the :py:meth:`fusor.tools.check_data_resources` method to verify that all data dependencies are available:

.. code-block:: pycon

>>> from fusor.tools import check_data_resources
>>> status = await check_data_resources()
>>> assert all(status) # passes if all resources can be acquired successfully
4 changes: 4 additions & 0 deletions docs/source/license.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
License
=======

.. include:: ../../LICENSE
8 changes: 8 additions & 0 deletions docs/source/reference/api/fusor.exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fusor.exceptions
================

.. automodule:: fusor.exceptions
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
8 changes: 8 additions & 0 deletions docs/source/reference/api/fusor.fusor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fusor.fusor
===========

.. automodule:: fusor.fusor
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
8 changes: 8 additions & 0 deletions docs/source/reference/api/fusor.models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fusor.models
============

.. automodule:: fusor.models
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
8 changes: 8 additions & 0 deletions docs/source/reference/api/fusor.nomenclature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fusor.nomenclature
==================

.. automodule:: fusor.nomenclature
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
8 changes: 8 additions & 0 deletions docs/source/reference/api/fusor.tools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fusor.tools
===========

.. automodule:: fusor.tools
:members:
:undoc-members:
:special-members: __init__
:exclude-members: model_fields, model_config
15 changes: 15 additions & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _api_reference:

API Reference
=============

.. autosummary::
:nosignatures:
:toctree: api/
:template: module_summary.rst

fusor.exceptions
fusor.fusor
fusor.models
fusor.nomenclature
fusor.tools
Loading